java.lang.Object
javax.imageio.ImageReader
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
FieldsModifier and TypeFieldDescriptionprotected Locale[]
An array ofLocale
s which may be used to localize warning messages, ornull
if localization is not supported.protected boolean
true
if the current input source has been marked as allowing metadata to be ignored bysetInput
.protected Object
TheImageInputStream
or otherObject
bysetInput
and retrieved bygetInput
.protected Locale
The currentLocale
to be used for localization, ornull
if none has been set.protected int
The smallest valid index for reading, initially 0.protected ImageReaderSpi
TheImageReaderSpi
that instantiated this object, ornull
if its identity is not known or none exists.protected List<IIOReadProgressListener>
AList
of currently registeredIIOReadProgressListener
s, initialized by default tonull
, which is synonymous with an emptyList
.protected boolean
true
if the current input source has been marked as allowing only forward seeking bysetInput
.protected List<IIOReadUpdateListener>
AList
of currently registeredIIOReadUpdateListener
s, initialized by default tonull
, which is synonymous with an emptyList
.protected List<IIOReadWarningListener>
AList
of currently registeredIIOReadWarningListener
s, initialized by default tonull
, which is synonymous with an emptyList
.AList
of theLocale
s associated with each currently registeredIIOReadWarningListener
, initialized by default tonull
, which is synonymous with an emptyList
. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ImageReader(ImageReaderSpi originatingProvider)
Constructs anImageReader
and sets itsoriginatingProvider
field to the supplied value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Requests that any current read operation be aborted.protected boolean
Returnstrue
if a request to abort the current read operation has been made since the reader was instantiated orclearAbortRequest
was called.void
Adds anIIOReadProgressListener
to the list of registered progress listeners.void
addIIOReadUpdateListener(IIOReadUpdateListener listener)
Adds anIIOReadUpdateListener
to the list of registered update listeners.void
addIIOReadWarningListener(IIOReadWarningListener listener)
Adds anIIOReadWarningListener
to the list of registered warning listeners.boolean
Returnstrue
if this plug-in supports reading just aRaster
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 anImageReadParam
.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 optionalImageReadParam
into account.void
dispose()
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 afloat
.Locale[]
Returns an array ofLocale
s that may be used to localize warning listeners and compression settings.Returns a defaultImageReadParam
object appropriate for this format.protected static BufferedImage
getDestination(ImageReadParam param, Iterator<ImageTypeSpecifier> imageTypes, int width, int height)
Returns theBufferedImage
to which decoded pixel data should be written.Returns aString
identifying the format of the input source.abstract int