|
PDAP Public Review Draft | ||||||||
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.IndexColorModel
The IndexColorModel
class is a ColorModel
class that works with pixel values consisting of a
single sample which is an index into a fixed colormap in the default
sRGB. 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. If
alpha is not present, an opaque alpha component (alpha = 1.0) is
assumed for each entry. An optional transparent
pixel value can be supplied that indicates a completely transparent
pixel, regardless of any alpha component recorded for that pixel value.
Note that alpha values in IndexColorModel
objects are
never premultiplied.
This color model is similar to an X11 PseudoColor visual.
The index represented by a pixel value is stored in the least
significant n bits of the pixel representations passed to the
methods of this class, where n is the pixel size specified to the
constructor for a particular IndexColorModel
object
and n must be between 1 and 16.
Higher order bits in pixel representations are assumed to be zero.
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 reaons, but you cannot override or modify the behaviour of those methods.
ColorModel
Fields inherited from class java.awt.image.ColorModel |
pixel_bits |
Constructor Summary | |
IndexColorModel(int bits,
int size,
byte[] r,
byte[] g,
byte[] b)
Constructs an IndexColorModel from the specified
arrays of red, green, and blue components. |
|
IndexColorModel(int bits,
int size,
byte[] r,
byte[] g,
byte[] b,
byte[] a)
Constructs an IndexColorModel from the given
arrays of red, green, blue and alpha components. |
|
IndexColorModel(int bits,
int size,
byte[] r,
byte[] g,
byte[] b,
int trans)
Constructs an IndexColorModel from the given arrays
of red, green, and blue components. |
|
IndexColorModel(int bits,
int size,
byte[] cmap,
int start,
boolean hasalpha)
Constructs an IndexColorModel from a single
array of interleaved red, green, blue and optional alpha
components. |
|
IndexColorModel(int bits,
int size,
byte[] cmap,
int start,
boolean hasalpha,
int trans)
Constructs an IndexColorModel from a single array of
interleaved red, green, blue and optional alpha components. |
Method Summary | |
void |
finalize()
Disposes of system resources associated with this ColorModel once this ColorModel is no
longer referenced. |
int |
getAlpha(int pixel)
Returns the alpha component for the specified pixel, scaled from 0 to 255. |
void |
getAlphas(byte[] a)
Copies the array of alpha transparency components into the specified array. |
int |
getBlue(int pixel)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB. |
void |
getBlues(byte[] b)
Copies the array of blue color components into the specified array. |
int |
getGreen(int pixel)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB. |
void |
getGreens(byte[] g)
Copies the array of green color components into the specified array. |
int |
getMapSize()
Returns the size of the color/alpha component arrays in this IndexColorModel . |
int |
getRed(int pixel)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB. |
void |
getReds(byte[] r)
Copies the array of red color components into the specified array. |
int |
getRGB(int pixel)
Returns the color/alpha components of the pixel in the default RGB color model format. |
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. |
int |
getTransparentPixel()
Returns the index of the transparent pixel in this IndexColorModel or -1 if there is no transparent pixel. |
java.lang.String |
toString()
Returns the String representation of the contents of
this ColorModel object. |
Methods inherited from class java.awt.image.ColorModel |
equals, getPixelSize, getRGBdefault, hasAlpha, hashCode, isAlphaPremultiplied |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b)
IndexColorModel
from the specified
arrays of red, green, and blue components. Pixels described
by this color model all have alpha components of 255
unnormalized (1.0 normalized), which means they
are fully opaque. All of the arrays specifying the color
components must have at least the specified number of entries.bits
- the number of bits each pixel occupiessize
- the size of the color component arraysr
- the array of red color componentsg
- the array of green color componentsb
- the array of blue color componentsjava.lang.IllegalArgumentException
- if bits
is less
than 1 or greater than 16java.lang.IllegalArgumentException
- if size
is less
than 1public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, int trans)
IndexColorModel
from the given arrays
of red, green, and blue components. Pixels described by this color
model all have alpha components of 255 unnormalized
(1.0 normalized), which means they are fully opaque, except
for the indicated transparent pixel. All of the arrays
specifying the color components must have at least the specified
number of entries.bits
- the number of bits each pixel occupiessize
- the size of the color component arraysr
- the array of red color componentsg
- the array of green color componentsb
- the array of blue color componentstrans
- the index of the transparent pixeljava.lang.IllegalArgumentException
- if bits
is less than
1 or greater than 16java.lang.IllegalArgumentException
- if size
is less than
1public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, byte[] a)
IndexColorModel
from the given
arrays of red, green, blue and alpha components. All of the
arrays specifying the components must have at least the specified
number of entries.bits
- the number of bits each pixel occupiessize
- the size of the color component arraysr
- the array of red color componentsg
- the array of green color componentsb
- the array of blue color componentsa
- the array of alpha value componentsjava.lang.IllegalArgumentException
- if bits
is less
than 1 or greater than 16java.lang.IllegalArgumentException
- if size
is less
than 1public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha)
IndexColorModel
from a single
array of interleaved red, green, blue and optional alpha
components. The array must have enough values in it to
fill all of the needed component arrays of the specified
size.bits
- the number of bits each pixel occupiessize
- the size of the color component arrayscmap
- the array of color componentsstart
- the starting offset of the first color componenthasalpha
- indicates whether alpha values are contained in
the cmap
arrayjava.lang.IllegalArgumentException
- if bits
is less
than 1 or greater than 16java.lang.IllegalArgumentException
- if size
is less
than 1public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha, int trans)
IndexColorModel
from a single array of
interleaved red, green, blue and optional alpha components. The
specified transparent index represents a pixel that is considered
entirely transparent regardless of any alpha value specified
for it. The array must have enough values in it to fill all
of the needed component arrays of the specified size.bits
- the number of bits each pixel occupiessize
- the size of the color component arrayscmap
- the array of color componentsstart
- the starting offset of the first color componenthasalpha
- indicates whether alpha values are contained in
the cmap
arraytrans
- the index of the fully transparent pixeljava.lang.IllegalArgumentException
- if bits
is less than
1 or greater than 16java.lang.IllegalArgumentException
- if size
is less than
1Method Detail |
public final int getMapSize()
IndexColorModel
.public final int getTransparentPixel()
IndexColorModel
or -1 if there is no transparent pixel.IndexColorModel
object's
transparent pixel, or -1 if there is no such pixel.public final void getReds(byte[] r)
getMapSize
are written.r
- the specified array into which the elements of the
array of red color components are copiedpublic final void getGreens(byte[] g)
getMapSize
are written.g
- the specified array into which the elements of the
array of green color components are copiedpublic final void getBlues(byte[] b)
getMapSize
are written.b
- the specified array into which the elements of the
array of blue color components are copiedpublic final void getAlphas(byte[] a)
getMapSize
are written.a
- the specified array into which the elements of the
array of alpha components are copiedpublic final void getRGBs(int[] rgb)
getMapSize
are
written.rgb
- the specified array into which the converted ARGB
values from this array of color and alpha components
are copied.public final int getRed(int pixel)
getRed
in class ColorModel
pixel
- the specified pixelpublic final int getGreen(int pixel)
getGreen
in class ColorModel
pixel
- the specified pixelpublic final int getBlue(int pixel)
getBlue
in class ColorModel
pixel
- the specified pixelpublic final int getAlpha(int pixel)
getAlpha
in class ColorModel
pixel
- the specified pixelpublic final int getRGB(int pixel)
getRGB
in class ColorModel
pixel
- the specified pixelColorModel.getRGBdefault()
public void finalize()
ColorModel
once this ColorModel
is no
longer referenced.finalize
in class ColorModel
public java.lang.String toString()
String
representation of the contents of
this ColorModel
object.toString
in class ColorModel
String
representing the contents of this
ColorModel
object.
|
PDAP 1.0 Spec, Rev. 0.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |