Java Reference
In-Depth Information
Figure 11.1 A
BufferedImage object
holds a Raster and
ColorModel . The Raster
in turn holds a
SampleModel and a
DataBuffer with the raw
data array(s).
for reasons of space and speed. Instead raw image data is packed in a primitive
type array or set of arrays and the colors are constructed from the array data
as needed. The internal structure of BufferedImage is shown in Figure 11.1.
It includes a ColorModel object and a Raster object. The Raster in turn
contains SampleModel and Databuffer objects.
The Raster specifies the colors of the individual pixels of an image. It does
this with the help of a DataBuffer that holds one or more raw data arrays
(each array is referred to as a bank ) and a SampleModel subclass that knows
how the pixel data is packed in the DataBuffer . The abstract SampleModel
has several subclasses such as PixelInterleavedSampleModel and
BandedSampleModel that describe particular packing arrangements. The term
sample refers to one of the values that describe a pixel. In RGB color space, for
example, there are three samples - the red sample, the green sample, and the blue
sample - that make up a pixel. The collection of values of a particular sample for
all the pixels is referred to as a band . That is, if you filtered an image to show
only the red values, this would display the red band.
The bands can be arranged in many different ways in the data buffers. For
example, the band arrays could be assembled sequentially with the red array first,
green array second, and blue array last. Or they could be interleaved within a
single array in triplets of samples for each pixel. That is, the first three array
elements hold the red, green, and blue samples for the first pixel and then repeat
for the next pixel until the full image is complete. A binary black and white image
might use just a zero or one for each pixel and be packed as bits in a byte array.
The job of the sample model is to gather the samples for a given pixel and supply
them to the color model.
The ColorModel ,which must be compatible with the sample model, inter-
prets the pixel samples as color components. The ARGB (alpha, red, green, blue)
Search WWH ::




Custom Search