Class JPEGImageWriteParam
getDefaultImageWriteParam methods of the built-in JPEG
ImageWriter.
The principal purpose of these additions is to allow the
specification of tables to use in encoding abbreviated streams.
The built-in JPEG writer will also accept an ordinary
ImageWriteParam, in which case the writer will
construct the necessary tables internally.
In either case, the quality setting in an ImageWriteParam
has the same meaning as for the underlying library: 1.00 means a
quantization table of all 1's, 0.75 means the "standard", visually
lossless quantization table, and 0.00 means aquantization table of
all 255's.
While tables for abbreviated streams are often specified by first writing an 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.
Normally, the tables are specified in the
IIOMetadata objects passed in to the writer, and any
tables included in these objects are written to the stream.
If no tables are specified in the metadata, then an abbreviated
stream is written. If no tables are included in the metadata and
no tables are specified in a JPEGImageWriteParam, then
an abbreviated stream is encoded using the "standard" visually
lossless tables. This class is necessary for specifying tables
when an abbreviated stream must be written without writing any tables
to a stream first. In order to use this class, the metadata object
passed into the writer must contain no tables, and no stream metadata
must be provided. See JPEGQTable and
JPEGHuffmanTable for more
information on the default tables.
The default JPEGImageWriteParam returned by the
getDefaultWriteParam method of the writer contains no
tables. Default tables are included in the default
IIOMetadata objects returned by the writer.
If the metadata does contain tables, the tables given in a
JPEGImageWriteParam are ignored. Furthermore, once a
set of tables has been written, only tables in the metadata can
override them for subsequent writes, whether to the same stream or
a different one. In order to specify new tables using this class,
the reset
method of the writer must be called.
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 ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, compressionMode, compressionQuality, compressionType, compressionTypes, locale, MODE_COPY_FROM_METADATA, MODE_DEFAULT, MODE_DISABLED, MODE_EXPLICIT, preferredTileSizes, progressiveMode, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, tilingMode, tilingSetModifier and TypeFieldDescriptionprotected booleanAbooleanthat istrueif thisImageWriteParamallows tiling grid offset parameters to be set.protected booleanAbooleanthat istrueif this writer can write images using compression.protected booleanAbooleanthat istrueif thisImageWriteParamallows images to be written as a progressive sequence of increasing quality passes.protected booleanAbooleanthat istrueif thisImageWriteParamallows tile width and tile height parameters to be set.protected intThe mode controlling compression settings, which must be set to one of the fourMODE_*values.protected floatAfloatcontaining the current compression quality setting.protected StringAStringcontaining the name of the current compression type, ornullif none is set.protected String[]An array ofStrings containing the names of the available compression types.protected LocaleALocaleto be used to localize compression type names and quality descriptions, ornullto use a defaultLocale.static final intA constant value that may be passed into methods such assetTilingMode,setProgressiveMode, orsetCompressionModeto enable that feature for future writes.static final intA constant value that may be passed into methods such assetTilingMode,setProgressiveMode, andsetCompressionModeto enable that feature for future writes.static final intA constant value that may be passed into methods such assetTilingMode,setProgressiveMode, andsetCompressionModeto disable a feature for future writes.static final intA constant value that may be passed into methods such assetTilingModeorsetCompressionModeto enable a feature for future writes.protected Dimension[]An array of preferred tile size range pairs.protected intThe mode controlling progressive encoding, which must be set to one of the fourMODE_*values, exceptMODE_EXPLICIT.protected intThe amount by which the tile grid origin should be offset horizontally from the image origin if tiling has been set, or 0 otherwise.protected intThe amount by which the tile grid origin should be offset vertically from the image origin if tiling has been set, or 0 otherwise.protected intThe height of each tile if tiling has been set, or 0 otherwise.protected intThe width of each tile if tiling has been set, or 0 otherwise.protected intThe mode controlling tiling settings, which Must be set to one of the fourMODE_*values.protected booleanAbooleanthat istrueif tiling parameters have been specified.Fields declared in class IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffsetModifier and TypeFieldDescriptionprotected IIOParamControllerTheIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called.protected IIOParamControllerThe defaultIIOParamControllerthat will be used to provide settings for thisIIOParamobject when theactivateControllermethod is called.protected PointThe offset in the destination where the upper-left decoded pixel should be placed.protected ImageTypeSpecifierAnImageTypeSpecifierto be used to generate a destination image when reading, or to set the output color type when writing.protected int[]An array ofints indicating which source bands will be used, ornull.protected RectangleThe source region, onnullif none is set.protected intThe decimation subsampling to be applied in the horizontal direction.protected intThe decimation subsampling to be applied in the vertical direction.protected intA horizontal offset to be applied to the subsampling grid before subsampling.protected intA vertical offset to be applied to the subsampling grid before subsampling. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif tables are currently set.Returns a copy of the array of AC Huffman tables set on the most recent call tosetEncodeTables, ornullif tables are not currently set.Returns a copy of the array of DC Huffman tables set on the most recent call tosetEncodeTables, ornullif tables are not currently set.booleanReturns the value passed into the most recent call tosetOptimizeHuffmanTables, orfalseifsetOptimizeHuffmanTableshas never been called.Returns a copy of the array of quantization tables set on the most recent call tosetEncodeTables, ornullif tables are not currently set.booleanReturnsfalsesince the JPEG plug-in only supports lossy compression.voidsetEncodeTables(JPEGQTable[] qTables, JPEGHuffmanTable[] DCHuffmanTables, JPEGHuffmanTable[] ACHuffmanTables) Sets the quantization and Huffman tables to use in encoding abbreviated streams.voidsetOptimizeHuffmanTables(boolean optimize) Tells the writer to generate optimized Huffman tables for the image as part of the writing process.voidRemoves any previous compression quality setting.voidRemoves any quantization and Huffman tables that are currently set.Methods declared in class ImageWriteParam
canOffsetTiles, canWriteCompressed, canWriteProgressive, canWriteTiles, getBitRate, getCompressionMode, getCompressionQuality, getCompressionQualityDescriptions, getCompressionQualityValues, getCompressionType, getCompressionTypes, getLocale, getLocalizedCompressionTypeName, getPreferredTileSizes, getProgressiveMode, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getTilingMode, setCompressionMode, setCompressionQuality, setCompressionType, setProgressiveMode, setTiling, setTilingMode, unsetTilingModifier and TypeMethodDescriptionbooleanReturnstrueif the writer can perform tiling with non-zero grid offsets while writing.booleanReturnstrueif this writer supports compression.booleanReturnstrueif the writer can write out images as a series of passes of progressively increasing quality.booleanReturnstrueif the writer can perform tiling while writing.floatgetBitRate(float quality) Returns afloatindicating an estimate of the number of bits of output data for each bit of input image data at the given quality level.intReturns the current compression mode, if compression is supported.floatReturns the current compression quality setting.String[]Returns an array ofStrings that may be used along withgetCompressionQualityValuesas part of a user interface for setting or displaying the compression quality level.float[]Returns an array offloats that may be used along withgetCompressionQualityDescriptionsas part of a user interface for setting or displaying the compression quality level.Returns the currently set compression type, ornullif none has been set.String[]Returns a list of available compression types, as an array orStrings, ornullif a compression type may not be chosen using these interfaces.Returns the currently setLocale, ornullif only a defaultLocaleis supported.Returns a localized version of the name of the current compression type, using theLocalereturned bygetLocale.Returns an array ofDimensions indicating the legal size ranges for tiles as they will be encoded in the output file or stream.intReturns the current mode for writing the stream in a progressive manner.intReturns the horizontal tile grid offset of an image as it will be written to the output stream.intReturns the vertical tile grid offset of an image as it will be written to the output stream.intReturns the height of each tile in an image as it will be written to the output stream.intReturns the width of each tile in an image as it will be written to the output stream.intReturns the current tiling mode, if tiling is supported.voidsetCompressionMode(int mode) Specifies whether compression is to be performed, and if so how compression parameters are to be determined.voidsetCompressionQuality(float quality) Sets the compression quality to a value between0and1.voidsetCompressionType(String compressionType) Sets the compression type to one of the values indicated bygetCompressionTypes.voidsetProgressiveMode(int mode) Specifies that the writer is to write the image out in a progressive mode such that the stream will contain a series of scans of increasing quality.voidsetTiling(int tileWidth, int tileHeight, int tileGridXOffset, int tileGridYOffset) Specifies that the image should be tiled in the output stream.voidsetTilingMode(int mode) Determines whether the image will be tiled in the output stream and, if it will, how the tiling parameters will be determined.voidRemoves any previous tile grid parameters specified by calls tosetTiling.Methods declared in class IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceBands, setSourceRegion, setSourceSubsamplingModifier and TypeMethodDescriptionbooleanActivates the installedIIOParamControllerfor thisIIOParamobject and returns the resulting value.Returns whateverIIOParamControlleris 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.intReturns the number of source columns to advance for each pixel.intReturns the number of rows to advance for each pixel.intReturns the horizontal offset of the subsampling grid.intReturns the vertical offset of the subsampling grid.booleanReturnstrueif there is a controller installed for thisIIOParamobject.voidsetController(IIOParamController controller) Sets theIIOParamControllerto be used to provide settings for thisIIOParamobject when theactivateControllermethod is called, overriding any default controller.voidsetDestinationOffset(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.voidsetDestinationType(ImageTypeSpecifier destinationType) Sets the desired image type for the destination image, using anImageTypeSpecifier.voidsetSourceBands(int[] sourceBands) Sets the indices of the source bands to be used.voidsetSourceRegion(Rectangle sourceRegion) Sets the source region of interest.voidsetSourceSubsampling(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, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()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.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(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 voidwait(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
-
JPEGImageWriteParam
Constructs aJPEGImageWriteParam. Tiling is not supported. Progressive encoding is supported. The default progressive mode is MODE_DISABLED. A single form of compression, named "JPEG", is supported. The default compression quality is 0.75.- Parameters:
locale- aLocaleto be used by the superclass to localize compression type names and quality descriptions, ornull.
-
-
Method Details
-
unsetCompression
public void unsetCompression()Removes any previous compression quality setting.The default implementation resets the compression quality to
0.75F.- Overrides:
unsetCompressionin classImageWriteParam- Throws:
IllegalStateException- if the compression mode is notMODE_EXPLICIT.- See Also:
-
isCompressionLossless
public boolean isCompressionLossless()Returnsfalsesince the JPEG plug-in only supports lossy compression.- Overrides:
isCompressionLosslessin classImageWriteParam- Returns:
false.- Throws:
IllegalStateException- if the compression mode is notMODE_EXPLICIT.
-
areTablesSet
public boolean areTablesSet()Returnstrueif tables are currently set.- Returns:
trueif tables are present.
-
setEncodeTables
public void setEncodeTables(JPEGQTable[] qTables, JPEGHuffmanTable[] DCHuffmanTables, JPEGHuffmanTable[] ACHuffmanTables) Sets the quantization and Huffman tables to use in encoding abbreviated streams. There may be a maximum of 4 tables of each type. These tables are ignored if tables are specified in the metadata. 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 metadata 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 isnullor has more than 4 elements, or if the numbers of DC and AC tables differ.- See Also:
-
unsetEncodeTables
public void unsetEncodeTables()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 tosetEncodeTables, ornullif tables are not currently set.- Returns:
- an array of
JPEGQTableobjects, ornull. - See Also:
-
getDCHuffmanTables
Returns a copy of the array of DC Huffman tables set on the most recent call tosetEncodeTables, ornullif tables are not currently set.- Returns:
- an array of
JPEGHuffmanTableobjects, ornull. - See Also:
-
getACHuffmanTables
Returns a copy of the array of AC Huffman tables set on the most recent call tosetEncodeTables, ornullif tables are not currently set.- Returns:
- an array of
JPEGHuffmanTableobjects, ornull. - See Also:
-
setOptimizeHuffmanTables
public void setOptimizeHuffmanTables(boolean optimize) Tells the writer to generate optimized Huffman tables for the image as part of the writing process. The default isfalse. If this flag is set totrue, it overrides any tables specified in the metadata. Note that this means that any image written with this flag set totruewill always contain Huffman tables.- Parameters:
optimize- A boolean indicating whether to generate optimized Huffman tables when writing.- See Also:
-
getOptimizeHuffmanTables
public boolean getOptimizeHuffmanTables()Returns the value passed into the most recent call tosetOptimizeHuffmanTables, orfalseifsetOptimizeHuffmanTableshas never been called.- Returns:
trueif the writer will generate optimized Huffman tables.- See Also:
-