An abstract superclass for parsing and decoding of images. This class must be subclassed by classes that read in images in the context of the Java Image I/O framework.

ImageReader objects are normally instantiated by the service provider interface (SPI) class for the specific format. Service provider classes (e.g., instances of ImageReaderSpi) are registered with the IIORegistry, which uses them for format recognition and presentation of available format readers and writers.

When an input source is set (using the setInput method), it may be marked as "seek forward only". This setting means that images contained within the input source will only be read in order, possibly allowing the reader to avoid caching portions of the input containing data associated with images that have been read previously.

Requests that any current read operation be aborted. The contents of the image following the abort will be undefined.

Readers should call clearAbortRequest at the beginning of each read operation, and poll the value of abortRequested regularly during the read.

Adds an IIOReadProgressListener to the list of registered progress listeners. If listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOReadProgressListener to be registered.
Adds an IIOReadUpdateListener to the list of registered update listeners. If listener is null, no exception will be thrown and no action will be taken. The listener will receive notification of pixel updates as images and thumbnails are decoded, including the starts and ends of progressive passes.

If no update listeners are present, the reader may choose to perform fewer updates to the pixels of the destination images and/or thumbnails, which may result in more efficient decoding.

For example, in progressive JPEG decoding each pass contains updates to a set of coefficients, which would have to be transformed into pixel values and converted to an RGB color space for each pass if listeners are present. If no listeners are present, the coefficients may simply be accumulated and the final results transformed and color converted one time only.

The final results of decoding will be the same whether or not intermediate updates are performed. Thus if only the final image is desired it may be perferable not to register any IIOReadUpdateListeners. In general, progressive updating is most effective when fetching images over a network connection that is very slow compared to local CPU processing; over a fast connection, progressive updates may actually slow down the presentation of the image.

Parameters
listeneran IIOReadUpdateListener to be registered.
Adds an IIOReadWarningListener to the list of registered warning listeners. If listener is null, no exception will be thrown and no action will be taken. Messages sent to the given listener will be localized, if possible, to match the current Locale. If no Locale has been set, warning messages may be localized as the reader sees fit.
Parameters
listeneran IIOReadWarningListener to be registered.
Returns true if this plug-in supports reading just a Raster of pixel data. If this method returns false, calls to readRaster or readTileRaster will throw an UnsupportedOperationException.

The default implementation returns false.

Return
true if this plug-in supports reading raw Rasters.
Allows any resources held by this object to be released. The result of calling any other method (other than finalize) subsequent to a call to this method is undefined.

It is important for applications to call this method when they know they will no longer be using this ImageReader. Otherwise, the reader may continue to hold on to resources indefinitely.

The default implementation of this method in the superclass does nothing. Subclass implementations should ensure that all resources, especially native resources, are released.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Returns the aspect ratio of the given image (that is, its width divided by its height) as a float. For images that are inherently resizable, this method provides a way to determine the appropriate width given a deired height, or vice versa. For non-resizable images, the true width and height are used.

The default implementation simply returns (float)getWidth(imageIndex)/getHeight(imageIndex).

Parameters
imageIndexthe index of the image to be queried.
Return
a float indicating the aspect ratio of the given image.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns an array of Locales that may be used to localize warning listeners and compression settings. A return value of null indicates that localization is not supported.

The default implementation returns a clone of the availableLocales instance variable if it is non-null, or else returns null.

Return
an array of Locales that may be used as arguments to setLocale, or null.
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns a default ImageReadParam object appropriate for this format. All subclasses should define a set of default values for all parameters and return them with this call. This method may be called before the input source is set.

The default implementation constructs and returns a new ImageReadParam object that does not allow source scaling (i.e., it returns new ImageReadParam().

Return
an ImageReadParam object which may be used to control the decoding process using a set of default settings.
Returns a String identifying the format of the input source.

The default implementation returns originatingProvider.getFormatNames()[0]. Implementations that may not have an originating service provider, or which desire a different naming policy should override this method.

Return
the format name, as a String.
Throws
IOExceptionif an error occurs reading the information from the input source.
Returns the height in pixels of the given image within the input source.

If the image can be rendered to a user-specified size, then this method returns the default height.

Parameters
imageIndexthe index of the image to be queried.
Return
the height of the image, as an int.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs reading the height information from the input source.
Returns an IIOMetadata object containing metadata associated with the given image, or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.
Parameters
imageIndexthe index of the image whose metadata is to be retrieved.
Return
an IIOMetadata object, or null.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns an IIOMetadata object representing the metadata associated with the given image, or null if the reader does not support reading metadata or none is available.

The resuting metadata object is only responsible for returning documents in the format named by formatName. Within any documents that are returned, only nodes whose names are members of nodeNames are required to be returned. In this way, the amount of metadata processing done by the reader may be kept to a minimum, based on what information is actually needed.

If formatName is not the name of a supported metadata format, null may be returned.

In all cases, it is legal to return a more capable metadata object than strictly necessary. The format name and node names are merely hints that may be used to reduce the reader's workload.

The default implementation simply returns the result of calling getImageMetadata(imageIndex), after checking that the format name is supported. If it is not, null is returned.

Parameters
imageIndexthe index of the image whose metadata is to be retrieved.
formatNamea metadata format name that may be used to retrieve a document from the returned IIOMetadata object.
nodeNamesa Set containing the names of nodes that may be contained in a retrieved document.
Return
an IIOMetadata object, or null.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IllegalArgumentExceptionif formatName is null.
IllegalArgumentExceptionif nodeNames is null.
IOExceptionif an error occurs during reading.
Returns an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss. At least one legal image type will be returned.

The first element of the iterator should be the most "natural" type for decoding the image with as little loss as possible. For example, for a JPEG image the first entry should be an RGB image, even though the image data is stored internally in a YCbCr color space.

Parameters
imageIndexthe index of the image to be retrieved.
Return
an Iterator containing at least one ImageTypeSpecifier representing suggested image types for decoding the current given image.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs reading the format information from the input source.
Returns the ImageInputStream or other Object previously set as the input source. If the input source has not been set, null is returned.
Return
the Object that will be used for future decoding, or null.
Returns the currently set Locale, or null if none has been set.
Return
the current Locale, or null.
See Also
Returns the lowest valid index for reading an image, thumbnail, or image metadata. If seekForwardOnly() is false, this value will typically remain 0, indicating that random access is possible. Otherwise, it will contain the value of the most recently accessed index, and increase in a monotonic fashion.
Return
the minimum legal index for reading.
Returns the number of images, not including thumbnails, available from the current input source.

Note that some image formats (such as animated GIF) do not specify how many images are present in the stream. Thus determining the number of images will require the entire stream to be scanned and may require memory for buffering. If images are to be processed in order, it may be more efficient to simply call read with increasing indices until an IndexOutOfBoundsException is thrown to indicate that no more images are available. The allowSearch parameter may be set to false to indicate that an exhaustive search is not desired; the return value will be -1 to indicate that a search is necessary. If the input has been specified with seekForwardOnly set to true, this method throws an IllegalStateException if allowSearch is set to true.

Parameters
allowSearchif true, the true number of images will be returned even if a search is required. If false, the reader may return -1 without performing the search.
Return
the number of images, as an int, or -1 if allowSearch is false and a search would be required.
Throws
IllegalStateExceptionif the input source has not been set, or if the input has been specified with seekForwardOnly set to true.
IOExceptionif an error occurs reading the information from the input source.
See Also
Returns the number of thumbnail preview images associated with the given image. If the format does not support thumbnails, (readerSupportsThumbnails returns false), 0 will be returned regardless of whether an input source has been set or whether imageIndex is in bounds.

The default implementation returns 0 without checking its argument.

Parameters
imageIndexthe index of the image being queried.
Return
the number of thumbnails associated with the given image.
Throws
IllegalStateExceptionif the reader supports thumbnails but the input source has not been set.
IndexOutOfBoundsExceptionif the reader supports thumbnails but imageIndex is out of bounds.
IOExceptionif an error occurs during reading.
Returns the ImageReaderSpi that was passed in on the constructor. Note that this value may be null.
Return
an ImageReaderSpi, or null.
Returns an ImageTypeSpecifier indicating the SampleModel and ColorModel which most closely represents the "raw" internal format of the image. For example, for a JPEG image the raw type might have a YCbCr color space even though the image would conventionally be transformed into an RGB color space prior to display. The returned value should also be included in the list of values returned by getImageTypes.

The default implementation simply returns the first entry from the list provided by getImageType.

Parameters
imageIndexthe index of the image to be queried.
Return
an ImageTypeSpecifier.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs reading the format information from the input source.
Returns an IIOMetadata object representing the metadata associated with the input source as a whole (i.e., not associated with any particular image), or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.
Return
an IIOMetadata object, or null.
Throws
IOExceptionif an error occurs during reading.
Returns an IIOMetadata object representing the metadata associated with the input source as a whole (i.e., not associated with any particular image). If no such data exists, null is returned.

The resuting metadata object is only responsible for returning documents in the format named by formatName. Within any documents that are returned, only nodes whose names are members of nodeNames are required to be returned. In this way, the amount of metadata processing done by the reader may be kept to a minimum, based on what information is actually needed.

If formatName is not the name of a supported metadata format, null is returned.

In all cases, it is legal to return a more capable metadata object than strictly necessary. The format name and node names are merely hints that may be used to reduce the reader's workload.

The default implementation simply returns the result of calling getStreamMetadata(), after checking that the format name is supported. If it is not, null is returned.

Parameters
formatNamea metadata format name that may be used to retrieve a document from the returned IIOMetadata object.
nodeNamesa Set containing the names of nodes that may be contained in a retrieved document.
Return
an IIOMetadata object, or null.
Throws
IllegalArgumentExceptionif formatName is null.
IllegalArgumentExceptionif nodeNames is null.
IOExceptionif an error occurs during reading.
Returns the height of the thumbnail preview image indexed by thumbnailIndex, associated with the image indexed by ImageIndex.

If the reader does not support thumbnails, (readerSupportsThumbnails returns false), an UnsupportedOperationException will be thrown.

The default implementation simply returns readThumbnail(imageindex, thumbnailIndex).getHeight(). Subclasses should therefore override this method if possible in order to avoid forcing the thumbnail to be read.

Parameters
imageIndexthe index of the image to be retrieved.
thumbnailIndexthe index of the thumbnail to be retrieved.
Return
the height of the desired thumbnail as an int.
Throws
UnsupportedOperationExceptionif thumbnails are not supported.
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif either of the supplied indices are out of bounds.
IOExceptionif an error occurs during reading.
Returns the width of the thumbnail preview image indexed by thumbnailIndex, associated with the image indexed by ImageIndex.

If the reader does not support thumbnails, (readerSupportsThumbnails returns false), an UnsupportedOperationException will be thrown.

The default implementation simply returns readThumbnail(imageindex, thumbnailIndex).getWidth(). Subclasses should therefore override this method if possible in order to avoid forcing the thumbnail to be read.

Parameters
imageIndexthe index of the image to be retrieved.
thumbnailIndexthe index of the thumbnail to be retrieved.
Return
the width of the desired thumbnail as an int.
Throws
UnsupportedOperationExceptionif thumbnails are not supported.
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif either of the supplied indices are out of bounds.
IOExceptionif an error occurs during reading.
Returns the X coordinate of the upper-left corner of tile (0, 0) in the given image.

A reader for which the tile grid X offset always has the same value (usually 0), may return the value without accessing any image data. In such cases, it is not necessary to throw an exception even if no input source has been set or the image index is out of bounds.

The default implementation simply returns 0, which is correct for non-tiled images and tiled images in most formats. Readers that support tiling with non-(0, 0) offsets should override this method.

Parameters
imageIndexthe index of the image to be queried.
Return
the X offset of the tile grid.
Throws
IllegalStateExceptionif an input source is required to determine the return value, but none has been set.
IndexOutOfBoundsExceptionif an image must be accessed to determine the return value, but the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns the Y coordinate of the upper-left corner of tile (0, 0) in the given image.

A reader for which the tile grid Y offset always has the same value (usually 0), may return the value without accessing any image data. In such cases, it is not necessary to throw an exception even if no input source has been set or the image index is out of bounds.

The default implementation simply returns 0, which is correct for non-tiled images and tiled images in most formats. Readers that support tiling with non-(0, 0) offsets should override this method.

Parameters
imageIndexthe index of the image to be queried.
Return
the Y offset of the tile grid.
Throws
IllegalStateExceptionif an input source is required to determine the return value, but none has been set.
IndexOutOfBoundsExceptionif an image must be accessed to determine the return value, but the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns the height of a tile in the given image.

The default implementation simply returns getHeight(imageIndex), which is correct for non-tiled images. Readers that support tiling should override this method.

Parameters
imageIndexthe index of the image to be queried.
Return
the height of a tile.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns the width of a tile in the given image.

The default implementation simply returns getWidth(imageIndex), which is correct for non-tiled images. Readers that support tiling should override this method.

Parameters
imageIndexthe index of the image to be queried.
Return
the width of a tile.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns the width in pixels of the given image within the input source.

If the image can be rendered to a user-specified size, then this method returns the default width.

Parameters
imageIndexthe index of the image to be queried.
Return
the width of the image, as an int.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs reading the width information from the input source.
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
Returns true if the given image has thumbnail preview images associated with it. If the format does not support thumbnails (readerSupportsThumbnails returns false), false will be returned regardless of whether an input source has been set or whether imageIndex is in bounds.

The default implementation returns true if getNumThumbnails returns a value greater than 0.

Parameters
imageIndexthe index of the image being queried.
Return
true if the given image has thumbnails.
Throws
IllegalStateExceptionif the reader supports thumbnails but the input source has not been set.
IndexOutOfBoundsExceptionif the reader supports thumbnails but imageIndex is out of bounds.
IOExceptionif an error occurs during reading.
Returns true if the current input source has been marked as allowing metadata to be ignored by passing true as the ignoreMetadata argument to the setInput method.
Return
true if the metadata may be ignored.
See Also
Returns true if the image is organized into tiles, that is, equal-sized non-overlapping rectangles.

A reader plug-in may choose whether or not to expose tiling that is present in the image as it is stored. It may even choose to advertise tiling when none is explicitly present. In general, tiling should only be advertised if there is some advantage (in speed or space) to accessing individual tiles. Regardless of whether the reader advertises tiling, it must be capable of reading an arbitrary rectangular region specified in an ImageReadParam.

A reader for which all images are guaranteed to be tiled, or are guaranteed not to be tiled, may return true or false respectively without accessing any image data. In such cases, it is not necessary to throw an exception even if no input source has been set or the image index is out of bounds.

The default implementation just returns false.

Parameters
imageIndexthe index of the image to be queried.
Return
true if the image is tiled.
Throws
IllegalStateExceptionif an input source is required to determine the return value, but none has been set.
IndexOutOfBoundsExceptionif an image must be accessed to determine the return value, but the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns true if the storage format of the given image places no inherent impediment on random access to pixels. For most compressed formats, such as JPEG, this method should return false, as a large section of the image in addition to the region of interest may need to be decoded.

This is merely a hint for programs that wish to be efficient; all readers must be able to read arbitrary regions as specified in an ImageReadParam.

Note that formats that return false from this method may nonetheless allow tiling (e.g. Restart Markers in JPEG), and random access will likely be reasonably efficient on tiles. See isImageTiled .

A reader for which all images are guaranteed to support easy random access, or are guaranteed not to support easy random access, may return true or false respectively without accessing any image data. In such cases, it is not necessary to throw an exception even if no input source has been set or the image index is out of bounds.

The default implementation returns false.

Parameters
imageIndexthe index of the image to be queried.
Return
true if reading a region of interest of the given image is likely to be efficient.
Throws
IllegalStateExceptionif an input source is required to determine the return value, but none has been set.
IndexOutOfBoundsExceptionif an image must be accessed to determine the return value, but the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns true if the current input source has been marked as seek forward only by passing true as the seekForwardOnly argument to the setInput method.
Return
true if the input source is seek forward only.
See Also
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a default ImageReadParam. This is a convenience method that calls read(imageIndex, null).

The image returned will be formatted according to the first ImageTypeSpecifier returned from getImageTypes.

Any registered IIOReadProgressListener objects will be notified by calling their imageStarted method, followed by calls to their imageProgress method as the read progresses. Finally their imageComplete method will be called. IIOReadUpdateListener objects may be updated at other times during the read as pixels are decoded. Finally, IIOReadWarningListener objects will receive notification of any non-fatal warnings that occur during decoding.

Parameters
imageIndexthe index of the image to be retrieved.
Return
the desired portion of the image as a BufferedImage.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a supplied ImageReadParam.

The actual BufferedImage returned will be chosen using the algorithm defined by the getDestination method.

Any registered IIOReadProgressListener objects will be notified by calling their imageStarted method, followed by calls to their imageProgress method as the read progresses. Finally their imageComplete method will be called. IIOReadUpdateListener objects may be updated at other times during the read as pixels are decoded. Finally, IIOReadWarningListener objects will receive notification of any non-fatal warnings that occur during decoding.

The set of source bands to be read and destination bands to be written is determined by calling getSourceBands and getDestinationBands on the supplied ImageReadParam. If the lengths of the arrays returned by these methods differ, the set of source bands contains an index larger that the largest available source index, or the set of destination bands contains an index larger than the largest legal destination index, an IllegalArgumentException is thrown.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

Parameters
imageIndexthe index of the image to be retrieved.
paraman ImageReadParam used to control the reading process, or null.
Return
the desired portion of the image as a BufferedImage.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IllegalArgumentExceptionif the set of source and destination bands specified by param.getSourceBands and param.getDestinationBands differ in length or include indices that are out of bounds.
IllegalArgumentExceptionif the resulting image would have a width or height less than 1.
IOExceptionif an error occurs during reading.
Reads the image indexed by imageIndex and returns an IIOImage containing the image, thumbnails, and associated image metadata, using a supplied ImageReadParam.

The actual BufferedImage referenced by the returned IIOImage will be chosen using the algorithm defined by the getDestination method.

Any registered IIOReadProgressListener objects will be notified by calling their imageStarted method, followed by calls to their imageProgress method as the read progresses. Finally their imageComplete method will be called. IIOReadUpdateListener objects may be updated at other times during the read as pixels are decoded. Finally, IIOReadWarningListener objects will receive notification of any non-fatal warnings that occur during decoding.

The set of source bands to be read and destination bands to be written is determined by calling getSourceBands and getDestinationBands on the supplied ImageReadParam. If the lengths of the arrays returned by these methods differ, the set of source bands contains an index larger that the largest available source index, or the set of destination bands contains an index larger than the largest legal destination index, an IllegalArgumentException is thrown.

Thumbnails will be returned in their entirety regardless of the region settings.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), those values will be ignored.

Parameters
imageIndexthe index of the image to be retrieved.
paraman ImageReadParam used to control the reading process, or null.
Return
an IIOImage containing the desired portion of the image, a set of thumbnails, and associated image metadata.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IllegalArgumentExceptionif the set of source and destination bands specified by param.getSourceBands and param.getDestinationBands differ in length or include indices that are out of bounds.
IllegalArgumentExceptionif the resulting image would have a width or height less than 1.
IOExceptionif an error occurs during reading.
Returns an Iterator containing all the images, thumbnails, and metadata, starting at the index given by getMinIndex, from the input source in the form of IIOImage objects. An Iterator containing ImageReadParam objects is supplied; one element is consumed for each image read from the input source until no more images are available. If the read param Iterator runs out of elements, but there are still more images available from the input source, default read params are used for the remaining images.

If params is null, a default read param will be used for all images.

The actual BufferedImage referenced by the returned IIOImage will be chosen using the algorithm defined by the getDestination method.

Any registered IIOReadProgressListener objects will be notified by calling their sequenceStarted method once. Then, for each image decoded, there will be a call to imageStarted, followed by calls to imageProgress as the read progresses, and finally to imageComplete. The sequenceComplete method will be called after the last image has been decoded. IIOReadUpdateListener objects may be updated at other times during the read as pixels are decoded. Finally, IIOReadWarningListener objects will receive notification of any non-fatal warnings that occur during decoding.

