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.
For those methods that use a primitive array pixel representation of
type 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.
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.
ColorModel, ColorSpace, DataBuffer
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private static int[] | |
| private static final int | |
| private BufImgSurfaceData. | |
| private volatile int | |
| private int[] | |
| private int | |
| private static int[] | |
| private int | |
| private int[] | |
| private int | |
| private BigInteger |
| Access | Constructor and Description |
|---|---|
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, byte[] the array of red color components r, byte[] the array of green color components g, byte[] the array of blue color components b)Constructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, byte[] the array of red color components r, byte[] the array of green color components g, byte[] the array of blue color components b, int the index of the transparent pixel trans)Constructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, byte[] the array of red color components r, byte[] the array of green color components g, byte[] the array of blue color components b, byte[] the array of alpha value components a)Constructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, byte[] the array of color components cmap, int the starting offset of the first color component start, boolean indicates whether alpha values are contained in
the hasalpha)cmap arrayConstructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, byte[] the array of color components cmap, int the starting offset of the first color component start, boolean indicates whether alpha values are contained in
the hasalpha, int cmap arraythe index of the fully transparent pixel trans)Constructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component arrays size, int[] the array of color components cmap, int the starting offset of the first color component start, boolean indicates whether alpha values are contained in
the hasalpha, int cmap arraythe index of the fully transparent pixel trans, int the data type of the array used to represent
pixel values. The data type must be either
transferType)DataBuffer.TYPE_BYTE or
DataBuffer.TYPE_USHORT.Constructs an |
| public | IndexColorModel(int
the number of bits each pixel occupies bits, int the size of the color component array size, int[] the array of color components cmap, int the starting offset of the first color component start, int the specified data type transferType, BigInteger a validBits)BigInteger object. If a bit is
set in the BigInteger, the pixel at that index is valid.
If a bit is not set, the pixel at that index
is considered invalid. If null, all pixels are valid.
Only bits from 0 to the map size are considered.Constructs an |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| private void | calculatePixelMask()
This method is called from the constructors to set the pixel_mask value, which is based on the value of pixel_bits. |
| public BufferedImage | Returns: aBufferedImage created with the specified
Rasterthe specified raster, boolean Rasterif forceARGB)true, the returned
BufferedImage is TYPE_INT_ARGB; otherwise it is
TYPE_INT_RGBReturns a new |
| public SampleModel | Returns: aSampleModel object with the specified
width and height.the width to apply to the new w, int SampleModelthe height to apply to the new h)SampleModelOverrides java. Creates a |
| public WritableRaster | Returns: aWritableRaster object with the specified
width and height.the width to apply to the new w, int WritableRasterthe height to apply to the new h)WritableRasterOverrides java. Creates a |
| public boolean | Returns: true if the specified Object
equals this IndexColorModel; false otherwise.the obj)Object to test for equalityOverrides java. Tests if the specified |
| private BigInteger | |
| public final int | Returns: the value of the alpha component for the specified pixelthe specified pixel pixel)Implements abstract java. Returns the alpha component for the specified pixel, scaled from 0 to 255. |
| public final void | getAlphas(byte[]
the specified array into which the elements of the
array of alpha components are copied a)Copies the array of alpha transparency components into the specified array. |
| public final int | Returns: the value of the blue color component for the specified pixelthe specified pixel pixel)Implements abstract java. Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public final void | getBlues(byte[]
the specified array into which the elements of the
array of blue color components are copied b)Copies the array of blue color components into the specified array. |
| public int[] | Returns: an array containing the color and alpha components of the specified pixel starting at the specified offset.the specified pixel pixel, int[] the array to receive the color and alpha
components of the specified pixel components, int the offset into the offset)components array at
which to start storing the color and alpha componentsOverrides java. Returns an array of unnormalized color/alpha components for a
specified pixel in this |
| public int[] | Returns: an array containing the color and alpha components of the specified pixel starting at the specified offset.the specified pixel pixel, int[] an array that receives the color and alpha
components of the specified pixel components, int the index into the offset)components array at
which to begin storing the color and alpha components of the
specified pixelOverrides java. Returns an array of unnormalized color/alpha components for
a specified pixel in this |
| public int[] | Returns: an array containing the number of bits of each color and alpha component of thisIndexColorModelOverrides java. Returns an array of the number of bits for each color/alpha component. |
| public int | Returns: anint pixel value in this
ColorModel corresponding to the specified components.an array of unnormalized color and alpha
components components, int the index into offset)components at which to
begin retrieving the color and alpha componentsOverrides java. Returns a pixel value represented as an int in this
|
| public synchronized Object | Returns: an array representation of the specified pixel in thisIndexColorModel.the integer pixel representation in the default RGB
color model rgb, Object the specified pixel pixel)Overrides java. Returns a data element array representation of a pixel in this ColorModel, given an integer pixel representation in the default RGB color model. |
| public Object | Returns: anObject representing an array of color and
alpha components.an array of unnormalized color and alpha
components components, int the index into offset, Object components at which to
begin retrieving color and alpha componentsthe pixel)Object representing an array of color
and alpha componentsOverrides java. Returns a data element array representation of a pixel in this
|
| public final int | Returns: the value of the green color component for the specified pixelthe specified pixel pixel)Implements abstract java. Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public final void | getGreens(byte[]
the specified array into which the elements of the
array of green color components are copied g)Copies the array of green color components into the specified array. |
| public final int | Returns: the size of the color and alpha component arrays.Returns the size of the color/alpha component arrays in this
|
| public final int | Returns: the value of the red color component for the specified pixelthe specified pixel pixel)Implements abstract java. Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public final void | getReds(byte[]
the specified array into which the elements of the
array of red color components are copied r)Copies the array of red color components into the specified array. |
| public final int | Returns: the color and alpha components of the specified pixelthe specified pixel pixel)Overrides java. Returns the color/alpha components of the pixel in the default RGB color model format. |
| public final void | getRGBs(int[]
the specified array into which the converted ARGB
values from this array of color and alpha components
are copied. rgb)Converts data for each index from the color and alpha component arrays to an int in the default RGB ColorModel format and copies the resulting 32-bit ARGB values into the specified array. |
| public int | Returns: the transparency of thisIndexColorModelOverrides java. Implements java. Returns the transparency. |
| public final int | Returns: the index of a transparent pixel in thisIndexColorModel object, or -1 if there
is no such pixelReturns the index of a transparent pixel in this
|
| public BigInteger | Returns: aBigInteger indicating the valid/invalid pixels.Returns a |
| public int | Returns: a hash code for IndexColorModelOverrides java. Returns the hash code for IndexColorModel. |
| private static native void | |
| private Object | |
| public boolean | Returns: true if raster is compatible
with this ColorModel; false otherwise.the raster)Raster object to test for compatibilityOverrides java. Returns |
| 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 |
| public boolean | Returns: true if pixel
is valid; false otherwise.the specified pixel value pixel)Returns whether or not the pixel is valid. |
| public boolean | Returns: true if all pixels are valid;
false otherwise.Returns whether or not all of the pixels are valid. |
| private void | |
| private void | |
| private void | |
| private void | |
| public String | Returns: aString representing the contents of this
ColorModel object.Overrides java. Returns the |
| allgrayopaque | back to summary |
|---|---|
| private boolean allgrayopaque | |
| alphaBits | back to summary |
|---|---|
| private static int[] alphaBits | |
| CACHESIZE | back to summary |
|---|---|
| private static final int CACHESIZE | |
| colorData | back to summary |
|---|---|
| private BufImgSurfaceData. | |
| hashCode | back to summary |
|---|---|
| private volatile int hashCode | |
| lookupcache | back to summary |
|---|---|
| private int[] lookupcache | |
| map_size | back to summary |
|---|---|
| private int map_size | |
| opaqueBits | back to summary |
|---|---|
| private static int[] opaqueBits | |
| pixel_mask | back to summary |
|---|---|
| private int pixel_mask | |
| rgb | back to summary |
|---|---|
| private int[] rgb | |
| transparent_index | back to summary |
|---|---|
| private int transparent_index | |
| validBits | back to summary |
|---|---|
| private BigInteger validBits | |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, int trans) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, byte[] a) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha, int trans) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, int[] cmap, int start, boolean hasalpha, int trans, int transferType) Constructs an
| |
| IndexColorModel | back to summary |
|---|---|
| public IndexColorModel(int bits, int size, int[] cmap, int start, int transferType, BigInteger validBits) Constructs an
| |
| calcRealMapSize | back to summary |
|---|---|
| private int calcRealMapSize(int bits, int size) | |
| calculatePixelMask | back to summary |
|---|---|
| private void calculatePixelMask() This method is called from the constructors to set the pixel_mask value, which is based on the value of pixel_bits. The pixel_mask value is used to mask off the pixel parameters for methods such as getRed(), getGreen(), getBlue(), getAlpha(), and getRGB(). | |
| convertToIntDiscrete | back to summary |
|---|---|
| public BufferedImage convertToIntDiscrete(Raster raster, boolean forceARGB) Returns a new
| |
| createCompatibleSampleModel | back to summary |
|---|---|
| public SampleModel createCompatibleSampleModel(int w, int h) Overrides java. Creates a
| |
| createCompatibleWritableRaster | back to summary |
|---|---|
| public WritableRaster createCompatibleWritableRaster(int w, int h) Overrides java. Creates a
Since
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Tests if the specified | |
| getAllValid | back to summary |
|---|---|
| private BigInteger getAllValid() | |
| getAlpha | back to summary |
|---|---|
| public final int getAlpha(int pixel) Implements abstract java. Returns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified as an int. Only the lower n bits of the pixel value, as specified in the class description above, are used to calculate the returned value.
| |
| getAlphas | back to summary |
|---|---|
| public final void getAlphas(byte[] a) Copies the array of alpha transparency components into the
specified array. Only the initial entries of the array as specified
by
| |
| getBlue | back to summary |
|---|---|
| public final int getBlue(int pixel) Implements abstract java. Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. Only the lower n bits of the pixel value, as specified in the class description above, are used to calculate the returned value. The returned value is a non pre-multiplied value.
| |
| getBlues | back to summary |
|---|---|
| public final void getBlues(byte[] b) Copies the array of blue color components into the specified array.
Only the initial entries of the array as specified by
| |
| getComponents | back to summary |
|---|---|
| public int[] getComponents(int pixel, int[] components, int offset) Overrides java. Returns an array of unnormalized color/alpha components for a
specified pixel in this
| |
| getComponents | back to summary |
|---|---|
| public int[] getComponents(Object pixel, int[] components, int offset) Overrides java. Returns an array of unnormalized color/alpha components for
a specified pixel in this
Since
| |
| getComponentSize | back to summary |
|---|---|
| public int[] getComponentSize() Overrides java. Returns an array of the number of bits for each color/alpha component. The array contains the color components in the order red, green, blue, followed by the alpha component, if present.
| |
| getDataElement | back to summary |
|---|---|
| public int getDataElement(int[] components, int offset) Overrides java. Returns a pixel value represented as an int in this
| |
| getDataElements | back to summary |
|---|---|
| public synchronized Object getDataElements(int rgb, Object pixel) Overrides java. Returns a data element array representation of a pixel in this
ColorModel, given an integer pixel representation in the
default RGB color model. This array can then be passed to the
Since
| |
| getDataElements | back to summary |
|---|---|
| public Object getDataElements(int[] components, int offset, Object pixel) Overrides java. Returns a data element array representation of a pixel in this
Since
| |
| getGreen | back to summary |
|---|---|
| public final int getGreen(int pixel) Implements abstract java. Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. Only the lower n bits of the pixel value, as specified in the class description above, are used to calculate the returned value. The returned value is a non pre-multiplied value.
| |
| getGreens | back to summary |
|---|---|
| public final void getGreens(byte[] g) Copies the array of green color components into the specified array.
Only the initial entries of the array as specified by
| |
| getMapSize | back to summary |
|---|---|
| public final int getMapSize() Returns the size of the color/alpha component arrays in this
| |
| getRed | back to summary |
|---|---|
| public final int getRed(int pixel) Implements abstract java. Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. The pixel value is specified as an int. Only the lower n bits of the pixel value, as specified in the class description above, are used to calculate the returned value. The returned value is a non pre-multiplied value.
| |
| getReds | back to summary |
|---|---|
| public final void getReds(byte[] r) Copies the array of red color components into the specified array.
Only the initial entries of the array as specified by
| |
| getRGB | back to summary |
|---|---|
| public final int getRGB(int pixel) Overrides java. Returns the color/alpha components of the pixel in the default RGB color model format. The pixel value is specified as an int. Only the lower n bits of the pixel value, as specified in the class description above, are used to calculate the returned value. The returned value is in a non pre-multiplied format.
| |
| getRGBs | back to summary |
|---|---|
| public final void getRGBs(int[] rgb) Converts data for each index from the color and alpha component
arrays to an int in the default RGB ColorModel format and copies
the resulting 32-bit ARGB values into the specified array. Only
the initial entries of the array as specified by
| |
| getTransparency | back to summary |
|---|---|
| public int getTransparency() Overrides java. Implements java. Returns the transparency. Returns either OPAQUE, BITMASK, or TRANSLUCENT
| |
| getTransparentPixel | back to summary |
|---|---|
| public final int getTransparentPixel() Returns the index of a transparent pixel in this
| |
| getValidPixels | back to summary |
|---|---|
| public BigInteger getValidPixels() Returns a
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for IndexColorModel.
| |
| initIDs | back to summary |
|---|---|
| private static native void initIDs() | |
| installpixel | back to summary |
|---|---|
| private Object installpixel(Object pixel, int pix) | |
| isCompatibleRaster | back to summary |
|---|---|
| public boolean isCompatibleRaster(Raster raster) Overrides java. Returns | |
| isCompatibleSampleModel | back to summary |
|---|---|
| public boolean isCompatibleSampleModel(SampleModel sm) Overrides java. Checks if the specified
| |
| isValid | back to summary |
|---|---|
| public boolean isValid(int pixel) Returns whether or not the pixel is valid.
| |
| isValid | back to summary |
|---|---|
| public boolean isValid() Returns whether or not all of the pixels are valid.
| |
| setRGBs | back to summary |
|---|---|
| private void setRGBs(int size, byte[] r, byte[] g, byte[] b, byte[] a) | |
| setRGBs | back to summary |
|---|---|
| private void setRGBs(int size, int[] cmap, int start, boolean hasalpha) | |
| setTransparency | back to summary |
|---|---|
| private void setTransparency(int transparency) | |
| setTransparentPixel | back to summary |
|---|---|
| private void setTransparentPixel(int trans) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns the
| |