Class TIFFCompressor
java.lang.Object
com.sun.media.imageio.plugins.tiff.TIFFCompressor
- Direct Known Subclasses:
TIFFBaseJPEGCompressor,TIFFDeflater,TIFFFaxCompressor,TIFFLSBCompressor,TIFFLZWCompressor,TIFFNullCompressor,TIFFPackBitsCompressor
An abstract superclass for pluggable TIFF compressors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe value to be assigned to the TIFF Compression tag in the TIFF image metadata.protected StringThe name of the compression type supported by this compressor.protected booleanWhether the compression is lossless.protected IIOMetadataTheIIOMetadataobject containing metadata for the current image.protected ImageOutputStreamTheImageOutputStreamto be written.protected ImageWriterTheImageWritercalling thisTIFFCompressor. -
Constructor Summary
ConstructorsConstructorDescriptionTIFFCompressor(String compressionType, int compressionTagValue, boolean isCompressionLossless) Creates a compressor object for use in compressing TIFF data. -
Method Summary
Modifier and TypeMethodDescriptionabstract intencode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride) Encodes the supplied image data, writing to the currently setImageOutputStream.intRetrieve the value to be assigned to the TIFF Compression tag in the TIFF image metadata.Retrieve the name of the compression type supported by this compressor.Returns the currentIIOMetadataobject.Returns theImageOutputStreamthat will be written.Returns the currentImageWriter.booleanRetrieves a value indicating whether the compression is lossless.voidsetMetadata(IIOMetadata metadata) Sets the value of themetadatafield.voidsetStream(ImageOutputStream stream) Sets theImageOutputStreamto be written.voidsetWriter(ImageWriter writer) Sets the value of thewriterfield.
-
Field Details
-
writer
TheImageWritercalling thisTIFFCompressor. -
metadata
TheIIOMetadataobject containing metadata for the current image. -
compressionType
The name of the compression type supported by this compressor. -
compressionTagValue
protected int compressionTagValueThe value to be assigned to the TIFF Compression tag in the TIFF image metadata. -
isCompressionLossless
protected boolean isCompressionLosslessWhether the compression is lossless. -
stream
TheImageOutputStreamto be written.
-
-
Constructor Details
-
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 theTIFFImageWriteParam.setTIFFCompressor(TIFFCompressor)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
compressionTagValueandisCompressionLosslessare 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 (seeTIFFImageWriteParam), or is listed in the TIFF 6.0 specification but not supported. If the compression type is unknown, thecompressionTagValueandisCompressionLosslessparameters 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 ifcompressionTypeis a known type.isCompressionLossless- Whether the compression is lossless; ignored ifcompressionTypeis a known type.- Throws:
IllegalArgumentException- ifcompressionTypeisnullorcompressionTagValueis less than1.
-
-
Method Details
-
getCompressionType
Retrieve the name of the compression type supported by this compressor.- Returns:
- The compression type name.
-
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.
-
isCompressionLossless
public boolean isCompressionLossless()Retrieves a value indicating whether the compression is lossless.- Returns:
- Whether the compression is lossless.
-
setStream
Sets theImageOutputStreamto be written.- Parameters:
stream- anImageOutputStreamto be written.- See Also:
-
getStream
Returns theImageOutputStreamthat will be written.- Returns:
- an
ImageOutputStream. - See Also:
-
setWriter
Sets the value of thewriterfield.- Parameters:
writer- the currentImageWriter.- See Also:
-
getWriter
Returns the currentImageWriter.- Returns:
- an
ImageWriter. - See Also:
-
setMetadata
Sets the value of themetadatafield.- Parameters:
metadata- theIIOMetadataobject for the image being written.- See Also:
-
getMetadata
Returns the currentIIOMetadataobject.- Returns:
- the
IIOMetadataobject for the image being written. - See Also:
-
encode
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 setImageOutputStream.- Parameters:
b- an array ofbytes containing the packed but uncompressed image data.off- the starting offset of the data to be written in the arrayb.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 ofints 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 thisTIFFCompressor, or if any I/O error occurs during writing.
-