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.PackedColorModel | +--java.awt.image.DirectColorModel
A ColorModel class that works with pixel values which represent RGB color and alpha information as separate samples and which pack all samples for a single pixel into a single int, short, or byte quantity. This class can be used only with ColorSpaces of type ColorSpace.TYPE_RGB. There must be three color samples in the pixel values and there may be a single alpha sample. For those methods which use a primitive array pixel representation of type transferType, the array length is always one. Color and alpha samples are stored in the single element of the array in bits indicated by bit masks. Each bit mask must be contiguous and masks must not overlap. The same masks apply to the single int pixel representation used by other methods. The correspondence of masks and color/alpha samples is as follows. Masks are identified by indices running from 0 through 2, if no alpha is present, or 3. The first three indices refer to color samples; index 0 corresponds to red, index 1 to green, and index 2 to blue. Index 3 corresponds to the alpha sample, if present. The transfer types supported are DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT.
The translation from pixel values to color/alpha components for display or processing purposes is a one-to-one correspondence of samples to components. A DirectColorModel is typically used with image data which uses masks to define packed samples. For example, a DirectColorModel can be used in conjunction with a SinglePixelPackedSampleModel to construct a BufferedImage. Normally the masks used by the SampleModel and the ColorModel would be the same. However, if they are different, the color interpretation of pixel data will be done according to the masks of the ColorModel.
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.
This color model is similar to an X11 TrueColor visual. The default RGB ColorModel specified by the ColorModel.getRGBdefault method is a DirectColorModel with the following parameters:
Number of bits: 32 Red mask: 0x00ff0000 Green mask: 0x0000ff00 Blue mask: 0x000000ff Alpha mask: 0xff000000 Color space: sRGB isAlphaPremultiplied: False Transparency: Transparency.TRANSLUCENT transferType: DataBuffer.TYPE_INT
Many of the methods in this class are final. This is because 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 behavior of those methods.
ColorModel
,
ColorSpace
,
SinglePixelPackedSampleModel
,
BufferedImage
,
ColorModel.getRGBdefault()
Fields inherited from class java.awt.image.ColorModel |
pixel_bits,
transferType |
Constructor Summary | |
DirectColorModel(ColorSpace space,
int bits,
int rmask,
int gmask,
int bmask,
int amask,
boolean isAlphaPremultiplied,
int transferType)
Constructs a DirectColorModel from the specified parameters. |
|
DirectColorModel(int bits,
int rmask,
int gmask,
int bmask)
Constructs a DirectColorModel from the given masks specifying which bits in an int pixel representation contain the red, green and blue color samples. |
|
DirectColorModel(int bits,
int rmask,
int gmask,
int bmask,
int amask)
Constructs a DirectColorModel from the given masks specifying which bits in an int pixel representation contain the red, green and blue color samples and the alpha sample, if present. |
Method Summary | |
ColorModel |
coerceData(WritableRaster raster,
boolean isAlphaPremultiplied)
Forces the Raster data to match the state specified in the isAlphaPremultiplied variable, assuming the data is currently correctly described by 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. |
int |
getAlpha(Object inData)
Returns the alpha component for the specified pixel, scaled from 0 to 255. |
int |
getAlphaMask()
Returns the mask indicating which bits in an int pixel representation contain the alpha component. |
int |
getBlue(int pixel)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
int |
getBlue(Object inData)
Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
int |
getBlueMask()
Returns the mask indicating which bits in an int pixel representation contain the blue color component. |
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 |
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 obj)
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. |
int |
getGreen(Object inData)
Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
int |
getGreenMask()
Returns the mask indicating which bits in an int pixel representation contain the green color component. |
int |
getRed(int pixel)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
int |
getRed(Object inData)
Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
int |
getRedMask()
Returns the mask indicating which bits in an int pixel representation contain the red color component. |
int |
getRGB(int pixel)
Returns the color/alpha components of the pixel in the default RGB color model format. |
int |
getRGB(Object inData)
Returns the color/alpha components for the specified pixel in the default RGB color model format. |
boolean |
isCompatibleRaster(Raster raster)
Returns true if raster is compatible with this ColorModel and false if it is not. |
String |
toString()
Returns a String that represents this
DirectColorModel . |
Methods inherited from class java.awt.image.PackedColorModel |
createCompatibleSampleModel,
equals,
getAlphaRaster,
getMask,
getMasks,
isCompatibleSampleModel |
Methods inherited from class java.awt.image.ColorModel |
finalize,
getColorSpace,
getComponentSize,
getComponentSize,
getNormalizedComponents,
getNumColorComponents,
getNumComponents,
getPixelSize,
getRGBdefault,
getTransparency,
getUnnormalizedComponents,
hasAlpha,
isAlphaPremultiplied |
Methods inherited from class java.lang.Object |
clone,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public DirectColorModel(int bits, int rmask, int gmask, int bmask)
public DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask)
public DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType)
Method Detail |
public final int getRedMask()
public final int getGreenMask()
public final int getBlueMask()
public final int getAlphaMask()
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 int getRed(Object inData)
inData
- an array of pixel valuesClassCastException
- if inData
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
inData
is not large enough to hold a pixel value
for this ColorModel
UnsupportedOperationException
- if this
tranferType
is not supported by this
ColorModel
public int getGreen(Object inData)
inData
- an array of pixel valuesClassCastException
- if inData
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
inData
is not large enough to hold a pixel value
for this ColorModel
UnsupportedOperationException
- if this
tranferType
is not supported by this
ColorModel
public int getBlue(Object inData)
inData
- an array of pixel valuesClassCastException
- if inData
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
inData
is not large enough to hold a pixel value
for this ColorModel
UnsupportedOperationException
- if this
tranferType
is not supported by this
ColorModel
public int getAlpha(Object inData)
inData
- the specified pixelClassCastException
- if inData
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
inData
is not large enough to hold a pixel value
for this ColorModel
UnsupportedOperationException
- if this
tranferType
is not supported by this
ColorModel
public int getRGB(Object inData)
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 final 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 final 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 final WritableRaster createCompatibleWritableRaster(int w, int h)
WritableRaster
,
SampleModel
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 obj)
WritableRaster.setDataElements(int, int, java.lang.Object)
,
SampleModel.setDataElements(int, int, java.lang.Object, java.awt.image.DataBuffer)
public final ColorModel coerceData(WritableRaster raster, boolean isAlphaPremultiplied)
raster
- the WritableRaster
dataisAlphaPremultiplied
- true
if the alpha is
premultiplied; false
otherwiseColorModel
object that represents the
coerced data.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 String toString()
String
that represents this
DirectColorModel
.String
representing this
DirectColorModel
.
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |