com.sun.media.imageio.plugins.tiff
Class TIFFImageWriteParam

java.lang.Object
  |
  +--javax.imageio.IIOParam
        |
        +--javax.imageio.ImageWriteParam
              |
              +--com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam

public class TIFFImageWriteParam
extends ImageWriteParam

A subclass of ImageWriteParam allowing control over the standard TIFF compression types.

Supported Compression Types
Compression Type Description Reference
CCITT RLE Modified Huffman compression TIFF 6.0 Specification, Section 10
CCITT T.4 CCITT T.4 bilevel encoding/Group 3 facsimile compression TIFF 6.0 Specification, Section 11
CCITT T.6 CCITT T.6 bilevel encoding/Group 4 facsimile compression TIFF 6.0 Specification, Section 11
JPEG "New" JPEG-in-TIFF compression TIFF Technical Note #2
Deflate "Zip-in-TIFF" compression DEFLATE Compressed Data Format Specification
PackBits Byte-oriented, run length compression TIFF 6.0 Specification, Section 9

LZW and old-style JPEG compression as described in sections 13 and 22, respectively of the TIFF 6.0 Specification are not supported.

The canWriteTiles and canWriteCompressed methods will return true; the canOffsetTiles and canWriteProgressive methods will return false.

The CCITT compression types are applicable to bilevel (1-bit) images only. The JPEG compression type is applicable to byte grayscale (1-band) and RGB (3-band) images only.

If Deflate or JPEG compression is used, the compression quality may be set. For Deflate the supplied floating point quality value is rescaled to the range [1, 9] and truncated to an integer to derive the Deflate compression level. For JPEG the floating point quality value is passed directly to the JPEG writer plug-in which interprets it in the usual way.


Field Summary
 
Fields inherited from class javax.imageio.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, tilingSet
 
Fields inherited from class javax.imageio.IIOParam
controller, defaultController, destinationOffset, destinationType, sourceBands, sourceRegion, sourceXSubsampling, sourceYSubsampling, subsamplingXOffset, subsamplingYOffset
 
Constructor Summary
TIFFImageWriteParam(Locale locale)
          Constructs a TIFFImageWriteParam instance for a given Locale.
 
Method Summary
 TIFFColorConverter getColorConverter()
          Returns the current TIFFColorConverter object that will be used to perform color conversion when writing the image, or null if none is set.
 int getPhotometricInterpretation()
          Returns the current value that will be written to the Photometricinterpretation tag.
 TIFFCompressor getTIFFCompressor()
          Returns the TIFFCompressor that is currently set to be used by the ImageWriter to encode each image strip or tile, or null if none has been set.
 boolean isCompressionLossless()
           
 void setColorConverter(TIFFColorConverter colorConverter, int photometricInterpretation)
          Sets the TIFFColorConverter object describing the color space to which the input data should be converted for storage in the input stream.
 void setTIFFCompressor(TIFFCompressor compressor)
          Sets the TIFFCompressor object to be used by the ImageWriter to encode each image strip or tile.
 void unsetColorConverter()
          Removes any currently set ColorConverter object and PhotometricInterpretation tag value.
 
Methods inherited from class javax.imageio.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, unsetCompression, unsetTiling
 
Methods inherited from class javax.imageio.IIOParam
activateController, getController, getDefaultController, getDestinationOffset, getDestinationType, getSourceBands, getSourceRegion, getSourceXSubsampling, getSourceYSubsampling, getSubsamplingXOffset, getSubsamplingYOffset, hasController, setController, setDestinationOffset, setDestinationType, setSourceBands, setSourceRegion, setSourceSubsampling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TIFFImageWriteParam

public TIFFImageWriteParam(Locale locale)
Constructs a TIFFImageWriteParam instance for a given Locale.

Parameters:
locale - the Locale for which messages should be localized.
Method Detail

isCompressionLossless

public boolean isCompressionLossless()
Overrides:
isCompressionLossless in class ImageWriteParam

setTIFFCompressor

public void setTIFFCompressor(TIFFCompressor compressor)
Sets the TIFFCompressor object to be used by the ImageWriter to encode each image strip or tile. A value of null allows the writer to choose its own TIFFCompressor.

Note that invoking this method is not sufficient to set the compression type: setCompressionType() must be invoked explicitly for this purpose. The following code illustrates the correct procedure:

 TIFFImageWriteParam writeParam;
 TIFFCompressor compressor;
 writeParam.setCompressionMode(writeParam.MODE_EXPLICIT);
 writeParam.setTIFFCompressor(compressor);
 writeParam.setCompressionType(compressor.getCompressionType());
 
If compressionType is set to a value different from that supported by the TIFFCompressor then the compressor object will not be used.

If the compression type supported by the supplied TIFFCompressor is not among those in compressionTypes, then it will be appended to this array after removing any previously appended compression type. If compressor is null this will also cause any previously appended type to be removed from the array.

Parameters:
compressor - the TIFFCompressor to be used for encoding, or null to allow the writer to choose its own.
Throws:
IllegalStateException - if the compression mode is not MODE_EXPLICIT.
See Also:
getTIFFCompressor()

getTIFFCompressor

public TIFFCompressor getTIFFCompressor()
Returns the TIFFCompressor that is currently set to be used by the ImageWriter to encode each image strip or tile, or null if none has been set.

Returns:
compressor the TIFFCompressor to be used for encoding, or null if none has been set (allowing the writer to choose its own).
Throws:
IllegalStateException - if the compression mode is not MODE_EXPLICIT.
See Also:
setTIFFCompressor(TIFFCompressor)

setColorConverter

public void setColorConverter(TIFFColorConverter colorConverter,
                              int photometricInterpretation)
Sets the TIFFColorConverter object describing the color space to which the input data should be converted for storage in the input stream. In addition, the value to be written to the PhotometricInterpretation tag is supplied.

Parameters:
colorConverter - a TIFFColorConverter object, or null.
photometricInterpretation - the value to be written to the PhotometricInterpretation tag in the root IFD.
See Also:
getColorConverter(), getPhotometricInterpretation()

getColorConverter

public TIFFColorConverter getColorConverter()
Returns the current TIFFColorConverter object that will be used to perform color conversion when writing the image, or null if none is set.

Returns:
a TIFFColorConverter object, or null.
See Also:
setColorConverter(TIFFColorConverter, int)

getPhotometricInterpretation

public int getPhotometricInterpretation()
Returns the current value that will be written to the Photometricinterpretation tag. This method should only be called if a value has been set using the setColorConverter method.

Returns:
an int to be used as the value of the PhotometricInterpretation tag.
Throws:
IllegalStateException - if no value is set.
See Also:
setColorConverter(TIFFColorConverter, int)

unsetColorConverter

public void unsetColorConverter()
Removes any currently set ColorConverter object and PhotometricInterpretation tag value.

See Also:
setColorConverter(TIFFColorConverter, int)