DirectColorModel
class is a ColorModel
class that works with pixel values that represent RGB
color and alpha information as separate samples and that 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.
In addition, for each component of the ColorSpace, the minimum
normalized component value obtained via the getMinValue()
method of ColorSpace must be 0.0, and the maximum value obtained via
the getMaxValue()
method must be 1.0 (these min/max
values are typical for RGB spaces).
There must be three color samples in the pixel values and there can
be a single alpha sample. 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,
DataBuffer.TYPE_USHORT, and DataBuffer.TYPE_INT.
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:
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
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
Modifier and Type | Field and Description |
---|---|
private int | |
private int | |
private int | |
private int | |
private int | |
private int | |
private short[] | |
private byte[] | |
private int | |
private int | |
private int | |
private boolean | |
private int | |
private int | |
private int | |
private int | |
private byte[] |
Access | Constructor and Description |
---|---|
public | DirectColorModel(int
the number of bits in the pixel values; for example,
the sum of the number of bits in the masks. bits, int specifies a mask indicating which bits in an
integer pixel contain the red component rmask, int specifies a mask indicating which bits in an
integer pixel contain the green component gmask, int specifies a mask indicating which bits in an
integer pixel contain the blue component bmask)Constructs a |
public | DirectColorModel(int
the number of bits in the pixel values; for example,
the sum of the number of bits in the masks. bits, int specifies a mask indicating which bits in an
integer pixel contain the red component rmask, int specifies a mask indicating which bits in an
integer pixel contain the green component gmask, int specifies a mask indicating which bits in an
integer pixel contain the blue component bmask, int specifies a mask indicating which bits in an
integer pixel contain the alpha component amask)Constructs a |
public | DirectColorModel(ColorSpace
the specified space, int ColorSpace the number of bits in the pixel values; for example,
the sum of the number of bits in the masks. bits, int specifies a mask indicating which bits in an
integer pixel contain the red component rmask, int specifies a mask indicating which bits in an
integer pixel contain the green component gmask, int specifies a mask indicating which bits in an
integer pixel contain the blue component bmask, int specifies a mask indicating which bits in an
integer pixel contain the alpha component amask, boolean true if color samples are
premultiplied by the alpha sample; false otherwisethe type of array used to represent pixel values transferType)Constructs a |
Modifier and Type | Method and Description |
---|---|
public final ColorModel | Returns: aColorModel object that represents the
coerced data.the raster, boolean WritableRaster datatrue if the alpha is
premultiplied; false otherwiseOverrides java. Forces the raster data to match the state specified in the
|
public final WritableRaster | Returns: aWritableRaster object with the specified
width and height.the width to apply to the new w, int WritableRaster the height to apply to the new h)WritableRaster Overrides java. Creates a |
public final int | Returns: the value of the alpha component ofpixel
from 0 to 255.the specified pixel pixel)Implements abstract java. Returns the alpha component for the specified pixel, scaled from 0 to 255. |
public int | Returns: the alpha component of the specified pixel, scaled from 0 to 255.the specified pixel inData)Overrides java. Returns the alpha component for the specified pixel, scaled from 0 to 255. |
public final int | Returns: the mask, which indicates which bits of theint
pixel representation contain the alpha sample.Returns the mask indicating which bits in an |
public final int | Returns: the blue color component for the specified pixel, from 0 to 255 in the sRGBColorSpace .the specified pixel pixel)Implements abstract java. Returns the blue color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public int | Returns: the value of the blue component of the specified pixel.the array containing the pixel value inData)Overrides java. Returns the blue color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public final int | Returns: the mask, which indicates which bits of theint
pixel representation contain the blue color sample.Returns the mask indicating which bits in an |
public final 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 given a pixel
in this |
public final 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 given a pixel
in this |
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 |
public Object | Returns: an array representation of the specified pixel in thisColorModel 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
|
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 obj)Object representing an array of color
and alpha componentsOverrides java. Returns a data element array representation of a pixel in this
|
private float[] | |
public final int | Returns: the green color component for the specified pixel, from 0 to 255 in the sRGBColorSpace .the specified pixel pixel)Implements abstract java. Returns the green color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public int | Returns: the value of the green component of the specified pixel.the array containing the pixel value inData)Overrides java. Returns the green color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public final int | Returns: the mask, which indicates which bits of theint
pixel representation contain the green color sample.Returns the mask indicating which bits in an |
public final int | Returns: the red color component for the specified pixel, from 0 to 255 in the sRGBColorSpace .the specified pixel pixel)Implements abstract java. Returns the red color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public int | Returns: the value of the red component of the specified pixel.the array containing the pixel value inData)Overrides java. Returns the red color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
public final int | Returns: the mask, which indicates which bits of theint
pixel representation contain the red color sample.Returns the mask indicating which bits in an |
public final int | Returns: the RGB value of the color/alpha components of the specified pixel.the specified pixel pixel)Overrides java. Returns the color/alpha components of the pixel in the default RGB color model format. |
public int | Returns: the color and alpha components of the specified pixel.the specified pixel inData)Overrides java. Returns the color/alpha components for the specified pixel in the default RGB color model format. |
private int | |
private int | |
public boolean | Returns: true if raster is compatible
with this ColorModel ; false otherwise.the raster)Raster object to test for compatibilityOverrides java. Returns |
private void | |
public String | Returns: aString representing this
DirectColorModel .Overrides java. Returns a |
alpha_mask | back to summary |
---|---|
private int alpha_mask |
alpha_offset | back to summary |
---|---|
private int alpha_offset |
alpha_scale | back to summary |
---|---|
private int alpha_scale |
blue_mask | back to summary |
---|---|
private int blue_mask |
blue_offset | back to summary |
---|---|
private int blue_offset |
blue_scale | back to summary |
---|---|
private int blue_scale |
fromsRGB8LUT16 | back to summary |
---|---|
private short[] fromsRGB8LUT16 |
fromsRGB8LUT8 | back to summary |
---|---|
private byte[] fromsRGB8LUT8 |
green_mask | back to summary |
---|---|
private int green_mask |
green_offset | back to summary |
---|---|
private int green_offset |
green_scale | back to summary |
---|---|
private int green_scale |
is_LinearRGB | back to summary |
---|---|
private boolean is_LinearRGB |
lRGBprecision | back to summary |
---|---|
private int lRGBprecision |
red_mask | back to summary |
---|---|
private int red_mask |
red_offset | back to summary |
---|---|
private int red_offset |
red_scale | back to summary |
---|---|
private int red_scale |
tosRGB8LUT | back to summary |
---|---|
private byte[] tosRGB8LUT |
DirectColorModel | back to summary |
---|---|
public DirectColorModel(int bits, int rmask, int gmask, int bmask) Constructs a
|
DirectColorModel | back to summary |
---|---|
public DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask) Constructs a
|
DirectColorModel | back to summary |
---|---|
public DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType) Constructs a
|
coerceData | back to summary |
---|---|
public final ColorModel coerceData(WritableRaster raster, boolean isAlphaPremultiplied) Overrides java. Forces the raster data to match the state specified in the
|
createCompatibleWritableRaster | back to summary |
---|---|
public final WritableRaster createCompatibleWritableRaster(int w, int h) Overrides java. Creates a
|
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
|
getAlpha | back to summary |
---|---|
public int getAlpha(Object inData) Overrides java. Returns the alpha component for the specified pixel, scaled
from 0 to 255. The pixel value is specified by an array of data
elements of type
|
getAlphaMask | back to summary |
---|---|
public final int getAlphaMask() Returns the mask indicating which bits in an
|
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
|
getBlue | back to summary |
---|---|
public int getBlue(Object inData) Overrides java. Returns the blue color component for the specified pixel, scaled
from 0 to 255 in the default RGB
|
getBlueMask | back to summary |
---|---|
public final int getBlueMask() Returns the mask indicating which bits in an
|
getComponents | back to summary |
---|---|
public final int[] getComponents(int pixel, int[] components, int offset) Overrides java. Returns an array of unnormalized color/alpha components given a pixel
in this
|
getComponents | back to summary |
---|---|
public final int[] getComponents(Object pixel, int[] components, int offset) Overrides java. Returns an array of unnormalized color/alpha components given a pixel
in this
|
getDataElement | back to summary |
---|---|
public int getDataElement(int[] components, int offset) Overrides java. Returns a pixel value represented as an
|
getDataElements | back to summary |
---|---|
public Object getDataElements(int rgb, Object pixel) Overrides java. Returns a data element array representation of a pixel in this
|
getDataElements | back to summary |
---|---|
public Object getDataElements(int[] components, int offset, Object obj) Overrides java. Returns a data element array representation of a pixel in this
|
getDefaultRGBComponents | back to summary |
---|---|
private float[] getDefaultRGBComponents(int pixel) |
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
|
getGreen | back to summary |
---|---|
public int getGreen(Object inData) Overrides java. Returns the green color component for the specified pixel, scaled
from 0 to 255 in the default RGB
|
getGreenMask | back to summary |
---|---|
public final int getGreenMask() Returns the mask indicating which bits in an
|
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
|
getRed | back to summary |
---|---|
public int getRed(Object inData) Overrides java. Returns the red color component for the specified pixel, scaled
from 0 to 255 in the default RGB
|
getRedMask | back to summary |
---|---|
public final int getRedMask() Returns the mask indicating which bits in an
|
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. A color conversion is done if necessary.
The pixel value is specified as an
|
getRGB | back to summary |
---|---|
public int getRGB(Object inData) Overrides java. Returns the color/alpha components for the specified pixel in the
default RGB color model format. A color conversion is done if
necessary. The pixel value is specified by an array of data
elements of type
|
getsRGBComponentFromLinearRGB | back to summary |
---|---|
private int getsRGBComponentFromLinearRGB(int pixel, int idx) |
getsRGBComponentFromsRGB | back to summary |
---|---|
private int getsRGBComponentFromsRGB(int pixel, int idx) |
isCompatibleRaster | back to summary |
---|---|
public boolean isCompatibleRaster(Raster raster) Overrides java. Returns |
setFields | back to summary |
---|---|
private void setFields() |
toString | back to summary |
---|---|
public String toString() Overrides java. Returns a
|