public abstract class TIFFBaseJPEGCompressor extends TIFFCompressor
Modifier and Type | Class and Description |
---|---|
private static class |
TIFFBaseJPEGCompressor.IIOByteArrayOutputStream
A
ByteArrayOutputStream which allows writing to an
ImageOutputStream . |
Modifier and Type | Field and Description |
---|---|
private TIFFBaseJPEGCompressor.IIOByteArrayOutputStream |
baos |
private static boolean |
DEBUG |
protected static String |
IMAGE_METADATA_NAME |
private IIOMetadata |
JPEGImageMetadata |
protected JPEGImageWriteParam |
JPEGParam
ImageWriteParam for JPEG writer.
|
protected IIOMetadata |
JPEGStreamMetadata
Stream metadata equivalent to a tables-only stream such as in
the
JPEGTables . |
protected ImageWriter |
JPEGWriter
The JPEG writer.
|
private ImageWriteParam |
param |
protected static String |
STREAM_METADATA_NAME |
private boolean |
usingCodecLib |
protected boolean |
writeAbbreviatedStream
Whether to write abbreviated JPEG streams (default == false).
|
compressionTagValue, compressionType, isCompressionLossless, metadata, stream, writer
Constructor and Description |
---|
TIFFBaseJPEGCompressor(String compressionType,
int compressionTagValue,
boolean isCompressionLossless,
ImageWriteParam param) |
Modifier and Type | Method and Description |
---|---|
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 . |
protected void |
finalize() |
private static List |
getAllNodes(IIOMetadataNode root,
List nodes) |
private IIOMetadata |
getImageMetadata(boolean pruneTables)
Retrieves image metadata with non-core nodes removed.
|
protected void |
initJPEGWriter(boolean supportsStreamMetadata,
boolean supportsImageMetadata)
Initializes the JPEGWriter and JPEGParam instance variables.
|
private static void |
pruneNodes(Node tree,
boolean pruneTables)
Removes nonessential nodes from a JPEG native image metadata tree.
|
getCompressionTagValue, getCompressionType, getMetadata, getStream, getWriter, isCompressionLossless, setMetadata, setStream, setWriter
private static final boolean DEBUG
protected static final String STREAM_METADATA_NAME
protected static final String IMAGE_METADATA_NAME
private ImageWriteParam param
protected JPEGImageWriteParam JPEGParam
initJPEGWriter(boolean, boolean)
.protected ImageWriter JPEGWriter
initJPEGWriter(boolean, boolean)
.protected boolean writeAbbreviatedStream
true
should also
initialized JPEGStreamMetadata
.protected IIOMetadata JPEGStreamMetadata
JPEGTables
. Default value is null
.
This should be set by any subclass which sets
writeAbbreviatedStream
to true
.private IIOMetadata JPEGImageMetadata
private boolean usingCodecLib
private TIFFBaseJPEGCompressor.IIOByteArrayOutputStream baos
public TIFFBaseJPEGCompressor(String compressionType, int compressionTagValue, boolean isCompressionLossless, ImageWriteParam param)
private static void pruneNodes(Node tree, boolean pruneTables)
pruneTables
is
true
in which case the nodes derived from the DHT and
DQT marker segments are also removed.tree
- A javax_imageio_jpeg_image_1.0 tree.pruneTables
- Whether to prune Huffman and quantization tables.IllegalArgumentException
- if tree
is
null
or is not the root of a JPEG native image
metadata tree.private static List getAllNodes(IIOMetadataNode root, List nodes)
protected void initJPEGWriter(boolean supportsStreamMetadata, boolean supportsImageMetadata)
supportsStreamMetadata
- Whether the JPEG writer must
support JPEG native stream metadata, i.e., be capable of writing
abbreviated streams.supportsImageMetadata
- Whether the JPEG writer must
support JPEG native image metadata.private IIOMetadata getImageMetadata(boolean pruneTables) throws IIOException
IIOException
public final int encode(byte[] b, int off, int width, int height, int[] bitsPerSample, int scanlineStride) throws IOException
TIFFCompressor
ImageOutputStream
.encode
in class TIFFCompressor
b
- an array of byte
s 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 int
s 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.IOException
- if the supplied data cannot be encoded by
this TIFFCompressor
, or if any I/O error occurs
during writing.Copyright © 2016 Open Microscopy Environment