Class ImageReaderBase
- Direct Known Subclasses:
BMPImageReader
,DCXImageReader
,DDSImageReader
,DIBImageReader
,EXIFUtilities.DisplayHelper
,HDRImageReader
,ICNSImageReader
,IFFImageReader
,JPEGImageReader
,PCXImageReader
,PICTImageReader
,PNMImageReader
,PNTGImageReader
,PSDImageReader
,SGIImageReader
,SVGImageReader
,TGAImageReader
,ThumbsDBImageReader
,TIFFImageReader
,WebPImageReader
,WMFImageReader
,XWDImageReader
- Version:
- $Id: ImageReaderBase.java,v 1.0 Sep 20, 2007 5:28:37 PM haraldk Exp$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ImageInputStream
For convenience.private static final Point
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ImageReaderBase
(ImageReaderSpi provider) Constructs anImageReader
and sets itsoriginatingProvider
field to the supplied value. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Makes sure input is set.protected void
checkBounds
(int index) Convenience method to make sure image index is within bounds.void
dispose()
protected static BufferedImage
fakeAOI
(BufferedImage pImage, ImageReadParam pParam) Utility method for getting the area of interest (AOI) of an image.protected static Image
fakeSubsampling
(Image pImage, ImageReadParam pParam) Utility method for getting the subsampled image.static BufferedImage
getDestination
(ImageReadParam param, Iterator<ImageTypeSpecifier> types, int width, int height) Returns theBufferedImage
to which decoded pixel data should be written.getImageMetadata
(int imageIndex) Default implementation that always returnsnull
.int
getNumImages
(boolean allowSearch) Default implementation that always returns1
.Default implementation that always returnsnull
.protected static boolean
hasExplicitDestination
(ImageReadParam pParam) Tests if param has explicit destination.static void
void
reset()
protected abstract void
Resets all member variables.void
OverridessetInput
, to allow easy access to the input, in case it is anImageInputStream
.protected static void
showIt
(BufferedImage pImage, String pTitle) Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getFormatName, getHeight, getImageMetadata, getImageTypes, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
-
Field Details
-
ORIGIN
-
imageInput
For convenience. Only set if the input is anImageInputStream
.- See Also:
-
-
Constructor Details
-
ImageReaderBase
Constructs anImageReader
and sets itsoriginatingProvider
field to the supplied value.Subclasses that make use of extensions should provide a constructor with signature
(ImageReaderSpi, Object)
in order to retrieve the extension object. If the extension object is unsuitable, anIllegalArgumentException
should be thrown.- Parameters:
provider
- theImageReaderSpi
that is invoking this constructor, ornull
.
-
-
Method Details
-
setInput
OverridessetInput
, to allow easy access to the input, in case it is anImageInputStream
.- Overrides:
setInput
in classImageReader
- Parameters:
input
- theImageInputStream
or otherObject
to 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.- Throws:
IllegalArgumentException
- ifinput
is not an instance of one of the classes returned by the originating service provider'sgetInputTypes
method, or is not anImageInputStream
.- See Also:
-
dispose
public void dispose()- Overrides:
dispose
in classImageReader
-
reset
public void reset()- Overrides:
reset
in classImageReader
-
resetMembers
protected abstract void resetMembers()Resets all member variables. This method is by default invoked from: -
getImageMetadata
Default implementation that always returnsnull
.- Specified by:
getImageMetadata
in classImageReader
- Parameters:
imageIndex
- ignored, unless overridden- Returns:
null
, unless overridden- Throws:
IOException
- never, unless overridden.
-
getStreamMetadata
Default implementation that always returnsnull
.- Specified by:
getStreamMetadata
in classImageReader
- Returns:
null
, unless overridden- Throws:
IOException
- never, unless overridden.
-
getNumImages
Default implementation that always returns1
.- Specified by:
getNumImages
in classImageReader
- Parameters:
allowSearch
- ignored, unless overridden- Returns:
1
, unless overridden- Throws:
IOException
- never, unless overridden
-
checkBounds
Convenience method to make sure image index is within bounds.- Parameters:
index
- the image index- Throws:
IOException
- if an error occurs during readingIndexOutOfBoundsException
- if notminIndex <= index < numImages
-
assertInput
protected void assertInput()Makes sure input is set.- Throws:
IllegalStateException
- ifgetInput() == null
.
-
getDestination
public static BufferedImage getDestination(ImageReadParam param, Iterator<ImageTypeSpecifier> types, int width, int height) throws IIOException Returns theBufferedImage
to which decoded pixel data should be written.As
ImageReader.getDestination(javax.imageio.ImageReadParam, java.util.Iterator<javax.imageio.ImageTypeSpecifier>, int, int)
but tests if the explicit destination image (if set) is valid according to theImageTypeSpecifier
s given intypes
.- Parameters:
param
- anImageReadParam
to be used to get the destination image or image type, ornull
.types
- anIterator
ofImageTypeSpecifier
s indicating the legal image types, with the default first.width
- the true width of the image or tile begin decoded.height
- the true width of the image or tile being decoded.- Returns:
- the
BufferedImage
to which decoded pixel data should be written. - Throws:
IIOException
- if theImageTypeSpecifier
orBufferedImage
specified byparam
does not match any of the legal ones fromtypes
.IllegalArgumentException
- iftypes
isnull
or empty, or if an object not of typeImageTypeSpecifier
is retrieved from it. Or, if the resulting image would have a width or height less than 1, or if the product ofwidth
andheight
of the resulting image is greater thanInteger.MAX_VALUE
.
-
fakeAOI
Utility method for getting the area of interest (AOI) of an image. The AOI is defined by theIIOParam.setSourceRegion(java.awt.Rectangle)
method.Note: If it is possible for the reader to read the AOI directly, such a method should be used instead, for efficiency.
- Parameters:
pImage
- the image to get AOI frompParam
- the param optionally specifying the AOI- Returns:
- a
BufferedImage
containing the area of interest (source region), or the original image, if no source region was set, orpParam
wasnull
-
fakeSubsampling
Utility method for getting the subsampled image. The subsampling is defined by theIIOParam.setSourceSubsampling(int, int, int, int)
method.NOTE: This method does not take the subsampling offsets into consideration.
Note: If it is possible for the reader to subsample directly, such a method should be used instead, for efficiency.
- Parameters:
pImage
- the image to subsamplepParam
- the param optionally specifying subsampling- Returns:
- an
Image
containing the subsampled image, or the original image, if no subsampling was specified, orpParam
wasnull
-
hasExplicitDestination
Tests if param has explicit destination.- Parameters:
pParam
- the image read parameter, ornull
- Returns:
- true if
pParam
is non-null
and either itsgetDestination
,getDestinationType
returns a non-null
value, orgetDestinationOffset
returns aPoint
that is not the upper left corner(0, 0)
.
-
main
- Throws:
IOException
-
showIt
-