com.sun.media.imageio.plugins.tiff

Class TIFFCompressor

public abstract class TIFFCompressor extends Object

An abstract superclass for pluggable TIFF compressors.
Field Summary
protected intcompressionTagValue
The value to be assigned to the TIFF Compression tag in the TIFF image metadata.
protected StringcompressionType
The name of the compression type supported by this compressor.
protected booleanisCompressionLossless
Whether the compression is lossless.
protected IIOMetadatametadata
The IIOMetadata object containing metadata for the current image.
protected ImageOutputStreamstream
The ImageOutputStream to be written.
protected ImageWriterwriter
The ImageWriter calling this TIFFCompressor.
Constructor Summary
TIFFCompressor(String compressionType, int compressionTagValue, boolean isCompressionLossless)
Creates a compressor object for use in compressing TIFF data.
Method Summary
abstract intencode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride)
Encodes the supplied image data, writing to the currently set ImageOutputStream.
intgetCompressionTagValue()
Retrieve the value to be assigned to the TIFF Compression tag in the TIFF image metadata.
StringgetCompressionType()
Retrieve the name of the compression type supported by this compressor.
IIOMetadatagetMetadata()
Returns the current IIOMetadata object.
ImageOutputStreamgetStream()
Returns the ImageOutputStream that will be written.
ImageWritergetWriter()
Returns the current ImageWriter.
booleanisCompressionLossless()
Retrieves a value indicating whether the compression is lossless.
voidsetMetadata(IIOMetadata metadata)
Sets the value of the metadata field.
voidsetStream(ImageOutputStream stream)
Sets the ImageOutputStream to be written.
voidsetWriter(ImageWriter writer)
Sets the value of the writer field.

Field Detail

compressionTagValue

protected int compressionTagValue
The value to be assigned to the TIFF Compression tag in the TIFF image metadata.

compressionType

protected String compressionType
The name of the compression type supported by this compressor.

isCompressionLossless

protected boolean isCompressionLossless
Whether the compression is lossless.

metadata

protected IIOMetadata metadata
The IIOMetadata object containing metadata for the current image.

stream

protected ImageOutputStream stream
The ImageOutputStream to be written.

writer

protected ImageWriter writer
The ImageWriter calling this TIFFCompressor.

Constructor Detail

TIFFCompressor

public TIFFCompressor(String compressionType, int compressionTagValue, boolean isCompressionLossless)
Creates a compressor object for use in compressing TIFF data. This object may be passed to the setTIFFCompressor method to override the compressor of a supported compression type or to provide the implementation of the compression algorithm of an unsupported compression type.

The parameters compressionTagValue and isCompressionLossless are provided to accomodate compression types which are unknown. A compression type is "known" if it is either among those already supported by the TIFF writer (see TIFFImageWriteParam), or is listed in the TIFF 6.0 specification but not supported. If the compression type is unknown, the compressionTagValue and isCompressionLossless parameters are ignored.

Parameters: compressionType The name of the compression type. compressionTagValue The value to be assigned to the TIFF Compression tag in the TIFF image metadata; ignored if compressionType is a known type. isCompressionLossless Whether the compression is lossless; ignored if compressionType is a known type.

Throws: IllegalArgumentException if compressionType is null or compressionTagValue is less than 1.

Method Detail

encode

public abstract int encode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride)
Encodes the supplied image data, writing to the currently set ImageOutputStream.

Parameters: b an array of bytes containing the packed but uncompressed image data. off the starting offset of the data to be written in the array b. width the width of the rectangle of pixels to be written. height the height of the rectangle of pixels to be written. bitsPerSample an array of ints indicting the number of bits used to represent each image sample within a pixel. scanlineStride the number of bytes separating each row of the input data.

Returns: the number of bytes written.

Throws: IOException if the supplied data cannot be encoded by this TIFFCompressor, or if any I/O error occurs during writing.

getCompressionTagValue

public int getCompressionTagValue()
Retrieve the value to be assigned to the TIFF Compression tag in the TIFF image metadata.

Returns: The Compression tag value.

getCompressionType

public String getCompressionType()
Retrieve the name of the compression type supported by this compressor.

Returns: The compression type name.

getMetadata

public IIOMetadata getMetadata()
Returns the current IIOMetadata object.

Returns: the IIOMetadata object for the image being written.

See Also: setMetadata

getStream

public ImageOutputStream getStream()
Returns the ImageOutputStream that will be written.

Returns: an ImageOutputStream.

See Also: setStream

getWriter

public ImageWriter getWriter()
Returns the current ImageWriter.

Returns: an ImageWriter.

See Also: setWriter

isCompressionLossless

public boolean isCompressionLossless()
Retrieves a value indicating whether the compression is lossless.

Returns: Whether the compression is lossless.

setMetadata

public void setMetadata(IIOMetadata metadata)
Sets the value of the metadata field.

Parameters: metadata the IIOMetadata object for the image being written.

See Also: getMetadata

setStream

public void setStream(ImageOutputStream stream)
Sets the ImageOutputStream to be written.

Parameters: stream an ImageOutputStream to be written.

See Also: TIFFCompressor

setWriter

public void setWriter(ImageWriter writer)
Sets the value of the writer field.

Parameters: writer the current ImageWriter.

See Also: getWriter