Class TIFFNullDecompressor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private boolean
Whether to read the active source region only.private int
The original value ofsrcHeight
.private int
The original value ofsrcMinX
.private int
The original value ofsrcMinY
.private int
The original value ofsrcWidth
.Fields inherited from class com.github.jaiimageio.plugins.tiff.TIFFDecompressor
activeSrcHeight, activeSrcMinX, activeSrcMinY, activeSrcWidth, bitsPerSample, byteCount, colorConverter, colorMap, compression, destinationBands, dstHeight, dstMinX, dstMinY, dstWidth, dstXOffset, dstYOffset, extraSamples, image, metadata, offset, photometricInterpretation, planar, rawImage, reader, sampleFormat, samplesPerPixel, sourceBands, sourceXOffset, sourceYOffset, srcHeight, srcMinX, srcMinY, srcWidth, stream, subsampleX, subsampleY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
This routine is called prior to a sequence of calls to thedecode
method, in order to allow any necessary tables or other structures to be initialized based on metadata values.void
decode()
Decodes the input bit stream (located in theImageInputStream
stream
, at offsetoffset
, and continuing forbyteCount
bytes) into the outputBufferedImage
image
.void
decodeRaw
(byte[] b, int dstOffset, int bitsPerPixel, int scanlineStride) Decodes the source data into the providedbyte
arrayb
, starting at the offset given bydstOffset
.Methods inherited from class com.github.jaiimageio.plugins.tiff.TIFFDecompressor
createRawImage, decodeRaw, decodeRaw, decodeRaw, getRawImageType, getRawImageTypeSpecifier, setActiveSrcHeight, setActiveSrcMinX, setActiveSrcMinY, setActiveSrcWidth, setBitsPerSample, setByteCount, setColorConverter, setColorMap, setCompression, setDestinationBands, setDstHeight, setDstMinX, setDstMinY, setDstWidth, setDstXOffset, setDstYOffset, setExtraSamples, setImage, setMetadata, setOffset, setPhotometricInterpretation, setPlanar, setReader, setSampleFormat, setSamplesPerPixel, setSourceBands, setSourceXOffset, setSourceYOffset, setSrcHeight, setSrcMinX, setSrcMinY, setSrcWidth, setStream, setSubsampleX, setSubsampleY
-
Field Details
-
DEBUG
private static final boolean DEBUG- See Also:
-
isReadActiveOnly
private boolean isReadActiveOnlyWhether to read the active source region only. -
originalSrcMinX
private int originalSrcMinXThe original value ofsrcMinX
. -
originalSrcMinY
private int originalSrcMinYThe original value ofsrcMinY
. -
originalSrcWidth
private int originalSrcWidthThe original value ofsrcWidth
. -
originalSrcHeight
private int originalSrcHeightThe original value ofsrcHeight
.
-
-
Constructor Details
-
TIFFNullDecompressor
public TIFFNullDecompressor()
-
-
Method Details
-
beginDecoding
public void beginDecoding()Description copied from class:TIFFDecompressor
This routine is called prior to a sequence of calls to thedecode
method, in order to allow any necessary tables or other structures to be initialized based on metadata values. This routine is guaranteed to be called any time the metadata values have changed.The default implementation computes tables used by the
decode
method to rescale components to different bit depths. Thus, if this method is overridden, it is important for the subclass method to callsuper()
, unless it overridesdecode
as well.- Overrides:
beginDecoding
in classTIFFDecompressor
-
decode
Description copied from class:TIFFDecompressor
Decodes the input bit stream (located in theImageInputStream
stream
, at offsetoffset
, and continuing forbyteCount
bytes) into the outputBufferedImage
image
.The default implementation analyzes the destination image to determine if it is suitable as the destination for the
decodeRaw
method. If not, a suitable image is created. Next,decodeRaw
is called to perform the actual decoding, and the results are copied into the destination image if necessary. Subsampling and offsetting are performed automatically.The precise responsibilities of this routine are as follows. The input bit stream is defined by the instance variables
stream
,offset
, andbyteCount
. These bits contain the data for the region of the source image defined bysrcMinX
,srcMinY
,srcWidth
, andsrcHeight
.The source data is required to be subsampling, starting at the
sourceXOffset
th column and including everysubsampleX
th pixel thereafter (and similarly forsourceYOffset
andsubsampleY
).Pixels are copied into the destination with an addition shift of (
dstXOffset
,dstYOffset
). The complete set of formulas relating the source and destination coordinate spaces are:dx = (sx - sourceXOffset)/subsampleX + dstXOffset; dy = (sy - sourceYOffset)/subsampleY + dstYOffset;
Only source pixels such that(sx - sourceXOffset) % subsampleX == 0
and(sy - sourceYOffset) % subsampleY == 0
are copied.The inverse mapping, from destination to source coordinates, is one-to-one:
sx = (dx - dstXOffset)*subsampleX + sourceXOffset; sy = (dy - dstYOffset)*subsampleY + sourceYOffset;
The region of the destination image to be updated is given by the instance variables
dstMinX
,dstMinY
,dstWidth
, anddstHeight
.It is possible that not all of the source data being read will contribute to the destination image. For example, the destination offsets could be set such that some of the source pixels land outside of the bounds of the image. As a convenience, the bounds of the active source region (that is, the region of the strip or tile being read that actually contributes to the destination image, taking clipping into account) are available as
activeSrcMinX
,activeSrcMinY
,activeSrcWidth
andactiveSrcHeight
. Thus, the source pixel at (activeSrcMinX
,activeSrcMinY
) will map to the destination pixel (dstMinX
,dstMinY
).The sequence of source bands given by
sourceBands
are to be copied into the sequence of bands in the destination given bydestinationBands
.Some standard tag information is provided the instance variables
photometricInterpretation
,compression
,samplesPerPixel
,bitsPerSample
,sampleFormat
,extraSamples
, andcolorMap
.In practice, unless there is a significant performance advantage to be gained by overriding this routine, most users will prefer to use the default implementation of this routine, and instead override the
decodeRaw
and/orgetRawImageType
methods.- Overrides:
decode
in classTIFFDecompressor
- Throws:
IOException
- if an error occurs indecodeRaw
.
-
decodeRaw
public void decodeRaw(byte[] b, int dstOffset, int bitsPerPixel, int scanlineStride) throws IOException Description copied from class:TIFFDecompressor
Decodes the source data into the providedbyte
arrayb
, starting at the offset given bydstOffset
. Each pixel occupiesbitsPerPixel
bits, with no padding between pixels. Scanlines are separated byscanlineStride
byte
s.- Specified by:
decodeRaw
in classTIFFDecompressor
- Parameters:
b
- abyte
array to be written.dstOffset
- the starting offset inb
to be written.bitsPerPixel
- the number of bits for each pixel.scanlineStride
- the number ofbyte
s to advance between that starting pixels of each scanline.- Throws:
IOException
- if an error occurs reading from the sourceImageInputStream
.
-