Class ThumbsDBImageReader
- java.lang.Object
-
- javax.imageio.ImageReader
-
- com.twelvemonkeys.imageio.ImageReaderBase
-
- com.twelvemonkeys.imageio.plugins.thumbsdb.ThumbsDBImageReader
-
public final class ThumbsDBImageReader extends ImageReaderBase
ThumbsDBImageReader- Version:
- $Id: ThumbsDBImageReader.java,v 1.0 22.jan.2007 18:49:38 haku Exp$
- See Also:
CompoundDocument, Wikipedia: Thumbs.db
-
-
Field Summary
Fields Modifier and Type Field Description private Catalogcatalogprivate intcurrentImageprivate booleanloadEagerlyprivate javax.imageio.ImageReaderreaderprivate Entryrootprivate static intTHUMBNAIL_OFFSETprivate java.awt.image.BufferedImage[]thumbnails-
Fields inherited from class com.twelvemonkeys.imageio.ImageReaderBase
imageInput
-
-
Constructor Summary
Constructors Modifier Constructor Description ThumbsDBImageReader()protectedThumbsDBImageReader(ThumbsDBImageReaderSpi pProvider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()private static voidaddImage(java.awt.Container pParent, javax.imageio.ImageReader pReader, int pImageNo, java.lang.String pName)private static javax.imageio.ImageReadercreateJPEGReader(ThumbsDBImageReaderSpi pProvider)private static javax.swing.JFramecreateWindow(java.lang.String pTitle)voiddispose()intgetHeight(int pIndex)java.util.Iterator<javax.imageio.ImageTypeSpecifier>getImageTypes(int pIndex)intgetNumImages(boolean allowSearch)Default implementation that always returns1.intgetWidth(int pIndex)private voidinit()private voidinit(int pIndex)private voidinitCatalog()private voidinitReader(int pIndex)private voidinitReaderListeners()booleanisLoadEagerly()booleanisPresent(java.lang.String pFileName)static voidmain(java.lang.String[] pArgs)java.awt.image.BufferedImageread(int pIndex, javax.imageio.ImageReadParam pParam)Reads the image data from the given input stream, and returns it as aBufferedImage.java.awt.image.BufferedImageread(java.lang.String pName, javax.imageio.ImageReadParam pParam)Reads the image data from the given input stream, and returns it as aBufferedImage.protected voidresetMembers()Resets all member variables.voidsetInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)OverridessetInput, to allow easy access to the input, in case it is anImageInputStream.voidsetLoadEagerly(boolean pLoadEagerly)Instructs the reader wether it should read and cache alle thumbnails in sequence, during the first read operation.-
Methods inherited from class com.twelvemonkeys.imageio.ImageReaderBase
assertInput, checkBounds, fakeAOI, fakeSubsampling, getDestination, getImageMetadata, getStreamMetadata, hasExplicitDestination, reset, showIt
-
Methods inherited from class javax.imageio.ImageReader
abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
-
-
-
-
Field Detail
-
THUMBNAIL_OFFSET
private static final int THUMBNAIL_OFFSET
- See Also:
- Constant Field Values
-
root
private Entry root
-
catalog
private Catalog catalog
-
thumbnails
private java.awt.image.BufferedImage[] thumbnails
-
reader
private final javax.imageio.ImageReader reader
-
currentImage
private int currentImage
-
loadEagerly
private boolean loadEagerly
-
-
Constructor Detail
-
ThumbsDBImageReader
public ThumbsDBImageReader()
-
ThumbsDBImageReader
protected ThumbsDBImageReader(ThumbsDBImageReaderSpi pProvider)
-
-
Method Detail
-
resetMembers
protected void resetMembers()
Description copied from class:ImageReaderBaseResets all member variables. This method is by default invoked from:- Specified by:
resetMembersin classImageReaderBase
-
createJPEGReader
private static javax.imageio.ImageReader createJPEGReader(ThumbsDBImageReaderSpi pProvider)
-
dispose
public void dispose()
- Overrides:
disposein classImageReaderBase
-
isLoadEagerly
public boolean isLoadEagerly()
-
setLoadEagerly
public void setLoadEagerly(boolean pLoadEagerly)
Instructs the reader wether it should read and cache alle thumbnails in sequence, during the first read operation.This is useful mainly if you need to read all the thumbnails, and you need them in random order, as it requires less repositioning in the underlying stream.
- Parameters:
pLoadEagerly-trueif the reader should read all thumbs on first read
-
read
public java.awt.image.BufferedImage read(int pIndex, javax.imageio.ImageReadParam pParam) throws java.io.IOExceptionReads the image data from the given input stream, and returns it as aBufferedImage.- Specified by:
readin classjavax.imageio.ImageReader- Parameters:
pIndex- the index of the image to readpParam- additional parameters used while decoding, may benull, in which case defaults will be used- Returns:
- a
BufferedImage - Throws:
java.lang.IndexOutOfBoundsException- ifpIndexis out of boundsjava.lang.IllegalStateException- if the input source has not been setjava.io.IOException- if an error occurs during reading
-
read
public java.awt.image.BufferedImage read(java.lang.String pName, javax.imageio.ImageReadParam pParam) throws java.io.IOExceptionReads the image data from the given input stream, and returns it as aBufferedImage.- Parameters:
pName- the name of the image to readpParam- additional parameters used while decoding, may benull, in which case defaults will be used- Returns:
- a
BufferedImage - Throws:
java.io.FileNotFoundException- if the given file name is not found in the "Catalog" entry of theCompoundDocumentjava.lang.IllegalStateException- if the input source has not been setjava.io.IOException- if an error occurs during reading
-
abort
public void abort()
- Overrides:
abortin classjavax.imageio.ImageReader
-
setInput
public void setInput(java.lang.Object input, boolean seekForwardOnly, boolean ignoreMetadata)Description copied from class:ImageReaderBaseOverridessetInput, to allow easy access to the input, in case it is anImageInputStream.- Overrides:
setInputin classImageReaderBase- Parameters:
input- theImageInputStreamor otherObjectto use for future decoding.seekForwardOnly- iftrue, images and metadata may only be read in ascending order from this input source.ignoreMetadata- iftrue, metadata may be ignored during reads.- See Also:
ImageInputStream
-
init
private void init(int pIndex) throws java.io.IOException- Throws:
java.io.IOException
-
initReader
private void initReader(int pIndex) throws java.io.IOException- Throws:
java.io.IOException
-
initReaderListeners
private void initReaderListeners()
-
init
private void init() throws java.io.IOException- Throws:
java.io.IOException
-
initCatalog
private void initCatalog() throws java.io.IOException- Throws:
java.io.IOException
-
getNumImages
public int getNumImages(boolean allowSearch) throws java.io.IOExceptionDescription copied from class:ImageReaderBaseDefault implementation that always returns1.- Overrides:
getNumImagesin classImageReaderBase- Parameters:
allowSearch- ignored, unless overridden- Returns:
1, unless overridden- Throws:
java.io.IOException- never, unless overridden
-
getWidth
public int getWidth(int pIndex) throws java.io.IOException- Specified by:
getWidthin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getHeight
public int getHeight(int pIndex) throws java.io.IOException- Specified by:
getHeightin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
getImageTypes
public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int pIndex) throws java.io.IOException- Specified by:
getImageTypesin classjavax.imageio.ImageReader- Throws:
java.io.IOException
-
isPresent
public boolean isPresent(java.lang.String pFileName)
-
main
public static void main(java.lang.String[] pArgs) throws java.io.IOException- Throws:
java.io.IOException
-
createWindow
private static javax.swing.JFrame createWindow(java.lang.String pTitle)
-
addImage
private static void addImage(java.awt.Container pParent, javax.imageio.ImageReader pReader, int pImageNo, java.lang.String pName) throws java.io.IOException- Throws:
java.io.IOException
-
-