Class TIFFDecodeParam
- java.lang.Object
-
- org.apache.xmlgraphics.image.codec.tiff.TIFFDecodeParam
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,ImageDecodeParam
public class TIFFDecodeParam extends java.lang.Object implements ImageDecodeParam
An instance ofImageDecodeParam
for decoding images in the TIFF format.To determine the number of images present in a TIFF file, use the
getNumPages()
method on theImageDecoder
object that will be used to perform the decoding. The desired page number may be passed as an argument to theImageDecoder.decodeAsRaster)()
ordecodeAsRenderedImage()
methods.For TIFF Palette color images, the colorMap always has entries of short data type, the color Black being represented by 0,0,0 and White by 65536,65536,65536. In order to display these images, the default behavior is to dither the short values down to 8 bits. The dithering is done by calling the
decode16BitsTo8Bits
method for each short value that needs to be dithered. The method has the following implementation:byte b; short s; s = s & 0xffff; b = (byte)((s >> 8) & 0xff);
If a different algorithm is to be used for the dithering, this class should be subclassed and an appropriate implementation should be provided for thedecode16BitsTo8Bits
method in the subclass.If the palette contains image data that is signed short, as specified by the SampleFormat tag, the dithering is done by calling
decodeSigned16BitsTo8Bits
instead. The method has the following implementation:byte b; short s; b = (byte)((s + Short.MIN_VALUE) >> 8);
In order to use a different algorithm for the dithering, this class should be subclassed and the method overridden.If it is desired that the Palette be decoded such that the output image is of short data type and no dithering is performed, the
setDecodePaletteAsShorts
method should be used.This class is not a committed part of the JAI API. It may be removed or changed in future releases of JAI.
- See Also:
TIFFDirectory
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
convertJPEGYCbCrToRGB
private boolean
decodePaletteAsShorts
private java.lang.Long
ifdOffset
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description TIFFDecodeParam()
Constructs a default instance ofTIFFDecodeParam
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
decode16BitsTo8Bits(int s)
Returns an unsigned 8 bit value computed by dithering the unsigned 16 bit value.byte
decodeSigned16BitsTo8Bits(short s)
Returns an unsigned 8 bit value computed by dithering the signed 16 bit value.boolean
getDecodePaletteAsShorts()
Returnstrue
if palette entries will be decoded as shorts, resulting in an output image with short datatype.java.lang.Long
getIFDOffset()
Returns the value set bysetIFDOffset()
ornull
if no value has been set.boolean
getJPEGDecompressYCbCrToRGB()
Whether JPEG-compressed YCbCr data will be converted to RGB.void
setDecodePaletteAsShorts(boolean decodePaletteAsShorts)
If set, the entries in the palette will be decoded as shorts and no short to byte lookup will be applied to them.void
setIFDOffset(long offset)
Sets the offset in the stream from which to read the image.void
setJPEGDecompressYCbCrToRGB(boolean convertJPEGYCbCrToRGB)
Sets a flag indicating whether to convert JPEG-compressed YCbCr data to RGB.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
decodePaletteAsShorts
private boolean decodePaletteAsShorts
-
ifdOffset
private java.lang.Long ifdOffset
-
convertJPEGYCbCrToRGB
private boolean convertJPEGYCbCrToRGB
-
-
Method Detail
-
setDecodePaletteAsShorts
public void setDecodePaletteAsShorts(boolean decodePaletteAsShorts)
If set, the entries in the palette will be decoded as shorts and no short to byte lookup will be applied to them.
-
getDecodePaletteAsShorts
public boolean getDecodePaletteAsShorts()
Returnstrue
if palette entries will be decoded as shorts, resulting in an output image with short datatype.
-
decode16BitsTo8Bits
public byte decode16BitsTo8Bits(int s)
Returns an unsigned 8 bit value computed by dithering the unsigned 16 bit value. Note that the TIFF specified short datatype is an unsigned value, while Java'sshort
datatype is a signed value. Therefore the Javashort
datatype cannot be used to store the TIFF specified short value. A Javaint
is used as input instead to this method. The method deals correctly only with 16 bit unsigned values.
-
decodeSigned16BitsTo8Bits
public byte decodeSigned16BitsTo8Bits(short s)
Returns an unsigned 8 bit value computed by dithering the signed 16 bit value. This method deals correctly only with values in the 16 bit signed range.
-
setIFDOffset
public void setIFDOffset(long offset)
Sets the offset in the stream from which to read the image. There must be an Image File Directory (IFD) at that position or an error will occur. IfsetIFDOffset()
is never invoked then the decoder will assume that the TIFF stream is at the beginning of the 8-byte image header. If the directory offset is set and a page number is supplied to the TIFFImageDecoder
then the page will be the zero-relative index of the IFD in linked list of IFDs beginning at the specified offset with a page of zero indicating the directory at that offset.
-
getIFDOffset
public java.lang.Long getIFDOffset()
Returns the value set bysetIFDOffset()
ornull
if no value has been set.
-
setJPEGDecompressYCbCrToRGB
public void setJPEGDecompressYCbCrToRGB(boolean convertJPEGYCbCrToRGB)
Sets a flag indicating whether to convert JPEG-compressed YCbCr data to RGB. The default value istrue
. This flag is ignored if the image data are not JPEG-compressed.
-
getJPEGDecompressYCbCrToRGB
public boolean getJPEGDecompressYCbCrToRGB()
Whether JPEG-compressed YCbCr data will be converted to RGB.
-
-