Class ImageDecoderImpl
java.lang.Object
org.apache.xmlgraphics.image.codec.util.ImageDecoderImpl
- All Implemented Interfaces:
ImageDecoder
- Direct Known Subclasses:
PNGImageDecoder
,TIFFImageDecoder
A partial implementation of the
ImageDecoder
interface
useful for subclassing.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SeekableStream
TheSeekableStream
associcted with thisImageEncoder
.protected ImageDecodeParam
TheImageDecodeParam
object associated with thisImageEncoder
. -
Constructor Summary
ConstructorsConstructorDescriptionImageDecoderImpl
(InputStream input, ImageDecodeParam param) Constructs anImageDecoderImpl
with a givenInputStream
andImageDecodeParam
instance.ImageDecoderImpl
(SeekableStream input, ImageDecodeParam param) Constructs anImageDecoderImpl
with a givenSeekableStream
andImageDecodeParam
instance. -
Method Summary
Modifier and TypeMethodDescriptionReturns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.decodeAsRaster
(int page) Returns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.abstract RenderedImage
decodeAsRenderedImage
(int page) Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.Returns theSeekableStream
associated with thisImageDecoder
.int
Returns the number of pages present in the current stream.getParam()
Returns the current parameters as an instance of theImageDecodeParam
interface.void
setParam
(ImageDecodeParam param) Sets the current parameters to an instance of theImageDecodeParam
interface.
-
Field Details
-
input
TheSeekableStream
associcted with thisImageEncoder
. -
param
TheImageDecodeParam
object associated with thisImageEncoder
.
-
-
Constructor Details
-
ImageDecoderImpl
Constructs anImageDecoderImpl
with a givenSeekableStream
andImageDecodeParam
instance. -
ImageDecoderImpl
Constructs anImageDecoderImpl
with a givenInputStream
andImageDecodeParam
instance. Theinput
parameter will be used to construct aForwardSeekableStream
; if the ability to seek backwards is required, the caller should construct an instance ofSeekableStream
and make use of the other contructor.
-
-
Method Details
-
getParam
Returns the current parameters as an instance of theImageDecodeParam
interface. Concrete implementations of this interface will return corresponding concrete implementations of theImageDecodeParam
interface. For example, aJPEGImageDecoder
will return an instance ofJPEGDecodeParam
.- Specified by:
getParam
in interfaceImageDecoder
-
setParam
Sets the current parameters to an instance of theImageDecodeParam
interface. Concrete implementations ofImageDecoder
may throw aRuntimeException
if theparam
argument is not an instance of the appropriate subclass or subinterface. For example, aJPEGImageDecoder
will expectparam
to be an instance ofJPEGDecodeParam
.- Specified by:
setParam
in interfaceImageDecoder
-
getInputStream
Returns theSeekableStream
associated with thisImageDecoder
.- Specified by:
getInputStream
in interfaceImageDecoder
-
getNumPages
Returns the number of pages present in the current stream. By default, the return value is 1. Subclasses that deal with multi-page formats should override this method.- Specified by:
getNumPages
in interfaceImageDecoder
- Throws:
IOException
-
decodeAsRaster
Returns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
. Only the first page of a multi-page image is decoded.- Specified by:
decodeAsRaster
in interfaceImageDecoder
- Throws:
IOException
-
decodeAsRaster
Returns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
. The given page of a multi-page image is decoded. If the page does not exist, an IOException will be thrown. Page numbering begins at zero.- Specified by:
decodeAsRaster
in interfaceImageDecoder
- Parameters:
page
- The page to be decoded.- Throws:
IOException
-
decodeAsRenderedImage
Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
. Only the first page of a multi-page image is decoded.- Specified by:
decodeAsRenderedImage
in interfaceImageDecoder
- Throws:
IOException
-
decodeAsRenderedImage
Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
. The given page of a multi-page image is decoded. If the page does not exist, an IOException will be thrown. Page numbering begins at zero.- Specified by:
decodeAsRenderedImage
in interfaceImageDecoder
- Parameters:
page
- The page to be decoded.- Throws:
IOException
-