Class ImageDecoderImpl
- java.lang.Object
-
- org.apache.batik.ext.awt.image.codec.util.ImageDecoderImpl
-
- All Implemented Interfaces:
ImageDecoder
- Direct Known Subclasses:
PNGImageDecoder
public abstract class ImageDecoderImpl extends java.lang.Object implements ImageDecoder
A partial implementation of theImageDecoder
interface useful for subclassing.- Version:
- $Id: ImageDecoderImpl.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description protected SeekableStream
input
TheSeekableStream
associcted with thisImageEncoder
.protected ImageDecodeParam
param
TheImageDecodeParam
object associated with thisImageEncoder
.
-
Constructor Summary
Constructors Constructor Description ImageDecoderImpl(java.io.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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.awt.image.Raster
decodeAsRaster()
Returns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.java.awt.image.Raster
decodeAsRaster(int page)
Returns aRaster
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.java.awt.image.RenderedImage
decodeAsRenderedImage()
Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.abstract java.awt.image.RenderedImage
decodeAsRenderedImage(int page)
Returns aRenderedImage
that contains the decoded contents of theSeekableStream
associated with thisImageDecoder
.SeekableStream
getInputStream()
Returns theSeekableStream
associated with thisImageDecoder
.int
getNumPages()
Returns the number of pages present in the current stream.ImageDecodeParam
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 Detail
-
input
protected SeekableStream input
TheSeekableStream
associcted with thisImageEncoder
.
-
param
protected ImageDecodeParam param
TheImageDecodeParam
object associated with thisImageEncoder
.
-
-
Constructor Detail
-
ImageDecoderImpl
public ImageDecoderImpl(SeekableStream input, ImageDecodeParam param)
Constructs anImageDecoderImpl
with a givenSeekableStream
andImageDecodeParam
instance.
-
ImageDecoderImpl
public ImageDecoderImpl(java.io.InputStream input, ImageDecodeParam param)
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 Detail
-
getParam
public ImageDecodeParam 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
public void setParam(ImageDecodeParam param)
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
public SeekableStream getInputStream()
Returns theSeekableStream
associated with thisImageDecoder
.- Specified by:
getInputStream
in interfaceImageDecoder
-
getNumPages
public int getNumPages() throws java.io.IOException
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:
java.io.IOException
-
decodeAsRaster
public java.awt.image.Raster decodeAsRaster() throws java.io.IOException
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:
java.io.IOException
-
decodeAsRaster
public java.awt.image.Raster decodeAsRaster(int page) throws java.io.IOException
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:
java.io.IOException
-
decodeAsRenderedImage
public java.awt.image.RenderedImage decodeAsRenderedImage() throws java.io.IOException
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:
java.io.IOException
-
decodeAsRenderedImage
public abstract java.awt.image.RenderedImage decodeAsRenderedImage(int page) throws java.io.IOException
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:
java.io.IOException
-
-