Top Description Fields Constructors Methods
com.sun.imageio.plugins.tiff

public abstract Class TIFFCompressor

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.imageio.plugins.tiff.TIFFDeflater, com.sun.imageio.plugins.tiff.TIFFFaxCompressor, com.sun.imageio.plugins.tiff.TIFFLSBCompressor, com.sun.imageio.plugins.tiff.TIFFLZWCompressor, com.sun.imageio.plugins.tiff.TIFFNullCompressor, com.sun.imageio.plugins.tiff.TIFFPackBitsCompressor, com.sun.imageio.plugins.tiff.TIFFBaseJPEGCompressor
Imports
java.io.IOException, javax.imageio.ImageWriter, javax.imageio.metadata.IIOMetadata, javax.imageio.stream.ImageOutputStream

An abstract superclass for pluggable TIFF compressors.

Field Summary

Modifier and TypeField and Description
protected int
compressionTagValue

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

protected String
compressionType

The name of the compression type supported by this compressor.

protected boolean
isCompressionLossless

Whether the compression is lossless.

protected IIOMetadata
metadata

The IIOMetadata object containing metadata for the current image.

protected ImageOutputStream
stream

The ImageOutputStream to be written.

protected ImageWriter
writer

The ImageWriter calling this TIFFCompressor.

Constructor Summary

AccessConstructor and Description
public
TIFFCompressor(String
The name of the compression type.
compressionType
,
int
The value to be assigned to the TIFF Compression tag in the TIFF image metadata; ignored if compressionType is a known type.
compressionTagValue
,
boolean
Whether the compression is lossless; ignored if compressionType is a known type.
isCompressionLossless
)

Creates a compressor object for use in compressing TIFF data.

Method Summary

Modifier and TypeMethod and Description
public abstract int

Returns:

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

Encodes the supplied image data, writing to the currently set ImageOutputStream.

public int

Returns:

The Compression tag value.
getCompressionTagValue
()

Retrieve the value to be assigned to the TIFF Compression tag in the TIFF image metadata.

public String

Returns:

The compression type name.
getCompressionType
()

Retrieve the name of the compression type supported by this compressor.

public IIOMetadata

Returns:

the IIOMetadata object for the image being written.
getMetadata
()

Returns the current IIOMetadata object.

public ImageOutputStream

Returns:

an ImageOutputStream.
getStream
()

Returns the ImageOutputStream that will be written.

public ImageWriter

Returns:

an ImageWriter.
getWriter
()

Returns the current ImageWriter.

public boolean

Returns:

Whether the compression is lossless.
isCompressionLossless
()

Retrieves a value indicating whether the compression is lossless.

public void
setMetadata(IIOMetadata
the IIOMetadata object for the image being written.
metadata
)

Sets the value of the metadata field.

public void
setStream(ImageOutputStream
an ImageOutputStream to be written.
stream
)

Sets the ImageOutputStream to be written.

public void
setWriter(ImageWriter
the current ImageWriter.
writer
)

Sets the value of the writer field.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compressionTagValueback to summary
protected int compressionTagValue

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

compressionTypeback to summary
protected String compressionType

The name of the compression type supported by this compressor.

isCompressionLosslessback to summary
protected boolean isCompressionLossless

Whether the compression is lossless.

metadataback to summary
protected IIOMetadata metadata

The IIOMetadata object containing metadata for the current image.

streamback to summary
protected ImageOutputStream stream

The ImageOutputStream to be written.

writerback to summary
protected ImageWriter writer

The ImageWriter calling this TIFFCompressor.

Constructor Detail

TIFFCompressorback to summary
public TIFFCompressor(String compressionType, int compressionTagValue, boolean isCompressionLossless)

Creates a compressor object for use in compressing TIFF data.

The parameters compressionTagValue and isCompressionLossless are provided to accommodate 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:String

The name of the compression type.

compressionTagValue:int

The value to be assigned to the TIFF Compression tag in the TIFF image metadata; ignored if compressionType is a known type.

isCompressionLossless:boolean

Whether the compression is lossless; ignored if compressionType is a known type.

Exceptions
NullPointerException:
if compressionType is null.
IllegalArgumentException:
if compressionTagValue is less 1.

Method Detail

encodeback to summary
public abstract int encode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride) throws IOException

Encodes the supplied image data, writing to the currently set ImageOutputStream.

Parameters
b:byte[]

an array of bytes containing the packed but uncompressed image data.

off:int

the starting offset of the data to be written in the array b.

width:int

the width of the rectangle of pixels to be written.

height:int

the height of the rectangle of pixels to be written.

bitsPerSample:int[]

an array of ints indicting the number of bits used to represent each image sample within a pixel.

scanlineStride:int

the number of bytes separating each row of the input data.

Returns:int

the number of bytes written.

Exceptions
IOException:
if the supplied data cannot be encoded by this TIFFCompressor, or if any I/O error occurs during writing.
getCompressionTagValueback to summary
public int getCompressionTagValue()

Retrieve the value to be assigned to the TIFF Compression tag in the TIFF image metadata.

Returns:int

The Compression tag value.

getCompressionTypeback to summary
public String getCompressionType()

Retrieve the name of the compression type supported by this compressor.

Returns:String

The compression type name.

getMetadataback to summary
public IIOMetadata getMetadata()

Returns the current IIOMetadata object.

Returns:IIOMetadata

the IIOMetadata object for the image being written.

See Also
setMetadata(IIOMetadata)
getStreamback to summary
public ImageOutputStream getStream()

Returns the ImageOutputStream that will be written.

Returns:ImageOutputStream

an ImageOutputStream.

See Also
setStream(ImageOutputStream)
getWriterback to summary
public ImageWriter getWriter()

Returns the current ImageWriter.

Returns:ImageWriter

an ImageWriter.

See Also
setWriter(ImageWriter)
isCompressionLosslessback to summary
public boolean isCompressionLossless()

Retrieves a value indicating whether the compression is lossless.

Returns:boolean

Whether the compression is lossless.

setMetadataback to summary
public void setMetadata(IIOMetadata metadata)

Sets the value of the metadata field.

Parameters
metadata:IIOMetadata

the IIOMetadata object for the image being written.

See Also
getMetadata()
setStreamback to summary
public void setStream(ImageOutputStream stream)

Sets the ImageOutputStream to be written.

Parameters
stream:ImageOutputStream

an ImageOutputStream to be written.

See Also
getStream
setWriterback to summary
public void setWriter(ImageWriter writer)

Sets the value of the writer field.

Parameters
writer:ImageWriter

the current ImageWriter.

See Also
getWriter()