Class JPEGImageReadParam
getDefaultImageReadParam
methods of the built-in JPEG
ImageReader
.
The sole purpose of these additions is to allow the
specification of tables for use in decoding abbreviated streams.
The built-in JPEG reader will also accept an ordinary
ImageReadParam
, which is sufficient for decoding
non-abbreviated streams.
While tables for abbreviated streams are often obtained by
first reading another abbreviated stream containing only the
tables, in some applications the tables are fixed ahead of time.
This class allows the tables to be specified directly from client
code. If no tables are specified either in the stream or in a
JPEGImageReadParam
, then the stream is presumed to use
the "standard" visually lossless tables. See JPEGQTable
and JPEGHuffmanTable
for more information
on the default tables.
The default JPEGImageReadParam
returned by the
getDefaultReadParam
method of the builtin JPEG reader
contains no tables. Default tables may be obtained from the table
classes JPEGQTable
and
JPEGHuffmanTable
.
If a stream does contain tables, the tables given in a
JPEGImageReadParam
are ignored. Furthermore, if the
first image in a stream does contain tables and subsequent ones do
not, then the tables given in the first image are used for all the
abbreviated images. Once tables have been read from a stream, they
can be overridden only by tables subsequently read from the same
stream. In order to specify new tables, the setInput
method of
the reader must be called to change the stream.
Note that this class does not provide a means for obtaining the tables found in a stream. These may be extracted from a stream by consulting the IIOMetadata object returned by the reader.
For more information about the operation of the built-in JPEG plug-ins, see the JPEG metadata format specification and usage notes.
-
Field Summary
Fields declared in class ImageReadParam
canSetSourceRenderSize, destination, destinationBands, minProgressivePass, numProgressivePasses, sourceRenderSize
Modifier and TypeFieldDescriptionprotected boolean
true
if thisImageReadParam
allows the source rendering dimensions to be set.protected BufferedImage
The current destinationBufferedImage
, ornull
if none has been set.protected int[]
The set of destination bands to be used, as an array ofint
s.protected int
The minimum index of a progressive pass to read from the source.protected int
The maximum number of progressive passes to read from the source.protected Dimension
The desired rendering width and height of the source, ifcanSetSourceRenderSize
istrue
, ornull
.Fields declared in class IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
Modifier and TypeFieldDescriptionprotected IIOParamController
TheIIOParamController
that will be used to provide settings for thisIIOParam
object when theactivateController
method is called.protected IIOParamController
The defaultIIOParamController
that will be used to provide settings for thisIIOParam
object when theactivateController
method is called.protected Point
The offset in the destination where the upper-left decoded pixel should be placed.protected ImageTypeSpecifier
AnImageTypeSpecifier
to be used to generate a destination image when reading, or to set the output color type when writing.protected int[]
An array ofint
s indicating which source bands will be used, ornull
.protected Rectangle
The source region, onnull
if none is set.protected int
The decimation subsampling to be applied in the horizontal direction.protected int
The decimation subsampling to be applied in the vertical direction.protected int
A horizontal offset to be applied to the subsampling grid before subsampling.protected int
A vertical offset to be applied to the subsampling grid before subsampling. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if tables are currently set.Returns a copy of the array of AC Huffman tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.Returns a copy of the array of DC Huffman tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.Returns a copy of the array of quantization tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.void
setDecodeTables
(JPEGQTable[] qTables, JPEGHuffmanTable[] DCHuffmanTables, JPEGHuffmanTable[] ACHuffmanTables) Sets the quantization and Huffman tables to use in decoding abbreviated streams.void
Removes any quantization and Huffman tables that are currently set.Methods declared in class ImageReadParam
canSetSourceRenderSize, getDestination, getDestinationBands, getSourceMaxProgressivePass, getSourceMinProgressivePass, getSourceNumProgressivePasses, getSourceRenderSize, setDestination, setDestinationBands, setSourceProgressivePasses, setSourceRenderSize
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this reader allows the source image to be rendered at an arbitrary size as part of the decoding process, by means of thesetSourceRenderSize
method.Returns theBufferedImage
currently set by thesetDestination
method, ornull
if none is set.int[]
Returns the set of band indices where data will be placed.int
IfgetSourceNumProgressivePasses
is equal toInteger.MAX_VALUE
, returnsInteger.MAX_VALUE
.int
Returns the index of the first progressive pass that will be decoded.int
Returns the number of the progressive passes that will be decoded.Returns the width and height of the source image as it will be rendered during decoding, if they have been set via thesetSourceRenderSize
method.void
setDestination
(BufferedImage destination) Supplies aBufferedImage
to be used as the destination for decoded pixel data.void
setDestinationBands
(int[] destinationBands) Sets the indices of the destination bands where data will be placed.void
setSourceProgressivePasses
(int minPass, int numPasses) Sets the range of progressive passes that will be decoded.void
setSourceRenderSize
(Dimension size) If the image is able to be rendered at an arbitrary size, sets the source width and height to the supplied values.Methods declared in class IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceBands, setSourceRegion, setSourceSubsampling
Modifier and TypeMethodDescriptionboolean
Activates the installedIIOParamController
for thisIIOParam
object and returns the resulting value.Returns whateverIIOParamController
is currently installed.Returns the defaultIIOParamController
, if there is one, regardless of the currently installed controller.Returns the offset in the destination image at which pixels are to be placed.Returns the type of image to be returned by the read, if one was set by a call tosetDestination(ImageTypeSpecifier)
, as anImageTypeSpecifier
.int[]
Returns the set of source bands to be used.Returns the source region to be used.int
Returns the number of source columns to advance for each pixel.int
Returns the number of rows to advance for each pixel.int
Returns the horizontal offset of the subsampling grid.int
Returns the vertical offset of the subsampling grid.boolean
Returnstrue
if there is a controller installed for thisIIOParam
object.void
setController
(IIOParamController controller) Sets theIIOParamController
to be used to provide settings for thisIIOParam
object when theactivateController
method is called, overriding any default controller.void
setDestinationOffset
(Point destinationOffset) Specifies the offset in the destination image at which future decoded pixels are to be placed, when reading, or where a region will be written, when writing.void
setDestinationType
(ImageTypeSpecifier destinationType) Sets the desired image type for the destination image, using anImageTypeSpecifier
.void
setSourceBands
(int[] sourceBands) Sets the indices of the source bands to be used.void
setSourceRegion
(Rectangle sourceRegion) Sets the source region of interest.void
setSourceSubsampling
(int sourceXSubsampling, int sourceYSubsampling, int subsamplingXOffset, int subsamplingYOffset) Specifies a decimation subsampling to apply on I/O.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
JPEGImageReadParam
public JPEGImageReadParam()Constructs aJPEGImageReadParam
.
-
-
Method Details
-
areTablesSet
public boolean areTablesSet()Returnstrue
if tables are currently set.- Returns:
true
if tables are present.
-
setDecodeTables
public void setDecodeTables(JPEGQTable[] qTables, JPEGHuffmanTable[] DCHuffmanTables, JPEGHuffmanTable[] ACHuffmanTables) Sets the quantization and Huffman tables to use in decoding abbreviated streams. There may be a maximum of 4 tables of each type. These tables are ignored once tables are encountered in the stream. All arguments must be non-null
. The two arrays of Huffman tables must have the same number of elements. The table specifiers in the frame and scan headers in the stream are assumed to be equivalent to indices into these arrays. The argument arrays are copied by this method.- Parameters:
qTables
- an array of quantization table objects.DCHuffmanTables
- an array of Huffman table objects.ACHuffmanTables
- an array of Huffman table objects.- Throws:
IllegalArgumentException
- if any of the arguments isnull
, has more than 4 elements, or if the numbers of DC and AC tables differ.- See Also:
-
unsetDecodeTables
public void unsetDecodeTables()Removes any quantization and Huffman tables that are currently set.- See Also:
-
getQTables
Returns a copy of the array of quantization tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.- Returns:
- an array of
JPEGQTable
objects, ornull
. - See Also:
-
getDCHuffmanTables
Returns a copy of the array of DC Huffman tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.- Returns:
- an array of
JPEGHuffmanTable
objects, ornull
. - See Also:
-
getACHuffmanTables
Returns a copy of the array of AC Huffman tables set on the most recent call tosetDecodeTables
, ornull
if tables are not currently set.- Returns:
- an array of
JPEGHuffmanTable
objects, ornull
. - See Also:
-