Spec-Zone .ru
спецификации, руководства, описания, API
|
|
JavaTM 2 Platform Standard Edition |
|||||||||
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
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 ColorSpace. 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) will be assumed for each entry. An optional transparent pixel value can be supplied which indicates a completely transparent pixel, regardless of any alpha component recorded for that pixel value. Note that alpha values in IndexColorModels 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. 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)
Constructs an IndexColorModel from the given 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. |
|
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. |
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 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. |
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. |
int |
getDataElement(int[] components,
int offset)
Returns a pixel value represented as an int in this ColorModel, given an array of unnormalized color/alpha components. |
Object |
getDataElements(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. |
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. |
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. |
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. |
String |
toString()
Prints the contents of this object |
Methods inherited from class java.awt.image.ColorModel |
coerceData,
equals,
getAlpha,
getAlphaRaster,
getBlue,
getColorSpace,
getComponentSize,
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)
pixel
- a specified pixelpublic final int getGreen(int pixel)
pixel
- the specified pixelpublic final int getBlue(int pixel)
pixel
- the specified pixelpublic final int getAlpha(int pixel)
pixel
- the specified pixelpublic 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)
pixel
- the specified pixelcomponents
- the array to receive the color and alpha
components of the specified pixeloffset
- the offset into the components
array at
which to start storing the color and alpha componentsUnsupportedOperationException
- if this
method is not supported by this ColorModel
public int[] getComponents(Object pixel, int[] components, int offset)
pixel
- the specified pixelcomponents
- an array that receives the color and alpha
components of the specified pixeloffset
- the index into the components
array at
which to begin storing the color and alpha components of the
specified pixelUnsupportedOperationException
- if this
method is not supported by this ColorModel
public int getDataElement(int[] components, int offset)
components
- an array of unnormalized color and alpha
componentsoffset
- the index into components
at which to
begin retrieving the color and alpha componentsint
pixel value in this
ColorModel
corresponding to the specified components.IllegalArgumentException
- if
pixel values for this ColorModel
are not
conveniently representable as a single int
ArrayIndexOutOfBoundsException
- if
the components
array is not large enough to
hold all of the color and alpha components starting at
offset
UnsupportedOperationException
- if this
method is not supported by this ColorModel
public Object getDataElements(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)
raster
- the Raster
object to test for compatibilitytrue
if raster
is compatible
with this ColorModel
.UnsupportedOperationException
- if this
method has not been implemented for this
ColorModel
public SampleModel createCompatibleSampleModel(int w, int h)
SampleModel
public boolean isCompatibleSampleModel(SampleModel sm)
SampleModel
public BufferedImage convertToIntDiscrete(Raster raster, boolean forceARGB)
public void finalize()
ColorModel
once this ColorModel
is no
longer referenced.public String toString()
String
representing the contents of this
ColorModel
object.
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |