| |
|
| java.lang.Object javax.media.jai.RasterAccessor
RasterAccessor | public class RasterAccessor (Code) | | An adapter class for presenting non-binary image data in a
ComponentSampleModel format and binary image data in
a zero-offset byte array format even when the original data are not
so stored. RasterAccessor is meant to make the common
(ComponentSampleModel ) case fast and other formats
possible without forcing the OpImage writer to cover more
than one case per non-binary data type.
When constructing a RasterAccessor with a source(s) that
has an IndexColorModel and a destination that has a
non-IndexColorModel , RasterAccessor will
perform expansion of the source pixels. If the source(s) and the
destination have an IndexColorModel, then RasterAccessor
will assume that the operation can correctly process an IndexColorModel
source and will not expand the source pixels (colormap indices) into
color components. Refer to
JAI.KEY_REPLACE_INDEX_COLOR_MODEL
for a mechanism by which the destination image's ColorModel
is set to a non-IndexColorModel to cause
RasterAccessor to expand the source's
IndexColorModel .
Binary data are handled as a special case. In general image data
are considered to be binary when the image has a single-banded
MultiPixelPackedSampleModel with one bit per pixel. This
may be verified by invoking the isBinary() method. For this
case the methods getBinaryDataArray() and
copyBinaryDataToRaster() should be used to access and set,
respectively, the binary data in packed form. If the binary data are
to be accessed in expanded form, i.e., as bytes, then the usual byte
methods getByteDataArray() , getByteDataArrays() ,
and copyDataToRaster() should be used.
|
Field Summary | |
final public static int | COPIED Flag indicating data is a copy of the raster's data. | final public static int | COPY_MASK The bits of a FormatTag associated with how dataArrays are obtained. | final public static int | DATATYPE_MASK The bits of a FormatTagID associated with pixel datatype. | final public static int | DEFAULTEXPANSION | final public static int | EXPANDED Flag indicating ColorModel data should be interpreted. | final public static int | EXPANSION_MASK The bits of a FormatTag associated with how ColorModels are used. | final public static int | TAG_BYTE_EXPANDED FormatTagID indicating data in byte arrays and expanded. | final public static int | TAG_BYTE_UNCOPIED FormatTagID indicating data in byte arrays and uncopied. | final public static int | TAG_DOUBLE_COPIED FormatTagID indicating data in double arrays and copied. | final public static int | TAG_DOUBLE_UNCOPIED FormatTagID indicating data in double arrays and uncopied. | final public static int | TAG_FLOAT_COPIED FormatTagID indicating data in float arrays and copied. | final public static int | TAG_FLOAT_UNCOPIED FormatTagID indicating data in float arrays and uncopied. | final public static int | TAG_INT_COPIED FormatTagID indicating data in int arrays and copied. | final public static int | TAG_INT_UNCOPIED FormatTagID indicating data in int arrays and uncopied. | final public static int | TAG_SHORT_UNCOPIED FormatTagID indicating data in short arrays and uncopied. | final public static int | TAG_USHORT_UNCOPIED FormatTagID indicating data in unsigned short arrays and uncopied. | final public static int | UNCOPIED Flag indicating data is raster's data. | final public static int | UNEXPANDED | protected int | bandDataOffsets | protected int | bandOffsets | protected byte | binaryDataArray The image data for the binary case. | protected byte | byteDataArrays The image data in a two-dimensional byte array. | protected double | doubleDataArrays The image data in a two-dimensional double array. | protected float | floatDataArrays The image data in a two-dimensional float array. | protected int | formatTagID | protected int | intDataArrays The image data in a two-dimensional int array. | protected int | numBands The number of bands per pixel in the data array. | protected int | pixelStride | protected Raster | raster The raster that is the source of pixel data. | protected int | rectHeight The height of the rectangle this RasterAccessor addresses. | protected int | rectWidth The width of the rectangle this RasterAccessor addresses. | protected int | rectX The x coordinate of upper-left corner of the rectangle this
RasterAccessor addresses. | protected int | rectY The y coordinate of upper-left corner of the rectangle this
RasterAccessor addresses. | protected int | scanlineStride | protected short | shortDataArrays The image data in a two-dimensional short array. |
Constructor Summary | |
public | RasterAccessor(Raster raster, Rectangle rect, RasterFormatTag rft, ColorModel theColorModel) Constructs a RasterAccessor object out of a Raster, Rectangle
and formatTagID returned from RasterFormat.findCompatibleTag().
The RasterFormatTag must agree with the raster's
SampleModel and ColorModel . |
Method Summary | |
public void | clampDataArrays() Clamps data array values to a range that the underlying raster
can deal with. | public void | copyBinaryDataToRaster() For the case of binary data (isBinary() returns
true ), copy the binary data back into the
Raster of the RasterAccessor . | public void | copyDataToRaster() Copies data back into the RasterAccessor's raster. | public static int | findCompatibleTag(SampleModel[] srcSampleModels, SampleModel dstSampleModel) Returns the most efficient FormatTagID that is compatible with
the destination SampleModel and all source SampleModels. | public static RasterFormatTag[] | findCompatibleTags(RenderedImage srcs, RenderedImage dst) Finds the appropriate tags for the constructor, based on the
SampleModel and ColorModel of all the source and destination.
Parameters: srcs - The operations sources; may be null whichis taken to be equivalent to zero sources. Parameters: dst - The operation destination. | public int | getBandOffset(int b) Returns the offset of a specific band's first sample into the
DataBuffer including the DataBuffer's offset. | public int[] | getBandOffsets() Returns the bandDataOffsets into the dataArrays. | public byte[] | getBinaryDataArray() For the case of binary data (isBinary() returns
true ), return the binary data as a packed byte array.
The data will be packed as eight bits per byte with no bit offset,
i.e., the first bit in each image line will be the left-most of the
first byte of the line. | public byte[] | getByteDataArray(int b) Returns the image data as a byte array for a specific band. | public byte[][] | getByteDataArrays() Returns the image data as a byte array. | public Object | getDataArray(int b) Returns the image data as an Object for a specific band. | public int | getDataType() Returns the data type of the RasterAccessor object. | public double[] | getDoubleDataArray(int b) Returns the image data as a double array for a specific band. | public double[][] | getDoubleDataArrays() Returns the image data as a double array. | public float[] | getFloatDataArray(int b) Returns the image data as a float array for a specific band. | public float[][] | getFloatDataArrays() Returns the image data as a float array. | public int | getHeight() Returns the height of the
RasterAccessor's accessible area. | public int[] | getIntDataArray(int b) Returns the image data as an int array for a specific band. | public int[][] | getIntDataArrays() Returns the image data as an int array. | public int | getNumBands() Returns the numBands of the presented area. | public int | getOffsetForBand(int b) Returns the offset of a specified band's sample from any
pixel offset. | public int[] | getOffsetsForBands() Returns the offset of all band's samples from any
pixel offset. | public int | getPixelStride() Returns the pixelStride for the image data. | public int | getScanlineStride() Returns the scanlineStride for the image data. | public short[] | getShortDataArray(int b) Returns the image data as a short array for a specific band. | public short[][] | getShortDataArrays() Returns the image data as a short array. | public int | getWidth() Returns the width of the
RasterAccessor's accessible area. | public int | getX() Returns the x coordinate of the upper-left corner of the
RasterAccessor's accessible area. | public int | getY() Returns the y coordinate of the upper-left corner of the
RasterAccessor's accessible area. | public boolean | isBinary() Whether the RasterAccessor represents binary data. | public boolean | isDataCopy() Returns true if the RasterAccessors's data is copied from it's
raster. | public boolean | needsClamping() Indicates if the RasterAccessor has a larger dynamic range than
the underlying Raster. |
COPIED | final public static int COPIED(Code) | | Flag indicating data is a copy of the raster's data.
|
COPY_MASK | final public static int COPY_MASK(Code) | | The bits of a FormatTag associated with how dataArrays are obtained.
|
DATATYPE_MASK | final public static int DATATYPE_MASK(Code) | | The bits of a FormatTagID associated with pixel datatype.
|
DEFAULTEXPANSION | final public static int DEFAULTEXPANSION(Code) | | Flag indicating ColorModel data should be used only in copied case
|
EXPANDED | final public static int EXPANDED(Code) | | Flag indicating ColorModel data should be interpreted.
|
EXPANSION_MASK | final public static int EXPANSION_MASK(Code) | | The bits of a FormatTag associated with how ColorModels are used.
|
TAG_BYTE_EXPANDED | final public static int TAG_BYTE_EXPANDED(Code) | | FormatTagID indicating data in byte arrays and expanded.
|
TAG_BYTE_UNCOPIED | final public static int TAG_BYTE_UNCOPIED(Code) | | FormatTagID indicating data in byte arrays and uncopied.
|
TAG_DOUBLE_COPIED | final public static int TAG_DOUBLE_COPIED(Code) | | FormatTagID indicating data in double arrays and copied.
|
TAG_DOUBLE_UNCOPIED | final public static int TAG_DOUBLE_UNCOPIED(Code) | | FormatTagID indicating data in double arrays and uncopied.
|
TAG_FLOAT_COPIED | final public static int TAG_FLOAT_COPIED(Code) | | FormatTagID indicating data in float arrays and copied.
|
TAG_FLOAT_UNCOPIED | final public static int TAG_FLOAT_UNCOPIED(Code) | | FormatTagID indicating data in float arrays and uncopied.
|
TAG_INT_COPIED | final public static int TAG_INT_COPIED(Code) | | FormatTagID indicating data in int arrays and copied.
|
TAG_INT_UNCOPIED | final public static int TAG_INT_UNCOPIED(Code) | | FormatTagID indicating data in int arrays and uncopied.
|
TAG_SHORT_UNCOPIED | final public static int TAG_SHORT_UNCOPIED(Code) | | FormatTagID indicating data in short arrays and uncopied.
|
TAG_USHORT_UNCOPIED | final public static int TAG_USHORT_UNCOPIED(Code) | | FormatTagID indicating data in unsigned short arrays and uncopied.
|
UNCOPIED | final public static int UNCOPIED(Code) | | Flag indicating data is raster's data.
|
UNEXPANDED | final public static int UNEXPANDED(Code) | | Flag indicating ColorModel info should be ignored
|
bandDataOffsets | protected int bandDataOffsets(Code) | | The bandOffset + subRasterOffset + DataBufferOffset into each of
the numBand data arrays
|
bandOffsets | protected int bandOffsets(Code) | | Offset from a pixel's offset to a band of that pixel
|
binaryDataArray | protected byte binaryDataArray(Code) | | The image data for the binary case. The data will be packed as
eight bits per byte with no bit offset, i.e., the first bit in each
image line will be the left-most bit of the first byte of the line.
The line stride in bytes will be (int)((rectWidth+7)/8) .
The length of the array will be rectHeight multiplied
by the line stride.
since: JAI 1.1 |
byteDataArrays | protected byte byteDataArrays(Code) | | The image data in a two-dimensional byte array. This
value will be non-null only if getDataType() returns
DataBuffer.TYPE_BYTE. byteDataArrays.length will equal
numBands. Note that often the numBands subArrays will all
point to the same place in memory.
For the case of binary data this variable will not be initialized
until getByteDataArrays() or
getByteDataArray(int b) is invoked.
|
doubleDataArrays | protected double doubleDataArrays(Code) | | The image data in a two-dimensional double array. This
value will be non-null only if getDataType() returns
DataBuffer.TYPE_DOUBLE. doubleDataArrays.length will equal
numBands. Note that often the numBand subArrays will all
point to the same place in memory.
|
floatDataArrays | protected float floatDataArrays(Code) | | The image data in a two-dimensional float array. This
value will be non-null only if getDataType() returns
DataBuffer.TYPE_FLOAT. floatDataArrays.length will equal
numBands. Note that often the numBand subArrays will all
point to the same place in memory.
|
formatTagID | protected int formatTagID(Code) | | Tag indicating the data type of the data and whether it's copied
|
intDataArrays | protected int intDataArrays(Code) | | The image data in a two-dimensional int array. This
value will be non-null only if getDataType() returns
DataBuffer.TYPE_INT. intDataArrays.length will equal
numBands. Note that often the numBands subArrays will all
point to the same place in memory.
|
numBands | protected int numBands(Code) | | The number of bands per pixel in the data array.
|
pixelStride | protected int pixelStride(Code) | | The pixel stride of the image data in each data array
|
raster | protected Raster raster(Code) | | The raster that is the source of pixel data.
|
rectHeight | protected int rectHeight(Code) | | The height of the rectangle this RasterAccessor addresses.
|
rectWidth | protected int rectWidth(Code) | | The width of the rectangle this RasterAccessor addresses.
|
rectX | protected int rectX(Code) | | The x coordinate of upper-left corner of the rectangle this
RasterAccessor addresses.
|
rectY | protected int rectY(Code) | | The y coordinate of upper-left corner of the rectangle this
RasterAccessor addresses.
|
scanlineStride | protected int scanlineStride(Code) | | The scanline stride of the image data in each data array
|
shortDataArrays | protected short shortDataArrays(Code) | | The image data in a two-dimensional short array. This
value will be non-null only if getDataType() returns
DataBuffer.TYPE_USHORT or DataBuffer.TYPE_SHORT.
shortDataArrays.length will equal
numBands. Note that often the numBands subArrays will all
point to the same place in memory.
|
RasterAccessor | public RasterAccessor(Raster raster, Rectangle rect, RasterFormatTag rft, ColorModel theColorModel)(Code) | | Constructs a RasterAccessor object out of a Raster, Rectangle
and formatTagID returned from RasterFormat.findCompatibleTag().
The RasterFormatTag must agree with the raster's
SampleModel and ColorModel . It is best
to obtain the correct tag using the findCompatibleTags
static method.
Parameters: raster - The raster to be accessed Parameters: rect - A Rectangle from the raster to be accessed Parameters: rft - The RasterFormatTag associated with the Raster Parameters: theColorModel - The ColorModel for color components throws: ClassCastException - if the data type ofRasterFormatTag does not agree with the actualdata type of the Raster . throws: IllegalArgumentException - if raster ,rect , or rft is null . throws: IllegalArgumentException - if the Rectangle is not contained within Raster 's bounds. |
clampDataArrays | public void clampDataArrays()(Code) | | Clamps data array values to a range that the underlying raster
can deal with. For example, if the underlying raster stores
data as bytes, but the samples are unpacked into integer arrays by
the RasterAccessor for an operation, the operation will
need to call clampDataArrays() so that the data in the int
arrays is restricted to the range 0..255 before a setPixels()
call is made on the underlying raster. Note that some
operations (for example, lookup) can guarantee that their
results don't need clamping so they can call
RasterAccessor.copyDataToRaster() without first calling this
function.
|
copyBinaryDataToRaster | public void copyBinaryDataToRaster()(Code) | | For the case of binary data (isBinary() returns
true ), copy the binary data back into the
Raster of the RasterAccessor . If
this method is invoked in the non-binary case it does nothing.
Any bit offset in the original SampleModel will be
accounted for.
since: JAI 1.1 |
copyDataToRaster | public void copyDataToRaster()(Code) | | Copies data back into the RasterAccessor's raster. Note that
the data is cast from the intermediate data format to
the raster's format. If clamping is needed, the call
clampDataArrays() method needs to be called before
calling the copyDataToRaster() method.
Note: the raster is expected to be writable - typically a
destination raster - otherwise, a run-time exception will occur.
If the data are binary, then the target bit will be set if
and only if the corresponding byte is non-zero.
|
findCompatibleTag | public static int findCompatibleTag(SampleModel[] srcSampleModels, SampleModel dstSampleModel)(Code) | | Returns the most efficient FormatTagID that is compatible with
the destination SampleModel and all source SampleModels.
Since there is no ColorModel associated with
a SampleModel , this method does not expand the data
buffer as it has no access to the Raster's ColorModel.
|
findCompatibleTags | public static RasterFormatTag[] findCompatibleTags(RenderedImage srcs, RenderedImage dst)(Code) | | Finds the appropriate tags for the constructor, based on the
SampleModel and ColorModel of all the source and destination.
Parameters: srcs - The operations sources; may be null whichis taken to be equivalent to zero sources. Parameters: dst - The operation destination. An array containing RasterFormatTag s for thesources in the first src.length elements and aRasterFormatTag for the destination in the last element. throws: NullPointerException - if dst is null . |
getBandOffset | public int getBandOffset(int b)(Code) | | Returns the offset of a specific band's first sample into the
DataBuffer including the DataBuffer's offset.
|
getBandOffsets | public int[] getBandOffsets()(Code) | | Returns the bandDataOffsets into the dataArrays.
|
getBinaryDataArray | public byte[] getBinaryDataArray()(Code) | | For the case of binary data (isBinary() returns
true ), return the binary data as a packed byte array.
The data will be packed as eight bits per byte with no bit offset,
i.e., the first bit in each image line will be the left-most of the
first byte of the line. The line stride in bytes will be
(int)((getWidth()+7)/8) . The length of the returned
array will be the line stride multiplied by getHeight()
the binary data as a packed array of bytes with zero offsetof null if the data are not binary. since: JAI 1.1 |
getByteDataArray | public byte[] getByteDataArray(int b)(Code) | | Returns the image data as a byte array for a specific band.
Non-null only if getDataType = DataBuffer.TYPE_BYTE.
|
getByteDataArrays | public byte[][] getByteDataArrays()(Code) | | Returns the image data as a byte array. Non-null only if
getDataType = DataBuffer.TYPE_BYTE.
For the case of binary data the corresponding instance variable
byteDataArrays will not be initialized until this
method or getByteDataArray(int b) is invoked. The
binary data will be returned as bytes with value 0 or 1.
|
getDataArray | public Object getDataArray(int b)(Code) | | Returns the image data as an Object for a specific band.
Parameters: b - The index of the image band of interest. |
getDataType | public int getDataType()(Code) | | Returns the data type of the RasterAccessor object. Note that
this datatype is not necessarily the same data type as the
underlying raster.
|
getDoubleDataArray | public double[] getDoubleDataArray(int b)(Code) | | Returns the image data as a double array for a specific band.
Non-null only if getDataType = DataBuffer.TYPE_DOUBLE
|
getDoubleDataArrays | public double[][] getDoubleDataArrays()(Code) | | Returns the image data as a double array. Non-null only if
getDataType = DataBuffer.TYPE_DOUBLE
|
getFloatDataArray | public float[] getFloatDataArray(int b)(Code) | | Returns the image data as a float array for a specific band.
Non-null only if getDataType = DataBuffer.TYPE_FLOAT.
|
getFloatDataArrays | public float[][] getFloatDataArrays()(Code) | | Returns the image data as a float array. Non-null only if
getDataType = DataBuffer.TYPE_FLOAT.
|
getHeight | public int getHeight()(Code) | | Returns the height of the
RasterAccessor's accessible area.
|
getIntDataArray | public int[] getIntDataArray(int b)(Code) | | Returns the image data as an int array for a specific band.
Non-null only if getDataType = DataBuffer.TYPE_INT.
|
getIntDataArrays | public int[][] getIntDataArrays()(Code) | | Returns the image data as an int array. Non-null only if
getDataType = DataBuffer.TYPE_INT.
|
getNumBands | public int getNumBands()(Code) | | Returns the numBands of the presented area.
|
getOffsetForBand | public int getOffsetForBand(int b)(Code) | | Returns the offset of a specified band's sample from any
pixel offset.
|
getOffsetsForBands | public int[] getOffsetsForBands()(Code) | | Returns the offset of all band's samples from any
pixel offset.
|
getPixelStride | public int getPixelStride()(Code) | | Returns the pixelStride for the image data.
|
getScanlineStride | public int getScanlineStride()(Code) | | Returns the scanlineStride for the image data.
For binary data this stride is applies to the arrays returned by
getByteDataArray() and getByteDataArrays()
if the data are accessed as bytes; it does not apply to the array
returned by getBinaryDataArray() when the data are
accessed as bits packed into bytes.
|
getShortDataArray | public short[] getShortDataArray(int b)(Code) | | Returns the image data as a short array for a specific band.
Non-null only if getDataType = DataBuffer.TYPE_USHORT or
DataBuffer.TYPE_SHORT.
|
getShortDataArrays | public short[][] getShortDataArrays()(Code) | | Returns the image data as a short array. Non-null only if
getDataType = DataBuffer.TYPE_USHORT or DataBuffer.TYPE_SHORT.
|
getWidth | public int getWidth()(Code) | | Returns the width of the
RasterAccessor's accessible area.
|
getX | public int getX()(Code) | | Returns the x coordinate of the upper-left corner of the
RasterAccessor's accessible area.
|
getY | public int getY()(Code) | | Returns the y coordinate of the upper-left corner of the
RasterAccessor's accessible area.
|
isBinary | public boolean isBinary()(Code) | | Whether the RasterAccessor represents binary data.
This occurs when the Raster has a
MultiPixelPackedSampleModel with a single band and
one bit per pixel.
since: JAI 1.1 |
isDataCopy | public boolean isDataCopy()(Code) | | Returns true if the RasterAccessors's data is copied from it's
raster.
|
needsClamping | public boolean needsClamping()(Code) | | Indicates if the RasterAccessor has a larger dynamic range than
the underlying Raster. Except in special cases, where the op
knows something special, this call will determine whether or
not clampDataArrays() needs to be called.
|
|
|
|