RenderedImage
's Raster
s, as well as performing pixel-to-color data translation based on the image's SampleModel
and ColorModel
. It also provides several static methods to determine information about the image data. This class is intended to help classes that need to access the pixel and/or color data of a RenderedImage
, such as an OpImage
, in an optimized fashion. Most of the variables defined in this class are public so that other classes may use them directly. However, the variables are also declared final
so that other classes can not modify their values.
In general, the pixel data of a RenderedImage
may be obtained by calling the getPixels()
method. By definition, the pixel data of an image are the data described by the image's SampleModel
and stored in the image's Raster
s. No consideration of any kind is given to the image's ColorModel
. If no error is found, the pixel data are returned in the primitive arrays of the type specified by the caller in an unpacked format, along with access information. Therefore, the specified data type must be one of the valid types defined in DataBuffer
and large enough (in bit depth) to hold the pixel data of the image.
The pixel data of a binary image may be obtained in a packed format by calling the getPackedPixels()
method. It returns the data in a packed byte
array, with 8 pixels packed into 1 byte. The format of the data in the array is similar to the format described by the MultiPixelPackedSampleModel
, where the end of each scanline is padded to the end of the byte if necessary. Note that this method returns a valid result only if and only if the image is a single-band bit image, that is, each pixel has only 1 sample with a sample size of 1 bit.
Two corresponding "set" methods are also provided for setting the computed pixel data back into the Raster
's DataBuffer
: setPixels()
for unpacked data, and setPackedPixels()
for packed data. It is very important that the caller uses the correct "set" method that matches the "get" method used to obtain the data, or errors will occur.
The color/alpha data of the RenderedImage
may be obtained by calling the getComponents()
method which returns the unnormalized data in the ColorSpace
specified in the ColorModel
, or the getComponentsRGB()
method which returns the data scaled from 0 to 255 in the default sRGB ColorSpace
. These methods retrieve the pixel data from the Raster
, and perform the pixel-to-color translation. Therefore, in order for these two methods to return a valid result, the image must have a valid ColorModel
.
Similarly, two "set" methods may be used to perform the color-to-pixel translation, and set the pixel data back to the Raster
's DataBuffer
. Again, it is important that the "get" and "set" methods are matched up correctly.
In addition, several static methods are included in this class for the convenience of OpImage
developers, who may use them to help determine the appropriate destination SampleModel
type.
@since JAI 1.1
|
|
|
|
|
|
|
|
|
|