|
Java Platform 1.2 Beta 4 |
|||||||||
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 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. Higher order bits in pixel representations are assumed to be zero. For those methods which use a primitive array pixel representation of type transferType, the array length is always one. The transfer types supported are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT. 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.
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
,
ColorSpace
,
DataBuffer
Fields inherited from class java.awt.image.ColorModel | |
pixel_bits , transferType |
Constructor Summary | |
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[] r,
byte[] g,
byte[] b)
Constructs an IndexColorModel from the given arrays of red, green, and blue 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. |
|
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,
int[] cmap,
int start,
boolean hasalpha,
int trans,
int transferType)
Constructs an IndexColorModel from an array of ints where each int is comprised of red, green, blue, and optional alpha components in the default RGB color model format. |
Method Summary | |
BufferedImage | convertToIntDiscrete(Raster raster,
boolean forceARGB)
Returns a new BufferedImage of TYPE_INT_ARGB or TYPE_INT_RGB which has a Raster with pixel data computed by expanding the indices in the source Raster using the color/alpha component arrays of this ColorModel. |
SampleModel | createCompatibleSampleModel(int w,
int h)
Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel. |
WritableRaster | createCompatibleWritableRaster(int w,
int h)
Creates a WritableRaster with the specified width and height that has a data layout (SampleModel) compatible with this ColorModel. |
int | getAlpha(int pixel)
Returns the alpha component for the specified pixel, scaled from 0 to 255. The pixel value is specified as an int. |
void | getAlphas(byte[] a)
Copies the array of alpha transparency components into the given array. |
int | getBlue(int pixel)
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. |
void | getBlues(byte[] b)
Copies the array of blue color components into the given array. |
int[] | getComponents(int pixel,
int[] components,
int offset)
Returns an array of unnormalized color/alpha components given a pixel in this ColorModel. |
int[] | getComponents(Object pixel,
int[] components,
int offset)
Returns an array of unnormalized color/alpha components given a pixel in this ColorModel. |
int[] | getComponentSize()
Returns an array of the number of bits per color/alpha component. |
Object | getDataElements(int rgb,
Object pixel)
Returns a data element array representation of a pixel in this ColorModel, given an integer pixel representation in the default RGB color model. |
int | getGreen(int pixel)
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. |
void | getGreens(byte[] g)
Copies the array of green color components into the given 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 ColorSpace, sRGB. The pixel value is specified as an int. |
void | getReds(byte[] r)
Copies the array of red color components into the given 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 given array. |
int | getTransparency()
Returns the transparency. |
int | getTransparentPixel()
Returns the index of the transparent pixel in this IndexColorModel or -1 if there is no transparent pixel. |
boolean | isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel and false if it is not. |
boolean | isCompatibleSampleModel(SampleModel sm)
Checks if the SampleModel is compatible with this ColorModel. |
int | setDataElement(int[] components,
int offset)
Returns a pixel value represented as an int in this ColorModel, given an array of unnormalized color/alpha components. |
Object | setDataElements(int[] components,
int offset,
Object pixel)
Returns a data element array representation of a pixel in this ColorModel, given an array of unnormalized color/alpha components. |
String | toString()
Prints the contents of this object |
Methods inherited from class java.awt.image.ColorModel | |
coerceData , equals , finalize , getAlpha , getAlphaRaster , getBlue , getColorSpace , getComponentSize , getDataElement , getGreen , getNormalizedComponents , getNumColorComponents , getNumComponents , getPixelSize , getRed , getRGB , getRGBdefault , getUnnormalizedComponents , hasAlpha , isAlphaPremultiplied |
Methods inherited from class java.lang.Object | |
clone , getClass , hashCode , notify , notifyAll , wait , wait , wait |
Constructor Detail |
public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
r
- The array of red color components.
g
- The array of green color components.
b
- The array of blue color components.public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, int trans)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
r
- The array of red color components.
g
- The array of green color components.
b
- The array of blue color components.
trans
- The index of the transparent pixel.public IndexColorModel(int bits, int size, byte[] r, byte[] g, byte[] b, byte[] a)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
r
- The array of red color components.
g
- The array of green color components.
b
- The array of blue color components.
a
- The array of alpha value components.public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
cmap
- The array of color components.
start
- The starting offset of the first color component.
hasalpha
- Indicates whether alpha values are contained in
the cmap array.public IndexColorModel(int bits, int size, byte[] cmap, int start, boolean hasalpha, int trans)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
cmap
- The array of color components.
start
- The starting offset of the first color component.
hasalpha
- Indicates whether alpha values are contained in
the cmap array.
trans
- The index of the fully transparent pixel.public IndexColorModel(int bits, int size, int[] cmap, int start, boolean hasalpha, int trans, int transferType)
bits
- The number of bits each pixel occupies.
size
- The size of the color component arrays.
cmap
- The array of color components.
start
- The starting offset of the first color component.
hasalpha
- Indicates whether alpha values are contained in
the cmap array.
trans
- The index of the fully transparent pixel.Method Detail |
public int getTransparency()
Transparency.OPAQUE
,
Transparency.BITMASK
,
Transparency.TRANSLUCENT
public int[] getComponentSize()
public final int getMapSize()
public final int getTransparentPixel()
public final void getReds(byte[] r)
public final void getGreens(byte[] g)
public final void getBlues(byte[] b)
public final void getAlphas(byte[] a)
public final void getRGBs(int[] rgb)
public final int getRed(int pixel)
public final int getGreen(int pixel)
public final int getBlue(int pixel)
public final int getAlpha(int pixel)
public final int getRGB(int pixel)
ColorModel.getRGBdefault()
public Object getDataElements(int rgb, Object pixel)
WritableRaster.setDataElements(int, int, java.lang.Object)
,
SampleModel.setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)
public int[] getComponents(int pixel, int[] components, int offset)
public int[] getComponents(Object pixel, int[] components, int offset)
public int setDataElement(int[] components, int offset)
public Object setDataElements(int[] components, int offset, Object pixel)
WritableRaster.setDataElements(int, int, java.lang.Object)
,
SampleModel.setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)
public WritableRaster createCompatibleWritableRaster(int w, int h)
WritableRaster
,
SampleModel
public boolean isCompatibleRaster(Raster raster)
public SampleModel createCompatibleSampleModel(int w, int h)
SampleModel
public boolean isCompatibleSampleModel(SampleModel sm)
SampleModel
public BufferedImage convertToIntDiscrete(Raster raster, boolean forceARGB)
public String toString()
|
Java Platform 1.2 Beta 4 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |