Class JPEGImageReadParam
public class JPEGImageReadParam extends ImageReadParam
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 Type | Field | Description |
|---|---|---|
protected boolean |
canSetSourceRenderSize |
true if this ImageReadParam allows the source rendering dimensions to be set. |
protected BufferedImage |
destination |
The current destination BufferedImage, or null if none has been set. |
protected int[] |
destinationBands |
The set of destination bands to be used, as an array of ints. |
protected int |
minProgressivePass |
The minimum index of a progressive pass to read from the source. |
protected int |
numProgressivePasses |
The maximum number of progressive passes to read from the source. |
protected Dimension |
sourceRenderSize |
The desired rendering width and height of the source, if canSetSourceRenderSize is true, or null. |
Fields declared in class IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset | Modifier and Type | Field | Description |
|---|---|---|
protected IIOParamController |
controller |
The IIOParamController that will be used to provide settings for this IIOParam object when the activateController method is called. |
protected IIOParamController |
defaultController |
The default IIOParamController that will be used to provide settings for this IIOParam object when the activateController method is called. |
protected Point |
destinationOffset |
The offset in the destination where the upper-left decoded pixel should be placed. |
protected ImageTypeSpecifier |
destinationType |
An ImageTypeSpecifier to be used to generate a destination image when reading, or to set the output color type when writing. |
protected int[] |
sourceBands |
An array of ints indicating which source bands will be used, or null. |
protected Rectangle |
sourceRegion |
The source region, on null if none is set. |
protected int |
sourceXSubsampling |
The decimation subsampling to be applied in the horizontal direction. |
protected int |
sourceYSubsampling |
The decimation subsampling to be applied in the vertical direction. |
protected int |
subsamplingXOffset |
A horizontal offset to be applied to the subsampling grid before subsampling. |
protected int |
subsamplingYOffset |
A vertical offset to be applied to the subsampling grid before subsampling. |
Constructor Summary
| Constructor | Description |
|---|---|
JPEGImageReadParam() |
Constructs a JPEGImageReadParam. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
areTablesSet() |
Returns true if tables are currently set. |
JPEGHuffmanTable[] |
getACHuffmanTables() |
Returns a copy of the array of AC Huffman tables set on the most recent call to setDecodeTables, or null if tables are not currently set. |
JPEGHuffmanTable[] |
getDCHuffmanTables() |
Returns a copy of the array of DC Huffman tables set on the most recent call to setDecodeTables, or null if tables are not currently set. |
JPEGQTable[] |
getQTables() |
Returns a copy of the array of quantization tables set on the most recent call to setDecodeTables, or null if tables are not currently set. |
void |
setDecodeTables |
Sets the quantization and Huffman tables to use in decoding abbreviated streams. |
void |
unsetDecodeTables() |
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 Type | Method | Description |
|---|---|---|
boolean |
canSetSourceRenderSize() |
Returns true if this reader allows the source image to be rendered at an arbitrary size as part of the decoding process, by means of the setSourceRenderSize method. |
BufferedImage |
getDestination() |
Returns the BufferedImage currently set by the setDestination method, or null if none is set. |
int[] |
getDestinationBands() |
Returns the set of band indices where data will be placed. |
int |
getSourceMaxProgressivePass() |
If getSourceNumProgressivePasses is equal to Integer.MAX_VALUE, returns Integer.MAX_VALUE. |
int |
getSourceMinProgressivePass() |
Returns the index of the first progressive pass that will be decoded. |
int |
getSourceNumProgressivePasses() |
Returns the number of the progressive passes that will be decoded. |
Dimension |
getSourceRenderSize() |
Returns the width and height of the source image as it will be rendered during decoding, if they have been set via the setSourceRenderSize method. |
void |
setDestination |
Supplies a BufferedImage to be used as the destination for decoded pixel data. |
void |
setDestinationBands |
Sets the indices of the destination bands where data will be placed. |
void |
setSourceProgressivePasses |
Sets the range of progressive passes that will be decoded. |
void |
setSourceRenderSize |
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 Type | Method | Description |
|---|---|---|
boolean |
activateController() |
Activates the installed IIOParamController for this IIOParam object and returns the resulting value. |
IIOParamController |
getController() |
Returns whatever IIOParamController is currently installed. |
IIOParamController |
getDefaultController() |
Returns the default IIOParamController, if there is one, regardless of the currently installed controller. |
Point |
getDestinationOffset() |
Returns the offset in the destination image at which pixels are to be placed. |
ImageTypeSpecifier |
getDestinationType() |
Returns the type of image to be returned by the read, if one was set by a call to setDestination(ImageTypeSpecifier), as an ImageTypeSpecifier. |
int[] |
getSourceBands() |
Returns the set of source bands to be used. |
Rectangle |
getSourceRegion() |
Returns the source region to be used. |
int |
getSourceXSubsampling() |
Returns the number of source columns to advance for each pixel. |
int |
getSourceYSubsampling() |
Returns the number of rows to advance for each pixel. |
int |
getSubsamplingXOffset() |
Returns the horizontal offset of the subsampling grid. |
int |
getSubsamplingYOffset() |
Returns the vertical offset of the subsampling grid. |
boolean |
hasController() |
Returns true if there is a controller installed for this IIOParam object. |
void |
setController |
Sets the IIOParamController to be used to provide settings for this IIOParam object when the activateController method is called, overriding any default controller. |
void |
setDestinationOffset |
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 |
Sets the desired image type for the destination image, using an ImageTypeSpecifier. |
void |
setSourceBands |
Sets the indices of the source bands to be used. |
void |
setSourceRegion |
Sets the source region of interest. |
void |
setSourceSubsampling |
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 Type | Method | Description |
|---|---|---|
protected Object |
clone() |
Creates and returns a copy of this object. |
boolean |
equals |
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 this Object. |
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 |
notifyAll() |
Wakes up all threads that are waiting on this object's monitor. |
String |
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 |
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 |
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()
JPEGImageReadParam.Method Details
areTablesSet
public boolean areTablesSet()
true if tables are currently set.- Returns:
-
trueif tables are present.
setDecodeTables
public void setDecodeTables(JPEGQTable[] qTables, JPEGHuffmanTable[] DCHuffmanTables, JPEGHuffmanTable[] ACHuffmanTables)
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()
- See Also:
getQTables
public JPEGQTable[] getQTables()
setDecodeTables, or null if tables are not currently set.- Returns:
- an array of
JPEGQTableobjects, ornull. - See Also:
getDCHuffmanTables
public JPEGHuffmanTable[] getDCHuffmanTables()
setDecodeTables, or null if tables are not currently set.- Returns:
- an array of
JPEGHuffmanTableobjects, ornull. - See Also:
getACHuffmanTables
public JPEGHuffmanTable[] getACHuffmanTables()
setDecodeTables, or null if tables are not currently set.- Returns:
- an array of
JPEGHuffmanTableobjects, ornull. - See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.