javax.imageio
public abstract class ImageReader extends Object
Field Summary | |
---|---|
protected Locale[] | availableLocales
All locales available for localization of warning messages, or
null if localization is not supported. |
protected boolean | ignoreMetadata
true if the input source does not require metadata to be read,
false otherwise. |
protected Object | input
An ImageInputStream from which image data is read. |
protected Locale | locale
The current locale used to localize warning messages, or null if
no locale has been set. |
protected int | minIndex
The minimum index at which data can be read. |
protected ImageReaderSpi | originatingProvider
The image reader SPI that instantiated this reader. |
protected List<IIOReadProgressListener> | progressListeners
A list of installed progress listeners. |
protected boolean | seekForwardOnly
true if this reader should only read data further ahead in the
stream than its current location. false if it can read backwards
in the stream. |
protected List<IIOReadUpdateListener> | updateListeners
A list of installed update listeners. |
protected List<IIOReadWarningListener> | warningListeners
A list of installed warning listeners. |
protected List<Locale> | warningLocales
A list of warning locales corresponding with the list of
installed warning listeners. |
Constructor Summary | |
---|---|
protected | ImageReader(ImageReaderSpi originatingProvider)
Construct an image reader.
|
Method Summary | |
---|---|
void | abort()
Request that reading be aborted. |
protected boolean | abortRequested()
Check if the abort flag is set.
|
void | addIIOReadProgressListener(IIOReadProgressListener listener)
Install a read progress listener. |
void | addIIOReadUpdateListener(IIOReadUpdateListener listener)
Install a read update listener. |
void | addIIOReadWarningListener(IIOReadWarningListener listener)
Install a read warning listener. |
boolean | canReadRaster()
Check if this reader can handle raster data. |
protected static void | checkReadParamBandSettings(ImageReadParam param, int numSrcBands, int numDstBands)
Check that the given read parameters have valid source and
destination band settings. |
protected void | clearAbortRequest()
Clear the abort flag. |
protected static void | computeRegions(ImageReadParam param, int srcWidth, int srcHeight, BufferedImage image, Rectangle srcRegion, Rectangle destRegion)
Calcluate the source and destination regions that will be read
from and written to, given image parameters and/or a destination
buffered image. |
void | dispose()
Releases any resources allocated to this object. |
float | getAspectRatio(int imageIndex)
Returns the aspect ratio of this image, the ration of its width
to its height. |
Locale[] | getAvailableLocales()
Retrieve the available locales. |
ImageReadParam | getDefaultReadParam()
Retrieve the default read parameters for this reader's image
format.
|
protected static BufferedImage | getDestination(ImageReadParam param, Iterator<ImageTypeSpecifier> imageTypes, int width, int height)
Return a suitable destination buffered image. |
String | getFormatName()
Retrieve the format of the input source.
|
abstract int | getHeight(int imageIndex)
Get the height of the input image in pixels. |
abstract IIOMetadata | getImageMetadata(int imageIndex)
Get the metadata associated with this image. |
IIOMetadata | getImageMetadata(int imageIndex, String formatName, Set<String> nodeNames)
Get the metadata associated with this image. |
abstract Iterator<ImageTypeSpecifier> | getImageTypes(int imageIndex)
Get an iterator over the collection of image types into which
this reader can decode image data. |
Object | getInput()
Get this reader's image input source. null is returned if the
image source has not been set.
|
Locale | getLocale()
Get this reader's locale. null is returned if the locale has not
been set.
|
int | getMinIndex()
Get the index at which the next image will be read. |
abstract int | getNumImages(boolean allowSearch)
Return the number of images available from the image input
source, not including thumbnails. |
int | getNumThumbnails(int imageIndex)
Get the number of thumbnails associated with an image.
|
ImageReaderSpi | getOriginatingProvider()
Get the ImageReaderSpi that created this reader or null.
|
ImageTypeSpecifier | getRawImageType(int imageIndex)
Get the image type specifier that most closely represents the
internal data representation used by this reader. |
protected static Rectangle | getSourceRegion(ImageReadParam param, int srcWidth, int srcHeight)
Calculate a source region based on the given source image
dimensions and parameters. |
abstract IIOMetadata | getStreamMetadata()
Get the metadata associated with the image being read. |
IIOMetadata | getStreamMetadata(String formatName, Set<String> nodeNames)
Get the metadata associated with the image being read. |
int | getThumbnailHeight(int imageIndex, int thumbnailIndex)
Get the height of a thumbnail image.
|
int | getThumbnailWidth(int imageIndex, int thumbnailIndex)
Get the width of a thumbnail image.
|
int | getTileGridXOffset(int imageIndex)
Get the X coordinate in pixels of the top-left corner of the
first tile in this image.
|
int | getTileGridYOffset(int imageIndex)
Get the Y coordinate in pixels of the top-left corner of the
first tile in this image.
|
int | getTileHeight(int imageIndex)
Get the height of an image tile.
|
int | getTileWidth(int imageIndex)
Get the width of an image tile.
|
abstract int | getWidth(int imageIndex)
Get the width of the input image in pixels. |
boolean | hasThumbnails(int imageIndex)
Check whether or not the given image has thumbnails associated
with it.
|
boolean | isIgnoringMetadata()
Check if this image reader ignores metadata. |
boolean | isImageTiled(int imageIndex)
Check if the given image is sub-divided into equal-sized
non-overlapping pixel rectangles.
|
boolean | isRandomAccessEasy(int imageIndex)
Check if all pixels in this image are readily accessible. |
boolean | isSeekForwardOnly()
Check if this image reader may only seek forward within the input
stream.
|
protected void | processImageComplete()
Notifies all installed read progress listeners that image loading
has completed by calling their imageComplete methods. |
protected void | processImageProgress(float percentageDone)
Notifies all installed read progress listeners that a certain
percentage of the image has been loaded, by calling their
imageProgress methods.
|
protected void | processImageStarted(int imageIndex)
Notifies all installed read progress listeners, by calling their
imageStarted methods, that image loading has started on the given
image.
|
protected void | processImageUpdate(BufferedImage image, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands)
Notifies all installed read update listeners, by calling their
imageUpdate methods, that the set of samples has changed.
|
protected void | processPassComplete(BufferedImage image)
Notifies all installed update progress listeners, by calling
their passComplete methods, that a progressive pass has
completed.
|
protected void | processPassStarted(BufferedImage image, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands)
Notifies all installed read update listeners, by calling their
passStarted methods, that a new pass has begun.
|
protected void | processReadAborted()
Notifies all installed read progress listeners that image loading
has been aborted by calling their readAborted methods. |
protected void | processSequenceComplete()
Notifies all installed read progress listeners, by calling their
sequenceComplete methods, that a sequence of images has completed
loading. |
protected void | processSequenceStarted(int minIndex)
Notifies all installed read progress listeners, by calling their
sequenceStarted methods, a sequence of images has started
loading.
|
protected void | processThumbnailComplete()
Notifies all installed read progress listeners, by calling their
thumbnailComplete methods, that a thumbnail has completed
loading. |
protected void | processThumbnailPassComplete(BufferedImage thumbnail)
Notifies all installed update progress listeners, by calling
their thumbnailPassComplete methods, that a progressive pass has
completed on a thumbnail.
|
protected void | processThumbnailPassStarted(BufferedImage thumbnail, int pass, int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands)
Notifies all installed read update listeners, by calling their
thumbnailPassStarted methods, that a new pass has begun.
|
protected void | processThumbnailProgress(float percentageDone)
Notifies all installed read progress listeners that a certain
percentage of a thumbnail has been loaded, by calling their
thumbnailProgress methods.
|
protected void | processThumbnailStarted(int imageIndex, int thumbnailIndex)
Notifies all installed read progress listeners, by calling their
imageStarted methods, that thumbnail loading has started on the
given thumbnail of the given image.
|
protected void | processThumbnailUpdate(BufferedImage image, int minX, int minY, int width, int height, int periodX, int periodY, int[] bands)
Notifies all installed read update listeners, by calling their
thumbnailUpdate methods, that the set of samples has changed.
|
protected void | processWarningOccurred(String warning)
Notifies all installed warning listeners, by calling their
warningOccurred methods, that a warning message has been raised.
|
protected void | processWarningOccurred(String baseName, String keyword)
Notify all installed warning listeners, by calling their
warningOccurred methods, that a warning message has been raised.
|
abstract BufferedImage | read(int imageIndex, ImageReadParam param)
Read the given frame into a buffered image using the given read
parameters. |
BufferedImage | read(int imageIndex)
Read the given frame all at once, using default image read
parameters, and return a buffered image.
|
IIOImage | readAll(int imageIndex, ImageReadParam param)
Read the given frame all at once, using the given image read
parameters, and return an IIOImage. |
Iterator<IIOImage> | readAll(Iterator<? extends ImageReadParam> params)
Read all image frames all at once, using the given image read
parameters iterator, and return an iterator over a collection of
IIOImages. |
RenderedImage | readAsRenderedImage(int imageIndex, ImageReadParam param)
Read a rendered image. |
boolean | readerSupportsThumbnails()
Check if this reader supports reading thumbnails.
|
Raster | readRaster(int imageIndex, ImageReadParam param)
Read raw raster data. |
BufferedImage | readThumbnail(int imageIndex, int thumbnailIndex)
Read a thumbnail.
|
BufferedImage | readTile(int imageIndex, int tileX, int tileY)
Read the given tile into a buffered image. |
Raster | readTileRaster(int imageIndex, int tileX, int tileY)
Read the given tile into a raster containing the raw image data.
|
void | removeAllIIOReadProgressListeners()
Uninstall all read progress listeners. |
void | removeAllIIOReadUpdateListeners()
Uninstall all read update listeners. |
void | removeAllIIOReadWarningListeners()
Uninstall all read warning listeners. |
void | removeIIOReadProgressListener(IIOReadProgressListener listener)
Uninstall the given read progress listener.
|
void | removeIIOReadUpdateListener(IIOReadUpdateListener listener)
Uninstall the given read update listener.
|
void | removeIIOReadWarningListener(IIOReadWarningListener listener)
Uninstall the given read warning listener.
|
void | reset()
Reset this reader's internal state. |
void | setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata)
Set the input source to the given object, specify whether this
reader should be allowed to read input from the data stream more
than once, and specify whether this reader should ignore metadata
in the input stream. |
void | setInput(Object in, boolean seekForwardOnly)
Set the input source to the given object and specify whether this
reader should be allowed to read input from the data stream more
than once. |
void | setInput(Object input)
Set the input source to the given object. |
void | setLocale(Locale locale)
Set the current locale or use the default locale.
|
Parameters: originatingProvider the provider that is constructing this image reader, or null
Returns: true if the current read operation should be aborted, false otherwise
Parameters: listener a read progress listener or null
Parameters: listener a read update listener
Parameters: listener a read warning listener
Returns: true if this reader supports raster data, false if not
Parameters: param the image parameters to check numSrcBands the number of input source bands numDstBands the number of ouput destination bands
Throws: IllegalArgumentException if either the given source or destination band indices are invalid
Parameters: image read parameters, or null srcWidth the width of the source image srcHeight the height of the source image image the destination image, or null srcRegion a rectangle whose values will be set to the clipped source region destRegion a rectangle whose values will be set to the clipped destination region
Throws: IllegalArgumentException if either srcRegion or destRegion is null IllegalArgumentException if either of the calculated regions is empty
Parameters: imageIndex the frame index
Returns: the image's aspect ratio
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Returns: an array of locales or null
Returns: image reading parameters
Parameters: param image read parameters from which a destination image or image type is retrieved, or null imageTypes a collection of legal image types width the width of the source image height the height of the source image
Returns: a suitable destination buffered image
Throws: IIOException if param.getDestinationType() does not return an image type in imageTypes IllegalArgumentException if imageTypes is null or empty, or if a non-ImageTypeSpecifier object is retrieved from imageTypes IllegalArgumentException if the resulting destination region is empty IllegalArgumentException if the product of width and height is greater than Integer.MAX_VALUE
Returns: the input source format name
Throws: IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the height of the input image
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: a metadata object, or null
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index formatName the format of metadata requested nodeNames a set of Strings specifiying node names to be retrieved
Returns: a metadata object, or null
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IllegalArgumentException if formatName is null IllegalArgumentException if nodeNames is null IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: an iterator over a collection of image type specifiers
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Returns: an image input source object, or null
Returns: this reader's locale, or null
Returns: the current frame index
Parameters: allowSearch true if all images should be available at once, false otherwise
Returns: -1 if allowSearch is false and the total number of images is currently unknown, or the number of images
Throws: IllegalStateException if input has not been set, or if seekForwardOnly is true IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the number of thumbnails associated with this image
Returns: an ImageReaderSpi, or null
Parameters: imageIndex the frame index
Returns: an image type specifier
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: param image parameters, or null srcWidth the width of the source image srcHeight the height of the source image
Returns: a clipped rectangle
Returns: metadata associated with the image being read, or null
Throws: IOException if a read error occurs
Parameters: formatName the format of metadata requested nodeNames a set of Strings specifiying node names to be retrieved
Returns: metadata associated with the image being read, or null
Throws: IllegalArgumentException if formatName is null IllegalArgumentException if nodeNames is null IOException if a read error occurs
Parameters: imageIndex the frame index thumbnailIndex the thumbnail index
Returns: the height of the thumbnail image
Throws: UnsupportedOperationException if this reader does not support thumbnails IllegalStateException if input is null IndexOutOfBoundsException if either index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index thumbnailIndex the thumbnail index
Returns: the width of the thumbnail image
Throws: UnsupportedOperationException if this reader does not support thumbnails IllegalStateException if input is null IndexOutOfBoundsException if either index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the X coordinate of this image's first tile
Throws: IllegalStateException if input is needed but the input source is not set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the Y coordinate of this image's first tile
Throws: IllegalStateException if input is needed but the input source is not set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the tile height for the given image
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: the tile width for the given image
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the image's index
Returns: the width of the input image
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Returns: true if the given image has thumbnails, false otherwise
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Returns: true if metadata is being ignored, false otherwise
Returns: true if the given image is tiled, false otherwise
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index
Returns: true if random pixel access is fast, false otherwise
Throws: IllegalStateException if input is null and it is needed to determine the return value IndexOutOfBoundsException if the frame index is out-of-bounds but the frame data must be accessed to determine the return value IOException if a read error occurs
Returns: true if this reader may only seek forward, false otherwise
Parameters: percentageDone the percentage of image data that has been loaded
Parameters: imageIndex the frame index of the image that has started loading
Parameters: image the buffered image that is being updated minX the X coordinate of the top-left pixel in this pass minY the Y coordinate of the top-left pixel in this pass width the total width of the rectangle covered by this pass, including skipped pixels height the total height of the rectangle covered by this pass, including skipped pixels periodX the horizontal sample interval periodY the vertical sample interval bands the affected bands in the destination
Parameters: image the image that has being updated
Parameters: image the buffered image that is being updated pass the current pass number minPass the pass at which decoding will begin maxPass the pass at which decoding will end minX the X coordinate of the top-left pixel in this pass minY the Y coordinate of the top-left pixel in this pass width the total width of the rectangle covered by this pass, including skipped pixels height the total height of the rectangle covered by this pass, including skipped pixels periodX the horizontal sample interval periodY the vertical sample interval bands the affected bands in the destination
Parameters: minIndex the index of the first image in the sequence
Parameters: thumbnail the thumbnail that has being updated
Parameters: thumbnail the thumbnail that is being updated pass the current pass number minPass the pass at which decoding will begin maxPass the pass at which decoding will end minX the X coordinate of the top-left pixel in this pass minY the Y coordinate of the top-left pixel in this pass width the total width of the rectangle covered by this pass, including skipped pixels height the total height of the rectangle covered by this pass, including skipped pixels periodX the horizontal sample interval periodY the vertical sample interval bands the affected bands in the destination
Parameters: percentageDone the percentage of thumbnail data that has been loaded
Parameters: imageIndex the frame index of the image one of who's thumbnails has started loading thumbnailIndex the index of the thumbnail that has started loading
Parameters: image the buffered image that is being updated minX the X coordinate of the top-left pixel in this pass minY the Y coordinate of the top-left pixel in this pass width the total width of the rectangle covered by this pass, including skipped pixels height the total height of the rectangle covered by this pass, including skipped pixels periodX the horizontal sample interval periodY the vertical sample interval bands the affected bands in the destination
Parameters: warning the warning message
Throws: IllegalArgumentException if warning is null
Parameters: baseName the basename of the resource from which to retrieve the warning message keyword the keyword used to retrieve the warning from the resource bundle
Throws: IllegalArgumentException if either baseName or keyword is null IllegalArgumentException if no resource bundle is found using baseName IllegalArgumentException if the given keyword produces no results from the resource bundle IllegalArgumentException if the retrieved object is not a String
Parameters: imageIndex the index of the frame to read param the image read parameters to use when reading
Returns: a buffered image
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: the index of the image frame to read
Returns: a buffered image
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: the index of the image frame to read the image read parameters
Returns: an IIOImage
Throws: IllegalStateException if input has not been set IndexOutOfBoundsException if the frame index is out-of-bounds IllegalArgumentException if param.getSourceBands() and param.getDestinationBands() are incompatible IllegalArgumentException if either the source or destination image regions are empty IOException if a read error occurs
Parameters: an iterator over the image read parameters
Returns: an IIOImage
Throws: IllegalStateException if input has not been set IllegalArgumentException if a non-ImageReadParam is found in params IllegalArgumentException if param.getSourceBands() and param.getDestinationBands() are incompatible IllegalArgumentException if either the source or destination image regions are empty IOException if a read error occurs
Parameters: the index of the image frame to read the image read parameters
Returns: a rendered image
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IllegalArgumentException if param.getSourceBands() and param.getDestinationBands() are incompatible IllegalArgumentException if either the source or destination image regions are empty IOException if a read error occurs
Returns: true if this reader supports reading thumbnails, false otherwise
Parameters: imageIndex the frame index param the image read parameters
Returns: a raster containing the read image data
Throws: UnsupportedOperationException if this reader doesn't support rasters IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index thumbnailIndex the thumbnail index
Returns: a buffered image of the thumbnail
Throws: UnsupportedOperationException if this reader doesn't support thumbnails IllegalStateException if input is null IndexOutOfBoundsException if either the frame index or the thumbnail index is out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index tileX the horizontal tile coordinate tileY the vertical tile coordinate
Returns: the contents of the tile as a buffered image
Throws: IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IllegalArgumentException if the tile coordinates are out-of-bounds IOException if a read error occurs
Parameters: imageIndex the frame index tileX the horizontal tile coordinate tileY the vertical tile coordinate
Returns: the contents of the tile as a raster
Throws: UnsupportedOperationException if rasters are not supported IllegalStateException if input is null IndexOutOfBoundsException if the frame index is out-of-bounds IllegalArgumentException if the tile coordinates are out-of-bounds IOException if a read error occurs
Parameters: listener the listener to remove
Parameters: listener the listener to remove
Parameters: listener the listener to remove
Parameters: input the input source object seekForwardOnly true if this reader should be allowed to read input from the data stream more than once, false otherwise ignoreMetadata true if this reader should ignore metadata associated with the input source, false otherwise
Throws: IllegalArgumentException if input is not a valid input source for this reader and is not an ImageInputStream
Parameters: input the input source object seekForwardOnly true if this reader should be allowed to read input from the data stream more than once, false otherwise
Throws: IllegalArgumentException if input is not a valid input source for this reader and is not an ImageInputStream
Parameters: input the input source object
Throws: IllegalArgumentException if input is not a valid input source for this reader and is not an ImageInputStream
Parameters: locale the locale to set, or null