The set of source bands to be read and destination bands to be written is determined by calling getSourceBands and getDestinationBands on the supplied ImageReadParam. If the lengths of the arrays returned by these methods differ, the set of source bands contains an index larger that the largest available source index, or the set of destination bands contains an index larger than the largest legal destination index, an IllegalArgumentException is thrown.

Thumbnails will be returned in their entirety regardless of the region settings.

If any of the supplied ImageReadParams contain optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

Parameters
paramsan Iterator containing ImageReadParam objects.
Return
an Iterator representing the contents of the input source as IIOImages.
Throws
IllegalStateExceptionif the input source has not been set.
IllegalArgumentExceptionif any non-null element of params is not an ImageReadParam.
IllegalArgumentExceptionif the set of source and destination bands specified by param.getSourceBands and param.getDestinationBands differ in length or include indices that are out of bounds.
IllegalArgumentExceptionif a resulting image would have a width or height less than 1.
IOExceptionif an error occurs during reading.
Returns a RenderedImage object that contains the contents of the image indexed by imageIndex. By default, the returned image is simply the BufferedImage returned by read(imageIndex, param).

The semantics of this method may differ from those of the other read methods in several ways. First, any destination image and/or image type set in the ImageReadParam may be ignored. Second, the usual listener calls are not guaranteed to be made, or to be meaningful if they are. This is because the returned image may not be fully populated with pixel data at the time it is returned, or indeed at any time.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

