Module java.desktop
Package javax.imageio

Class ImageReader

java.lang.Object
javax.imageio.ImageReader

public abstract class ImageReader extends Object
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.

See Also:
ImageWriter, IIORegistry, ImageReaderSpi
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Locale[]
    An array of Locales which may be used to localize warning messages, or null if localization is not supported.
    protected boolean
    true if the current input source has been marked as allowing metadata to be ignored by setInput.
    protected Object
    The ImageInputStream or other Object by setInput and retrieved by getInput.
    protected Locale
    The current Locale to be used for localization, or null if none has been set.
    protected int
    The smallest valid index for reading, initially 0.
    protected ImageReaderSpi
    The ImageReaderSpi that instantiated this object, or null if its identity is not known or none exists.
    A List of currently registered IIOReadProgressListeners, initialized by default to null, which is synonymous with an empty List.
    protected boolean
    true if the current input source has been marked as allowing only forward seeking by setInput.
    A List of currently registered IIOReadUpdateListeners, initialized by default to null, which is synonymous with an empty List.
    A List of currently registered IIOReadWarningListeners, initialized by default to null, which is synonymous with an empty List.
    protected List<Locale>
    A List of the Locales associated with each currently registered IIOReadWarningListener, initialized by default to null, which is synonymous with an empty List.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ImageReader​(ImageReaderSpi originatingProvider)
    Constructs an ImageReader and sets its originatingProvider field to the supplied value.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Requests that any current read operation be aborted.
    protected boolean
    Returns true if a request to abort the current read operation has been made since the reader was instantiated or clearAbortRequest was called.
    void
    Adds an IIOReadProgressListener to the list of registered progress listeners.
    void
    Adds an IIOReadUpdateListener to the list of registered update listeners.
    void
    Adds an IIOReadWarningListener to the list of registered warning listeners.
    boolean
    Returns true if this plug-in supports reading just a Raster of pixel data.
    protected static void
    checkReadParamBandSettings​(ImageReadParam param, int numSrcBands, int numDstBands)
    A utility method that may be used by readers to test the validity of the source and destination band settings of an ImageReadParam.
    protected void
    Clears any previous abort request.
    protected static void
    computeRegions​(ImageReadParam param, int srcWidth, int srcHeight, BufferedImage image, Rectangle srcRegion, Rectangle destRegion)
    Computes the source region of interest and the destination region of interest, taking the width and height of the source image, an optional destination image, and an optional ImageReadParam into account.
    void
    Allows any resources held by this object to be released.
    float
    getAspectRatio​(int imageIndex)
    Returns the aspect ratio of the given image (that is, its width divided by its height) as a float.
    Returns an array of Locales that may be used to localize warning listeners and compression settings.
    Returns a default ImageReadParam object appropriate for this format.
    protected static BufferedImage
    getDestination​(ImageReadParam param, Iterator<ImageTypeSpecifier> imageTypes, int width, int height)
    Returns the BufferedImage to which decoded pixel data should be written.
    Returns a String identifying the format of the input source.
    abstract int