The mapping between source and destination Y coordinates is given by the equations:
dx = (sx - sourceXOffset)/subsampleX + dstXOffset; dy = (sy - sourceYOffset)/subsampleY + dstYOffset;Note that the mapping from source coordinates to destination coordinates is not one-to-one if subsampling is being used, since only certain source pixels are to be copied to the destination. However, * the inverse mapping is always one-to-one:
sx = (dx - dstXOffset)*subsampleX + sourceXOffset; sy = (dy - dstYOffset)*subsampleY + sourceYOffset;
Decompressors may be written with various levels of complexity.
The most complex decompressors will override the
decode
method, and will perform all the work of
decoding, subsampling, offsetting, clipping, and format conversion.
This approach may be the most efficient, since it is possible to
avoid the use of extra image buffers, and it may be possible to
avoid decoding portions of the image that will not be copied into
the destination.
Less ambitious decompressors may override the
decodeRaw
method, which is responsible for
decompressing the entire tile or strip into a byte array (or other
appropriate datatype). The default implementation of
decode
will perform all necessary setup of buffers,
call decodeRaw
to perform the actual decoding, perform
subsampling, and copy the results into the final destination image.
Where possible, it will pass the real image buffer to
decodeRaw
in order to avoid making an extra copy.
Slightly more ambitious decompressors may override
decodeRaw
, but avoid writing pixels that will be
discarded in the subsampling phase.
Modifier and Type | Field and Description |
---|---|
protected int | activeSrcHeight
The height of the source region that will actually be copied into the destination image, taking into account all susbampling, offsetting, and clipping. |
protected int | activeSrcMinX
The X coordinate of the upper-left source pixel that will actually be copied into the destination image, taking into account all subsampling, offsetting, and clipping. |
protected int | activeSrcMinY
The Y coordinate of the upper-left source pixel that will actually be copied into the destination image, taking into account all subsampling, offsetting, and clipping. |
protected int | activeSrcWidth
The width of the source region that will actually be copied into the destination image, taking into account all susbampling, offsetting, and clipping. |
private boolean | |
private int[][] | |
protected int[] | bitsPerSample
The value of the |
private int[] | |
protected int | byteCount
The number of bytes of data from the source
|
protected TIFFColorConverter | colorConverter
A |
protected char[] | colorMap
The value of the |
protected int | compression
The value of the |
private int[] | |
protected int[] | destinationBands
The sequence of destination bands to receive the source data. |
private int[] | |
protected int | dstHeight
The height of the region of the destination image to be written. |
protected int | dstMinX
The X coordinate of the upper left pixel to be written in the destination image. |
protected int | dstMinY
The Y coordinate of the upper left pixel to be written in the destination image. |
protected int | dstWidth
The width of the region of the destination image to be written. |
protected int | dstXOffset
The horizontal destination offset used, along with
|
protected int | dstYOffset
The vertical destination offset used, along with
|
protected int[] | extraSamples
The value of the |
protected BufferedImage | image
The final destination image. |
private boolean | |
private boolean | |
private boolean | |
private boolean | |
protected IIOMetadata | metadata
The |
protected long | offset
The offset in the source |
protected int | photometricInterpretation
The value of the |
protected boolean | planar
|
protected int | planarBand
The planar band to decode; ignored for chunky (interleaved) images. |
private boolean | |
protected BufferedImage | rawImage
A |
protected ImageReader | reader
The |
protected int[] | sampleFormat
The value of the |
protected int | samplesPerPixel
The value of the |
protected int[] | sourceBands
The sequence of source bands that are to be copied into the destination. |
private int[] | |
protected int | sourceXOffset
The source X offset used, along with |
protected int | sourceYOffset
The source Y offset used, along with |
protected int | srcHeight
The height of the source region being decoded from the source stream. |
protected int | srcMinX
The X coordinate of the upper-left pixel of the source region being decoded from the source stream. |
protected int | srcMinY
The Y coordinate of the upper-left pixel of the source region being decoded from the source stream. |
protected int | srcWidth
The width of the source region being decoded from the source stream. |
protected ImageInputStream | stream
The |
protected int | subsampleX
The horizontal subsampling factor. |
protected int | subsampleY
The vertical subsampling factor. |
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
private static boolean | |
private static boolean | |
public void | beginDecoding()
This routine is called prior to a sequence of calls to the
|
pack-priv static ColorModel | createComponentCM(ColorSpace colorSpace, int numBands, int[] bitsPerSample, int dataType, boolean hasAlpha, boolean isAlphaPremultiplied)
Create a |
pack-priv static SampleModel | Returns: APixelInterleavedSampleModel .The data type (DataBuffer.TYPE_*). dataType, int The number of bands. numBands)Create a |
private static int | |
public BufferedImage | Returns: aBufferedImage whose underlying data
array has the same format as the raw source pixel data, or
null if it is not possible to create such an
image.Creates a |
public void | decode()
Decodes the input bit stream (located in the
|
public abstract void | decodeRaw(byte[]
a b, int byte array to be written.the starting offset in dstOffset, int b to be
written.the number of bits for each pixel. bitsPerPixel, int the number of scanlineStride)byte s to
advance between that starting pixels of each scanline.Decodes the source data into the provided |
public void | decodeRaw(short[]
a s, int short array to be written.the starting offset in dstOffset, int s to be
written.the number of bits for each pixel. bitsPerPixel, int the number of scanlineStride)short s to
advance between that starting pixels of each scanline.Decodes the source data into the provided |
public void | decodeRaw(int[]
an i, int int array to be written.the starting offset in dstOffset, int i to be
written.the number of bits for each pixel. bitsPerPixel, int the number of scanlineStride)int s to
advance between that starting pixels of each scanline.Decodes the source data into the provided |
public void | decodeRaw(float[]
a f, int float array to be written.the starting offset in dstOffset, int f to be
written.the number of bits for each pixel. bitsPerPixel, int the number of scanlineStride)float s to
advance between that starting pixels of each scanline.Decodes the source data into the provided |
public void | decodeRaw(double[]
a d, int double array to be written.the starting offset in dstOffset, int f to be
written.the number of bits for each pixel. bitsPerPixel, int the number of scanlineStride)double s to
advance between that starting pixels of each scanline.Decodes the source data into the provided |
private static int | |
private static int | |
private static int | getDataTypeSize(int dataType)
Return the number of bits occupied by |
public ImageTypeSpecifier | Returns: anImageTypeSpecifier .Returns an |
public static ImageTypeSpecifier | Returns: a suitableImageTypeSpecifier , or
null if it is not possible to create one.the value of the
photometricInterpretation, int PhotometricInterpretation field.the value of the compression, int Compression field.the value of the
samplesPerPixel, int[] SamplesPerPixel field.the value of the bitsPerSample, int[] BitsPerSample field.the value of the sampleFormat, int[] SampleFormat field.the value of the extraSamples, char[] ExtraSamples field.the value of the colorMap)ColorMap field.A utility method that returns an
|
private static boolean | isDataBufferBitContiguous(SampleModel sm, int[] bitsPerSample)
Determines whether the |
private static void | reformatData(byte[] buf, int bytesPerRow, int numRows, short[] shortData, int[] intData, int outOffset, int outStride)
Reformats data read as bytes into a short or int buffer. |
private static void | reformatDiscontiguousData(byte[] buf, int[] bitsPerSample, int stride, int w, int h, WritableRaster raster)
Reformats bit-discontiguous data into the |
public void | setActiveSrcHeight(int
the height of the active source region. activeSrcHeight)Sets the value of the |
public void | setActiveSrcMinX(int
the minimum X coordinate of the active
source region. activeSrcMinX)Sets the value of the |
public void | setActiveSrcMinY(int
the minimum Y coordinate of the active
source region. activeSrcMinY)Sets the value of the |
public void | setActiveSrcWidth(int
the width of the active source region. activeSrcWidth)Sets the value of the |
public void | setBitsPerSample(int[]
the number of bits for each source image
sample. bitsPerSample)Sets the value of the |
public void | setByteCount(int
the number of bytes of compressed data. byteCount)Sets the value of the |
public void | setColorConverter(TIFFColorConverter
a colorConverter)TIFFColorConverter object, or
null .Sets the |
public void | setColorMap(char[]
the color map to apply to the source data,
as an array of colorMap)char s.Sets the value of the |
public void | |
public void | setDestinationBands(int[]
an array of destinationBands)int s
specifying the destination bands to be written.Sets the value of the |
public void | setDstHeight(int
the height of the destination region. dstHeight)Sets the value of the |
public void | setDstMinX(int
the minimum X coordinate of the destination
region. dstMinX)Sets the value of the |
public void | setDstMinY(int
the minimum Y coordinate of the destination
region. dstMinY)Sets the value of the |
public void | |
public void | setDstXOffset(int
the horizontal destination offset to be
used when mapping between source and destination coordinates. dstXOffset)Sets the value of the |
public void | setDstYOffset(int
the vertical destination offset to be
used when mapping between source and destination coordinates. dstYOffset)Sets the value of the |
public void | setExtraSamples(int[]
the interpretation of any samples in the
source file beyond those used for basic color or grayscale
information. extraSamples)Sets the value of the |
public void | |
public void | setMetadata(IIOMetadata
the metadata)IIOMetadata object for the
image being read.Sets the value of the |
public void | setOffset(long
the offset of the beginning of the compressed
data. offset)Sets the value of the |
public void | setPhotometricInterpretation(int
the photometric interpretation
value. photometricInterpretation)Sets the value of the |
public void | setPlanar(boolean
true if the image to be decoded is
stored in planar format.Sets the value of the |
public void | setPlanarBand(int
the index of the planar band to decode planarBand)Sets the index of the planar configuration band to be decoded. |
public void | |
public void | setSampleFormat(int[]
the format of the source image data,
for example unsigned integer or floating-point. sampleFormat)Sets the value of the |
public void | setSamplesPerPixel(int
the number of samples in each source
pixel. samplesPerPixel)Sets the value of the |
public void | setSourceBands(int[]
an array of sourceBands)int s
specifying the source bands to be read.Sets the value of the |
public void | setSourceXOffset(int
the horizontal source offset to be used when
mapping between source and destination coordinates. sourceXOffset)Sets the value of the |
public void | setSourceYOffset(int
the vertical source offset to be used when
mapping between source and destination coordinates. sourceYOffset)Sets the value of the |
public void | setSrcHeight(int
the height of the source region being decoded,
irrespective of how it will be copied into the destination. srcHeight)Sets the value of the |
public void | setSrcMinX(int
the minimum X coordinate of the source region
being decoded, irrespective of how it will be copied into the
destination. srcMinX)Sets the value of the |
public void | setSrcMinY(int
the minimum Y coordinate of the source region
being decoded, irrespective of how it will be copied into the
destination. srcMinY)Sets the value of the |
public void | setSrcWidth(int
the width of the source region being decoded,
irrespective of how it will be copied into the destination. srcWidth)Sets the value of the |
public void | setStream(ImageInputStream
the stream)ImageInputStream to be read.Sets the value of the |
public void | setSubsampleX(int
the horizontal subsampling factor. subsampleX)Sets the value of the |
public void | setSubsampleY(int
the vertical subsampling factor. subsampleY)Sets the value of the |