The default implementation just calls .

Parameters
imageIndexthe index of the image to be retrieved.
paraman ImageReadParam used to control the reading process, or null.
Return
a RenderedImage object providing a view of the image.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IllegalArgumentExceptionif the set of source and destination bands specified by param.getSourceBands and param.getDestinationBands differ in length or include indices that are out of bounds.
IllegalArgumentExceptionif the resulting image would have a width or height less than 1.
IOExceptionif an error occurs during reading.
Returns true if the image format understood by this reader supports thumbnail preview images associated with it. The default implementation returns false.

If this method returns false, hasThumbnails and getNumThumbnails will return false and 0, respectively, and readThumbnail will throw an UnsupportedOperationException, regardless of their arguments.

A reader that does not support thumbnails need not implement any of the thumbnail-related methods.

Return
true if thumbnails are supported.
Returns a new Raster object containing the raw pixel data from the image stream, without any color conversion applied. The application must determine how to interpret the pixel data by other means. Any destination or image-type parameters in the supplied ImageReadParam object are ignored, but all other parameters are used exactly as in the read method, except that any destination offset is used as a logical rather than a physical offset. The size of the returned Raster will always be that of the source region clipped to the actual image. Logical offsets in the stream itself are ignored.

This method allows formats that normally apply a color conversion, such as JPEG, and formats that do not normally have an associated colorspace, such as remote sensing or medical imaging data, to provide access to raw pixel data.

Any registered readUpdateListeners are ignored, as there is no BufferedImage, but all other listeners are called exactly as they are for the read method.

If returns false, this method throws an UnsupportedOperationException.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

The default implementation throws an UnsupportedOperationException.

Parameters
imageIndexthe index of the image to be read.
paraman ImageReadParam used to control the reading process, or null.
Return
the desired portion of the image as a Raster.
Throws
UnsupportedOperationExceptionif this plug-in does not support reading raw Rasters.
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif the supplied index is out of bounds.
IOExceptionif an error occurs during reading.
Returns the thumbnail preview image indexed by thumbnailIndex, associated with the image indexed by ImageIndex as a BufferedImage.

Any registered IIOReadProgressListener objects will be notified by calling their thumbnailStarted, thumbnailProgress, and thumbnailComplete methods.

If the reader does not support thumbnails, (readerSupportsThumbnails returns false), an UnsupportedOperationException will be thrown regardless of whether an input source has been set or whether the indices are in bounds.

The default implementation throws an UnsupportedOperationException.

Parameters
imageIndexthe index of the image to be retrieved.
thumbnailIndexthe index of the thumbnail to be retrieved.
Return
the desired thumbnail as a BufferedImage.
Throws
UnsupportedOperationExceptionif thumbnails are not supported.
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif either of the supplied indices are out of bounds.
IOExceptionif an error occurs during reading.
Reads the tile indicated by the tileX and tileY arguments, returning it as a BufferedImage. If the arguments are out of range, an IllegalArgumentException is thrown. If the image is not tiled, the values 0, 0 will return the entire image; any other values will cause an IllegalArgumentException to be thrown.

This method is merely a convenience equivalent to calling read(int, ImageReadParam) with a read param specifiying a source region having offsets of tileX*getTileWidth(imageIndex), tileY*getTileHeight(imageIndex) and width and height of getTileWidth(imageIndex), getTileHeight(imageIndex); and subsampling factors of 1 and offsets of 0. To subsample a tile, call read with a read param specifying this region and different subsampling parameters.

The default implementation returns the entire image if tileX and tileY are 0, or throws an IllegalArgumentException otherwise.

Parameters
imageIndexthe index of the image to be retrieved.
tileXthe column index (starting with 0) of the tile to be retrieved.
tileYthe row index (starting with 0) of the tile to be retrieved.
Return
the tile as a BufferedImage.
Throws
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif imageIndex is out of bounds.
IllegalArgumentExceptionif the tile indices are out of bounds.
IOExceptionif an error occurs during reading.
Returns a new Raster object containing the raw pixel data from the tile, without any color conversion applied. The application must determine how to interpret the pixel data by other means.

If returns false, this method throws an UnsupportedOperationException.

The default implementation checks if reading Rasters is supported, and if so calls if tileX and tileY are 0, or throws an IllegalArgumentException otherwise.

Parameters
imageIndexthe index of the image to be retrieved.
tileXthe column index (starting with 0) of the tile to be retrieved.
tileYthe row index (starting with 0) of the tile to be retrieved.
Return
the tile as a Raster.
Throws
UnsupportedOperationExceptionif this plug-in does not support reading raw Rasters.
IllegalArgumentExceptionif the tile indices are out of bounds.
IllegalStateExceptionif the input source has not been set.
IndexOutOfBoundsExceptionif imageIndex is out of bounds.
IOExceptionif an error occurs during reading.
Removes all currently registered IIOReadProgressListener objects.

The default implementation sets the progressListeners instance variable to null.

Removes all currently registered IIOReadUpdateListener objects.

The default implementation sets the updateListeners instance variable to null.

Removes all currently registered IIOReadWarningListener objects.

The default implementation sets the warningListeners and warningLocales instance variables to null.

Removes an IIOReadProgressListener from the list of registered progress listeners. If the listener was not previously registered, or if listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOReadProgressListener to be unregistered.
Removes an IIOReadUpdateListener from the list of registered update listeners. If the listener was not previously registered, or if listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOReadUpdateListener to be unregistered.
Removes an IIOReadWarningListener from the list of registered error listeners. If the listener was not previously registered, or if listener is null, no exception will be thrown and no action will be taken.
Parameters
listeneran IIOReadWarningListener to be unregistered.
Restores the ImageReader to its initial state.

