PackedColorModel class is 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 the same as the number of color
components in the ColorSpace. There can be a single alpha
sample. The array length is always 1 for those methods that use a
primitive array pixel representation of type transferType.
The transfer types supported are DataBuffer.TYPE_BYTE,
DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT.
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:
getNumComponents - 1.
getNumColorComponents
indices refer to color samples.
ColorSpace. Typically, this reflects the name of
the color space type (for example, TYPE_RGB), index 0
corresponds to red, index 1 to green, and index 2 to blue.
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
that 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 is
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
that use this representation do 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
| Modifier and Type | Field and Description |
|---|---|
| private volatile int | |
| pack-priv int[] | |
| pack-priv int[] | |
| pack-priv float[] |
| Access | Constructor and Description |
|---|---|
| public | PackedColorModel(ColorSpace
the specified space, int ColorSpacethe number of bits in the pixel values bits, int[] array that specifies the masks representing
the bits of the pixel values that represent the color
components colorMaskArray, int specifies the mask representing
the bits of the pixel values that represent the alpha
component alphaMask, boolean true if color samples are
premultiplied by the alpha sample; false otherwisespecifies the alpha value that can be represented by
this color model trans, int the type of array used to represent pixel values transferType)Constructs a |
| public | PackedColorModel(ColorSpace
the specified space, int ColorSpacethe number of bits in the pixel values bits, int specifies the mask representing
the bits of the pixel values that represent the red
color component rmask, int specifies the mask representing
the bits of the pixel values that represent the green
color component gmask, int specifies the mask representing
the bits of the pixel values that represent
the blue color component bmask, int specifies the mask representing
the bits of the pixel values that represent
the alpha component amask, boolean true if color samples are
premultiplied by the alpha sample; false otherwisespecifies the alpha value that can be represented by
this color model trans, int the type of array used to represent pixel values transferType)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| private static final int | |
| private static final int[] | |
| private static final int[] | |
| public SampleModel | Returns: the newly createdSampleModel.the width (in pixels) of the region of the image data
described w, int the height (in pixels) of the region of the image data
described h)Overrides java. Creates a |
| private void | |
| public boolean | Returns: true if the specified Object
is an instance of PackedColorModel and equals this
PackedColorModel; false otherwise.the obj)Object to test for equalityOverrides java. Tests if the specified |
| public WritableRaster | Returns: aWritableRaster that represents the alpha
channel of the image contained in raster.a raster)WritableRaster containing an imageOverrides java. Returns a |
| public final int | Returns: the mask, which indicates which bits of theint
pixel representation contain the color or alpha sample specified
by index.the specified color or alpha sample index)Returns the mask indicating which bits in a pixel contain the specified color/alpha sample. |
| public final int[] | Returns: the mask array , which indicates which bits of theint pixel
representation contain the color or alpha samples.Returns a mask array indicating which bits in a pixel contain the color and alpha samples. |
| public int | Returns: a hash code for this PackedColorModel.Overrides java. Returns the hash code for this PackedColorModel. |
| public boolean | Returns: true if the specified SampleModel
is compatible with this ColorModel;
false otherwise.the specified sm)SampleModel,
or nullOverrides java. Checks if the specified |
| hashCode | back to summary |
|---|---|
| private volatile int hashCode | |
| maskArray | back to summary |
|---|---|
| pack-priv int[] maskArray | |
| maskOffsets | back to summary |
|---|---|
| pack-priv int[] maskOffsets | |
| scaleFactors | back to summary |
|---|---|
| pack-priv float[] scaleFactors | |
| PackedColorModel | back to summary |
|---|---|
| public PackedColorModel(ColorSpace space, int bits, int[] colorMaskArray, int alphaMask, boolean isAlphaPremultiplied, int trans, int transferType) Constructs a
| |
| PackedColorModel | back to summary |
|---|---|
| public PackedColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int trans, int transferType) Constructs a
| |
| countBits | back to summary |
|---|---|
| private static final int countBits(int mask) | |
| createBitsArray | back to summary |
|---|---|
| private static final int[] createBitsArray(int[] colorMaskArray, int alphaMask) | |
| createBitsArray | back to summary |
|---|---|
| private static final int[] createBitsArray(int rmask, int gmask, int bmask, int amask) | |
| createCompatibleSampleModel | back to summary |
|---|---|
| public SampleModel createCompatibleSampleModel(int w, int h) Overrides java. Creates a
| |
| DecomposeMask | back to summary |
|---|---|
| private void DecomposeMask(int mask, int idx, String componentName) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Tests if the specified | |
| getAlphaRaster | back to summary |
|---|---|
| public WritableRaster getAlphaRaster(WritableRaster raster) Overrides java. Returns a
| |
| getMask | back to summary |
|---|---|
| public final int getMask(int index) Returns the mask indicating which bits in a pixel
contain the specified color/alpha sample. For color
samples,
alphaIndex = numComponents() - 1;
| |
| getMasks | back to summary |
|---|---|
| public final int[] getMasks() Returns a mask array indicating which bits in a pixel contain the color and alpha samples.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for this PackedColorModel.
| |
| isCompatibleSampleModel | back to summary |
|---|---|
| public boolean isCompatibleSampleModel(SampleModel sm) Overrides java. Checks if the specified
| |