public abstract class XTIFFTileCodecImpl extends java.lang.Object implements XTIFFTileCodec
At the minimum you will need to implement the two methods decodeTilePixels() for byte and short data, as well as the methods register() and create(). If your decoder requires additional parameters from the tags, set them up in initializeDecoding(), and initializeEncoding() for encoding.
To implement encoding, you must override the canEncode() method to return true, and implement encodeTilePixels().
XTIFFTileCodec
Modifier and Type | Field and Description |
---|---|
protected byte[] |
_bdata |
protected short[] |
_sdata |
protected char[] |
bitsPerSample |
protected byte[] |
bpixvals |
protected java.awt.image.DataBuffer |
buffer |
protected char[] |
colormap |
protected int |
compression |
protected int |
dataType |
protected boolean |
decodePaletteAsShorts |
protected XTIFFDecodeParam |
decodeParam |
protected XTIFFDirectory |
directory |
protected XTIFFEncodeParam |
encodeParam |
protected java.awt.image.RenderedImage |
image |
protected int |
image_type |
protected boolean |
isTiled |
protected int |
length |
protected int |
minX |
protected int |
minY |
protected int |
numBands |
protected java.awt.image.SampleModel |
sampleModel |
protected int[] |
sampleSize |
protected short[] |
spixvals |
protected int |
tileLength |
protected int |
tileWidth |
protected int |
unitsInThisTile |
protected int |
width |
Constructor and Description |
---|
XTIFFTileCodecImpl()
The empty constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canEncode()
Indicate whether this codec can encode data.
|
abstract XTIFFTileCodec |
create()
Implement this to return the corresponding empty
codec object.
|
XTIFFTileCodec |
create(XTIFFDecodeParam param)
The standard decoder creation method
|
XTIFFTileCodec |
create(XTIFFEncodeParam param)
The method for creating an encoder from
the XTIFFEncodeParam information.
|
java.awt.image.WritableRaster |
decode(java.awt.image.RenderedImage img,
java.awt.Rectangle newRect,
byte[] bpixels)
Decode a rectangle of data stored in bpixels
into a raster tile.
|
protected void |
decodeColor(byte[] bpix,
byte[] bdata,
java.awt.Rectangle newRect)
Decode byte color data
|
protected void |
decodeColor(byte[] bpix,
short[] sdata,
java.awt.Rectangle newRect)
Decode short pixel data, or interpret palette data
as short from byte.
|
protected void |
decodeColor(java.awt.Rectangle newRect)
Postprocess the uncompressed color data into
the appropriate display color model.
|
protected void |
decodeColor(short[] spix,
short[] sdata,
java.awt.Rectangle newRect)
Decode short color data, or interpret palette data
as short.
|
protected void |
decodeTilePixels(byte[] bpixels,
java.awt.Rectangle newRect)
Decode a tile of data into either byte or short pixel buffers.
|
abstract void |
decodeTilePixels(byte[] bpixels,
java.awt.Rectangle rect,
byte[] pixels)
decode bpixel byte array of data into pixels, packed
for 1,2,4 8 bit pixels.
|
abstract void |
decodeTilePixels(byte[] bpixels,
java.awt.Rectangle rect,
short[] pixels)
decode bpixel byte array of data into pixels, packed
for 16 bit pixels.
|
int |
encode(java.awt.image.RenderedImage img,
java.awt.Rectangle rect,
byte[] bpixels)
Encode the data into buffer and return byte count
Normally you will not need to override this method,
but instead implement the
encodeTilePixels() method. |
int |
encodeTilePixels(int[] pixels,
java.awt.Rectangle rect,
byte[] bpixels)
encode the tile in pixels into bpixels and return the byte
size of the compressed data.
|
int |
getCompressedTileSize(java.awt.image.RenderedImage im)
If derived classes can make a better estimate
for the maximum size of a compressed tile,
they should override this, which assumes
conservatively that it won't be worse than
twice the original size.
|
int |
getCompression()
Returns the TIFF compression type
|
protected long |
getLongField(int fld)
A common utility method for accessing the XTIFFFields
in the current image directory.
|
protected void |
getTilePixels(java.awt.Rectangle rect)
Get the portion of tile fitting into buffer.
|
void |
initialize()
The method for initializing information common
to both encoder and decoder.
|
protected void |
initialize(XTIFFDecodeParam param) |
protected void |
initialize(XTIFFEncodeParam param) |
void |
initializeDecoding()
The initialization method particular to decoding.
|
void |
initializeEncoding()
The initialization method particular to encoding.
|
abstract void |
register()
Registration method.
|
void |
register(int comp)
This method may be used by the implementations register()
method to register itself with the XTIFFDirectory.
|
protected java.awt.image.WritableRaster |
setTilePixels(java.awt.Rectangle rect)
Take the values from the buffer and store them in
a WritableRaster object.
|
protected void |
setupBufferForDecoding()
One-time setup for encoding.
|
protected void |
setupBufferForEncoding()
One-time setup for encoding
|
protected void |
setupSourceImage(java.awt.image.RenderedImage img)
One-time common image parameter setup
|
protected void |
unpackShorts(byte[] byteArray,
short[] output,
int shortCount)
A useful Method to interpret a byte array as shorts.
|
protected XTIFFDirectory directory
protected java.awt.image.RenderedImage image
protected int minY
protected int minX
protected int width
protected int length
protected int numBands
protected int tileLength
protected int tileWidth
protected int compression
protected java.awt.image.SampleModel sampleModel
protected int[] sampleSize
protected char[] bitsPerSample
protected char[] colormap
protected XTIFFEncodeParam encodeParam
protected boolean isTiled
protected XTIFFDecodeParam decodeParam
protected boolean decodePaletteAsShorts
protected int unitsInThisTile
protected byte[] _bdata
protected short[] _sdata
protected byte[] bpixvals
protected short[] spixvals
protected java.awt.image.DataBuffer buffer
protected int dataType
protected int image_type
public abstract void register()
register
in interface XTIFFTileCodec
XTIFFDirectory
public abstract XTIFFTileCodec create()
public boolean canEncode()
public void initializeDecoding()
public void initializeEncoding()
public abstract void decodeTilePixels(byte[] bpixels, java.awt.Rectangle rect, byte[] pixels)
bpixels
- the byte array of compressed input datarect
- the rectangular shape of the target pixelspixels
- the target decompressed pixels.public abstract void decodeTilePixels(byte[] bpixels, java.awt.Rectangle rect, short[] pixels)
bpixels
- the byte array of compressed input datarect
- the rectangular shape of the target pixelspixels
- the target decompressed pixels.public int encodeTilePixels(int[] pixels, java.awt.Rectangle rect, byte[] bpixels)
pixels
- input pixelsrect
- the array dimensions of samplesbpixels
- the target array of compressed byte datapublic void initialize()
protected long getLongField(int fld)
public void register(int comp)
XTIFFDirectory
protected void setupSourceImage(java.awt.image.RenderedImage img)
img
- the source image that will be
encoded into a TIFF formatted stream, or
the TIFF image from which Raster tiles
will be decoded.public int getCompression()
getCompression
in interface XTIFFTileCodec
public XTIFFTileCodec create(XTIFFEncodeParam param) throws java.io.IOException
create
in interface XTIFFTileCodec
param
- the encoding parameter. It is the responsibility
of the codec to initialize itself from this parameter.java.io.IOException
protected void initialize(XTIFFEncodeParam param) throws java.io.IOException
java.io.IOException
public int encode(java.awt.image.RenderedImage img, java.awt.Rectangle rect, byte[] bpixels)
encodeTilePixels()
method.encode
in interface XTIFFTileCodec
protected void setupBufferForEncoding()
protected void getTilePixels(java.awt.Rectangle rect)
rect
- the region to extract from image.public int getCompressedTileSize(java.awt.image.RenderedImage im)
getCompressedTileSize
in interface XTIFFTileCodec
im
- the rendered image containing the image datapublic XTIFFTileCodec create(XTIFFDecodeParam param) throws java.io.IOException
create
in interface XTIFFTileCodec
param
- the decoding parameter. It is the responsibility
of the codec to initialize itself from this parameter.java.io.IOException
protected void initialize(XTIFFDecodeParam param) throws java.io.IOException
java.io.IOException
protected void setupBufferForDecoding()
public java.awt.image.WritableRaster decode(java.awt.image.RenderedImage img, java.awt.Rectangle newRect, byte[] bpixels)
decode
in interface XTIFFTileCodec
protected void decodeColor(java.awt.Rectangle newRect)
XTIFFDecodeParam
protected void decodeTilePixels(byte[] bpixels, java.awt.Rectangle newRect)
protected java.awt.image.WritableRaster setTilePixels(java.awt.Rectangle rect)
protected void unpackShorts(byte[] byteArray, short[] output, int shortCount)
protected void decodeColor(byte[] bpix, short[] sdata, java.awt.Rectangle newRect)
protected void decodeColor(short[] spix, short[] sdata, java.awt.Rectangle newRect)
protected void decodeColor(byte[] bpix, byte[] bdata, java.awt.Rectangle newRect)