The default implementation calls setInput(null, false), setLocale(null), removeAllIIOReadUpdateListeners(), removeAllIIOReadWarningListeners(), removeAllIIOReadProgressListeners(), and clearAbortRequest.

Sets the input source to use to the given ImageInputStream or other Object. The input source must be set before any of the query or read methods are used. If input is null, any currently set input source will be removed. In any case, the value of minIndex will be initialized to 0.

This method is equivalent to setInput(input, false, false).

Parameters
inputthe ImageInputStream or other Object to use for future decoding.
Throws
IllegalArgumentExceptionif input is not an instance of one of the classes returned by the originating service provider's getInputTypes method, or is not an ImageInputStream.
See Also
Sets the input source to use to the given ImageInputStream or other Object. The input source must be set before any of the query or read methods are used. If input is null, any currently set input source will be removed. In any case, the value of minIndex will be initialized to 0.

The seekForwardOnly parameter controls whether the value returned by getMinIndex will be increased as each image (or thumbnail, or image metadata) is read. If seekForwardOnly is true, then a call to read(index) will throw an IndexOutOfBoundsException if index < this.minIndex; otherwise, the value of minIndex will be set to index. If seekForwardOnly is false, the value of minIndex will remain 0 regardless of any read operations.

This method is equivalent to setInput(input, seekForwardOnly, false).

Parameters
inputthe ImageInputStream or other Object to use for future decoding.
seekForwardOnlyif true, images and metadata may only be read in ascending order from this input source.
Throws
IllegalArgumentExceptionif input is not an instance of one of the classes returned by the originating service provider's getInputTypes method, or is not an ImageInputStream.
See Also
Sets the input source to use to the given ImageInputStream or other Object. The input source must be set before any of the query or read methods are used. If input is null, any currently set input source will be removed. In any case, the value of minIndex will be initialized to 0.

The seekForwardOnly parameter controls whether the value returned by getMinIndex will be increased as each image (or thumbnail, or image metadata) is read. If seekForwardOnly is true, then a call to read(index) will throw an IndexOutOfBoundsException if index < this.minIndex; otherwise, the value of minIndex will be set to index. If seekForwardOnly is false, the value of minIndex will remain 0 regardless of any read operations.

The ignoreMetadata parameter, if set to true, allows the reader to disregard any metadata encountered during the read. Subsequent calls to the getStreamMetadata and getImageMetadata methods may return null, and an IIOImage returned from readAll may return null from their getMetadata method. Setting this parameter may allow the reader to work more efficiently. The reader may choose to disregard this setting and return metadata normally.

Subclasses should take care to remove any cached information based on the previous stream, such as header information or partially decoded image data.

Use of a general Object other than an ImageInputStream is intended for readers that interact directly with a capture device or imaging protocol. The set of legal classes is advertised by the reader's service provider's getInputTypes method; most readers will return a single-element array containing only ImageInputStream.class to indicate that they accept only an ImageInputStream.

The default implementation checks the input argument against the list returned by originatingProvider.getInputTypes() and fails if the argument is not an instance of one of the classes in the list. If the originating provider is set to null, the input is accepted only if it is an ImageInputStream.

Parameters
inputthe ImageInputStream or other Object to use for future decoding.
seekForwardOnlyif true, images and metadata may only be read in ascending order from this input source.
ignoreMetadataif true, metadata may be ignored during reads.
Throws
IllegalArgumentExceptionif input is not an instance of one of the classes returned by the originating service provider's getInputTypes method, or is not an ImageInputStream.
Sets the current Locale of this ImageReader to the given value. A value of null removes any previous setting, and indicates that the reader should localize as it sees fit.
Parameters
localethe desired Locale, or null.
Throws
IllegalArgumentExceptionif locale is non-null but is not one of the values returned by getAvailableLocales.
See Also
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Return
a string representation of the object.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.