|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.image.ColorModel | +--java.awt.image.PackedColorModel
An abstract ColorModel class that works with pixel values which represent color and alpha information as separate samples and which pack all samples for a single pixel into a single int, short, or byte quantity. This class can be used with an arbitrary ColorSpace. The number of color samples in the pixel values must be same as the number of color components in the ColorSpace. There may be a single alpha sample. For those methods which use a primitive array pixel representation of type transferType, the array length is always one. Color and alpha samples are stored in the single element of the array in bits indicated by bit masks. Each bit mask must be contiguous and masks must not overlap. The same masks apply to the single int pixel representation used by other methods. The correspondence of masks and color/alpha samples is as follows. Masks are identified by indices running from 0 through getNumComponents() - 1. The first getNumColorComponents() indices refer to color samples. If an alpha sample is present, it corresponds the last index. The order of the color indices is specified by the ColorSpace. Typically, this reflects the name of the color space type, e.g. for TYPE_RGB, index 0 corresponds to red, index 1 to green, and index 2 to blue. The transfer types supported are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT.
The translation from pixel values to color/alpha components for display or processing purposes is a one-to-one correspondence of samples to components. A PackedColorModel is typically used with image data which uses masks to define packed samples. For example, a PackedColorModel can be used in conjunction with a SinglePixelPackedSampleModel to construct a BufferedImage. Normally the masks used by the SampleModel and the ColorModel would be the same. However, if they are different, the color interpretation of pixel data will be done according to the masks of the ColorModel.
A single int pixel representation is valid for all objects of this class, since it is always possible to represent pixel values used with this class in a single int. Therefore, methods which use this representation will not throw an IllegalArgumentException due to an invalid pixel value.
A subclass of PackedColorModel is DirectColorModel, which is similar to an X11 TrueColor visual.
DirectColorModel
,
SinglePixelPackedSampleModel
,
BufferedImage
Fields inherited from class java.awt.image.ColorModel |
pixel_bits,
transferType |
Constructor Summary | |
PackedColorModel(ColorSpace space,
int bits,
int[] colorMaskArray,
int alphaMask,
boolean isAlphaPremultiplied,
int trans,
int transferType)
Constructs a PackedColorModel from a color mask array, which specifies which bits in an int pixel representation contain each of the color samples, and an alpha mask. |
|
PackedColorModel(ColorSpace space,
int bits,
int rmask,
int gmask,
int bmask,
int amask,
boolean isAlphaPremultiplied,
int trans,
int transferType)
Constructs a PackedColorModel from the given masks specifying which bits in an int pixel representation contain the alpha, red, green and blue color samples. |
Method Summary | |
SampleModel |
createCompatibleSampleModel(int w,
int h)
Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel. |
boolean |
equals(Object obj)
Tests if the specified Object is an instance
of PackedColorModel and equals this
PackedColorModel . |
WritableRaster |
getAlphaRaster(WritableRaster raster)
Returns a Raster representing the alpha channel of an image, extracted from the input Raster. |
int |
getMask(int index)
Returns the mask indicating which bits in an int pixel representation contain the specified color/alpha sample. |
int[] |
getMasks()
Returns a mask array indicating which bits in an int pixel representation contain the color and alpha samples. |
boolean |
isCompatibleSampleModel(SampleModel sm)
Checks if the SampleModel is compatible with this ColorModel. |
Methods inherited from class java.awt.image.ColorModel |
coerceData,
createCompatibleWritableRaster,
finalize,
getAlpha,
getAlpha,
getBlue,
getBlue,
getColorSpace,
getComponents,
getComponents,
getComponentSize,
getComponentSize,
getDataElement,
getDataElements,
getDataElements,
getGreen,
getGreen,
getNormalizedComponents,
getNumColorComponents,
getNumComponents,
getPixelSize,
getRed,
getRed,
getRGB,
getRGB,
getRGBdefault,
getTransparency,
getUnnormalizedComponents,
hasAlpha,
isAlphaPremultiplied,
isCompatibleRaster,
toString |
Methods inherited from class java.lang.Object |
clone,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public PackedColorModel(ColorSpace space, int bits, int[] colorMaskArray, int alphaMask, boolean isAlphaPremultiplied, int trans, int transferType)
public PackedColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int trans, int transferType)
ColorSpace
Method Detail |
public final int getMask(int index)
alphaIndex = numComponents() - 1;
public final int[] getMasks()
public SampleModel createCompatibleSampleModel(int w, int h)
SampleModel
public boolean isCompatibleSampleModel(SampleModel sm)
SampleModel
public WritableRaster getAlphaRaster(WritableRaster raster)
public boolean equals(Object obj)
Object
is an instance
of PackedColorModel
and equals this
PackedColorModel
.obj
- the Object
to test for equalitytrue
if the specified Object
is an instance of PackedColorModel
and equals this
PackedColorModel
; false
otherwise.
|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |