public class TIFFImageEncoder extends ImageEncoderImpl
| Modifier and Type | Class and Description |
|---|---|
private static class |
TIFFImageEncoder.Context |
| Modifier and Type | Field and Description |
|---|---|
private static int[] |
SIZE_OF_TYPE |
private static int |
TIFF_JPEG_TABLES |
private static int |
TIFF_REF_BLACK_WHITE |
private static int |
TIFF_YCBCR_POSITIONING |
private static int |
TIFF_YCBCR_SUBSAMPLING |
output, param| Constructor and Description |
|---|
TIFFImageEncoder(java.io.OutputStream output,
ImageEncodeParam param) |
| Modifier and Type | Method and Description |
|---|---|
private static int |
compressPackBits(byte[] data,
int numRows,
long bytesPerRow,
byte[] compData)
Performs PackBits compression on a tile of data.
|
private static int |
deflate(java.util.zip.Deflater deflater,
byte[] inflated,
byte[] deflated) |
void |
encode(java.awt.image.RenderedImage im)
Encodes a RenderedImage and writes the output to the
OutputStream associated with this ImageEncoder.
|
private int |
encode(java.awt.image.RenderedImage im,
TIFFEncodeParam encodeParam,
int ifdOffset,
boolean isLast) |
java.lang.Object |
encodeMultiple(java.lang.Object context,
java.awt.image.RenderedImage img)
Encodes a RenderedImage as part of a multi-page file and writes the output to the
OutputStream associated with this ImageEncoder.
|
void |
finishMultiple(java.lang.Object context)
Signals the encoder that you've finished sending pages for a multi-page image files.
|
private int |
getDirectorySize(java.util.SortedSet fields)
Calculates the size of the IFD.
|
private static int |
getValueSize(TIFFField field)
Determine the number of bytes in the value portion of the field.
|
private static int |
packBits(byte[] input,
int inOffset,
int inCount,
byte[] output,
int outOffset)
Performs PackBits compression for a single buffer of data.
|
private void |
validateImage(int dataTypeSize,
int[] sampleSize,
int numBands,
int dataType,
java.awt.image.ColorModel colorModel) |
private void |
writeDirectory(int thisIFDOffset,
java.util.SortedSet fields,
int nextIFDOffset) |
private void |
writeFileHeader() |
private void |
writeLong(long l)
despite its name, this method writes only 4 bytes to output.
|
private void |
writeUnsignedShort(int s) |
private void |
writeValues(TIFFField field) |
private void |
writeValuesAsFourBytes(TIFFField field) |
encode, getOutputStream, getParam, setParamprivate static final int TIFF_JPEG_TABLES
private static final int TIFF_YCBCR_SUBSAMPLING
private static final int TIFF_YCBCR_POSITIONING
private static final int TIFF_REF_BLACK_WHITE
private static final int[] SIZE_OF_TYPE
public TIFFImageEncoder(java.io.OutputStream output,
ImageEncodeParam param)
public void encode(java.awt.image.RenderedImage im)
throws java.io.IOException
encode in interface ImageEncoderencode in class ImageEncoderImpljava.io.IOExceptionpublic java.lang.Object encodeMultiple(java.lang.Object context,
java.awt.image.RenderedImage img)
throws java.io.IOException
When you sent all pages, make sure you call finishMultiple() in the end. Otherwise, the generated file will be corrupted.
context - the context object you receive as return value to a previous call to
encodeMultiple(). Set null for the first image.img - the imagejava.io.IOException - In case of an I/O errorpublic void finishMultiple(java.lang.Object context)
throws java.io.IOException
context - the context object you receive as return value to a previous call to
encodeMultiple()java.io.IOException - In case of an I/O errorprivate int encode(java.awt.image.RenderedImage im,
TIFFEncodeParam encodeParam,
int ifdOffset,
boolean isLast)
throws java.io.IOException
java.io.IOExceptionprivate void validateImage(int dataTypeSize,
int[] sampleSize,
int numBands,
int dataType,
java.awt.image.ColorModel colorModel)
private int getDirectorySize(java.util.SortedSet fields)
private void writeFileHeader()
throws java.io.IOException
java.io.IOExceptionprivate void writeDirectory(int thisIFDOffset,
java.util.SortedSet fields,
int nextIFDOffset)
throws java.io.IOException
java.io.IOExceptionprivate static int getValueSize(TIFFField field) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionprivate void writeValuesAsFourBytes(TIFFField field) throws java.io.IOException
java.io.IOExceptionprivate void writeValues(TIFFField field) throws java.io.IOException
java.io.IOExceptionprivate void writeUnsignedShort(int s)
throws java.io.IOException
java.io.IOExceptionprivate void writeLong(long l)
throws java.io.IOException
l - 32bits of this are written as 4 bytesjava.io.IOExceptionprivate static int compressPackBits(byte[] data,
int numRows,
long bytesPerRow,
byte[] compData)
private static int packBits(byte[] input,
int inOffset,
int inCount,
byte[] output,
int outOffset)
private static int deflate(java.util.zip.Deflater deflater,
byte[] inflated,
byte[] deflated)