Class TIFFEncodeParam
- java.lang.Object
-
- org.apache.xmlgraphics.image.codec.tiff.TIFFEncodeParam
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,ImageDecodeParam
,ImageEncodeParam
public class TIFFEncodeParam extends java.lang.Object implements ImageEncodeParam
An instance ofImageEncodeParam
for encoding images in the TIFF format.This class allows for the specification of encoding parameters. By default, the image is encoded without any compression, and is written out consisting of strips, not tiles. The particular compression scheme to be used can be specified by using the
setCompression()
method. The compression scheme specified will be honored only if it is compatible with the type of image being written out. For example, Group3 and Group4 compressions can only be used with Bilevel images. Writing of tiled TIFF images can be enabled by calling thesetWriteTiled()
method.This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private CompressionValue
compression
private boolean
convertJPEGRGBToYCbCr
private int
deflateLevel
private TIFFField[]
extraFields
private java.util.Iterator
extraImages
private static long
serialVersionUID
private int
tileHeight
private int
tileWidth
private boolean
writeTiled
-
Constructor Summary
Constructors Constructor Description TIFFEncodeParam()
Constructs a TIFFEncodeParam object with default values for all parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompressionValue
getCompression()
Returns the value of the compression parameter.int
getDeflateLevel()
Gets the compression level for DEFLATE compression.TIFFField[]
getExtraFields()
Returns the value set bysetExtraFields()
.java.util.Iterator
getExtraImages()
Returns the additional imageIterator
specified viasetExtraImages()
ornull
if none was supplied or if anull
value was supplied.boolean
getJPEGCompressRGBToYCbCr()
Whether RGB data will be converted to YCbCr when using JPEG compression.int
getTileHeight()
Retrieves the tile height set viasetTileSize()
.int
getTileWidth()
Retrieves the tile width set viasetTileSize()
.boolean
getWriteTiled()
Returns the value of the writeTiled parameter.void
setCompression(CompressionValue compression)
Specifies the type of compression to be used.void
setDeflateLevel(int deflateLevel)
Sets the compression level for DEFLATE-compressed data which should either bejava.util.Deflater.DEFAULT_COMPRESSION
or a value in the range [1,9] where larger values indicate more compression.void
setExtraFields(TIFFField[] extraFields)
Sets an array of extra fields to be written to the TIFF Image File Directory (IFD).void
setExtraImages(java.util.Iterator extraImages)
Sets anIterator
of additional images to be written after the image passed as an argument to theImageEncoder
.void
setJPEGCompressRGBToYCbCr(boolean convertJPEGRGBToYCbCr)
Sets flag indicating whether to convert RGB data to YCbCr when the compression type is JPEG.void
setTileSize(int tileWidth, int tileHeight)
Sets the dimensions of the tiles to be written.void
setWriteTiled(boolean writeTiled)
If set, the data will be written out in tiled format, instead of in strips.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
compression
private CompressionValue compression
-
writeTiled
private boolean writeTiled
-
tileWidth
private int tileWidth
-
tileHeight
private int tileHeight
-
extraImages
private java.util.Iterator extraImages
-
extraFields
private TIFFField[] extraFields
-
convertJPEGRGBToYCbCr
private boolean convertJPEGRGBToYCbCr
-
deflateLevel
private int deflateLevel
-
-
Method Detail
-
getCompression
public CompressionValue getCompression()
Returns the value of the compression parameter.
-
setCompression
public void setCompression(CompressionValue compression)
Specifies the type of compression to be used. The compression type specified will be honored only if it is compatible with the image being written out. Currently only PackBits, JPEG, and DEFLATE compression schemes are supported.If
compression
is set to any value butCOMPRESSION_NONE
and theOutputStream
supplied to theImageEncoder
is not aSeekableOutputStream
, then the encoder will use either a temporary file or a memory cache when compressing the data depending on whether the file system is accessible. Compression will therefore be more efficient if aSeekableOutputStream
is supplied.- Parameters:
compression
- The compression type.
-
getWriteTiled
public boolean getWriteTiled()
Returns the value of the writeTiled parameter.
-
setWriteTiled
public void setWriteTiled(boolean writeTiled)
If set, the data will be written out in tiled format, instead of in strips.- Parameters:
writeTiled
- Specifies whether the image data should be wriiten out in tiled format.
-
setTileSize
public void setTileSize(int tileWidth, int tileHeight)
Sets the dimensions of the tiles to be written. If either value is non-positive, the encoder will use a default value.If the data are being written as tiles, i.e.,
getWriteTiled()
returnstrue
, then the default tile dimensions used by the encoder are those of the tiles of the image being encoded.If the data are being written as strips, i.e.,
getWriteTiled()
returnsfalse
, the width of each strip is always the width of the image and the default number of rows per strip is 8.- Parameters:
tileWidth
- The tile width; ignored if strips are used.tileHeight
- The tile height or number of rows per strip.
-
getTileWidth
public int getTileWidth()
Retrieves the tile width set viasetTileSize()
.
-
getTileHeight
public int getTileHeight()
Retrieves the tile height set viasetTileSize()
.
-
setExtraImages
public void setExtraImages(java.util.Iterator extraImages)
Sets anIterator
of additional images to be written after the image passed as an argument to theImageEncoder
. The methods on the suppliedIterator
must only be invoked by theImageEncoder
which will exhaust the available values unless an error occurs.The value returned by an invocation of
next()
on theIterator
must return either aRenderedImage
or anObject[]
of length 2 wherein the element at index zero is aRenderedImage
amd the other element is aTIFFEncodeParam
. If noTIFFEncodeParam
is supplied in this manner for an additional image, the parameters used to create theImageEncoder
will be used. The extra imageIterator
set on anyTIFFEncodeParam
of an additional image will in all cases be ignored.
-
getExtraImages
public java.util.Iterator getExtraImages()
Returns the additional imageIterator
specified viasetExtraImages()
ornull
if none was supplied or if anull
value was supplied.
-
setDeflateLevel
public void setDeflateLevel(int deflateLevel)
Sets the compression level for DEFLATE-compressed data which should either bejava.util.Deflater.DEFAULT_COMPRESSION
or a value in the range [1,9] where larger values indicate more compression. The default setting isDeflater.DEFAULT_COMPRESSION
. This setting is ignored if the compression type is not DEFLATE.
-
getDeflateLevel
public int getDeflateLevel()
Gets the compression level for DEFLATE compression.
-
setJPEGCompressRGBToYCbCr
public void setJPEGCompressRGBToYCbCr(boolean convertJPEGRGBToYCbCr)
Sets flag indicating whether to convert RGB data to YCbCr when the compression type is JPEG. The default value istrue
. This flag is ignored if the compression type is not JPEG.
-
getJPEGCompressRGBToYCbCr
public boolean getJPEGCompressRGBToYCbCr()
Whether RGB data will be converted to YCbCr when using JPEG compression.
-
setExtraFields
public void setExtraFields(TIFFField[] extraFields)
Sets an array of extra fields to be written to the TIFF Image File Directory (IFD). Fields with tags equal to the tag of any automatically generated fields are ignored. No error checking is performed with respect to the validity of the field contents or the appropriateness of the field for the image being encoded.- Parameters:
extraFields
- An array of extra fields; the parameter is copied by reference.
-
getExtraFields
public TIFFField[] getExtraFields()
Returns the value set bysetExtraFields()
.
-
-