The IndexColorModel
class is a ColorModel
class that works with pixel values consisting of a
single sample that is an index into a fixed colormap in the default
sRGB color space. The colormap specifies red, green, blue, and
optional alpha components corresponding to each index. All components
are represented in the colormap as 8-bit unsigned integral values.
Some constructors allow the caller to specify "holes" in the colormap
by indicating which colormap entries are valid and which represent
unusable colors via the bits set in a BigInteger
object.
This color model is similar to an X11 PseudoColor visual.
Some constructors provide a means to specify an alpha component
for each pixel in the colormap, while others either provide no
such means or, in some cases, a flag to indicate whether the
colormap data contains alpha values. If no alpha is supplied to
the constructor, an opaque alpha component (alpha = 1.0) is
assumed for each entry.
An optional transparent pixel value can be supplied that indicates a
pixel to be made completely transparent, regardless of any alpha
component supplied or assumed for that pixel value.
Note that the color components in the colormap of an
IndexColorModel
objects are never pre-multiplied with
the alpha components.
If an IndexColorModel
object has
a transparency value of Transparency.OPAQUE
,
then the hasAlpha
and getNumComponents
methods
(both inherited from ColorModel
)
return false and 3, respectively.
For any other transparency value,
hasAlpha
returns true
and getNumComponents
returns 4.
The values used to index into the colormap are taken from the least
significant n bits of pixel representations where
n is based on the pixel size specified in the constructor.
For pixel sizes smaller than 8 bits, n is rounded up to a
power of two (3 becomes 4 and 5,6,7 become 8).
For pixel sizes between 8 and 16 bits, n is equal to the
pixel size.
Pixel sizes larger than 16 bits are not supported by this class.
Higher order bits beyond n are ignored in pixel representations.
Index values greater than or equal to the map size, but less than
2n, are undefined and return 0 for all color and
alpha components.
For those methods that use a primitive array pixel representation of
type
Many of the methods in this class are final. The reason for
this is that the underlying native graphics code makes assumptions
about the layout and operation of this class and those assumptions
are reflected in the implementations of the methods here that are
marked final. You can subclass this class for other reasons, but
you cannot override or modify the behaviour of those methods.
extends transferType
, the array length is always one.
The transfer types supported are DataBuffer.TYPE_BYTE
and
DataBuffer.TYPE_USHORT
. 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.
ColorModel, ColorSpace, DataBuffer