|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
java.awt.image
|
Field Summary |
---|
Fields inherited from class java.awt.image.ColorModel |
---|
pixel_bits, transferType |
Fields inherited from interface java.awt.Transparency |
---|
BITMASK, OPAQUE, TRANSLUCENT |
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 specified masks
that indicate 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 specified masks
that indicate 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, getDataElement, getDataElements, getNormalizedComponents, getNormalizedComponents, getNumColorComponents, getNumComponents, getPixelSize, getRGBdefault, getTransferType, getTransparency, getUnnormalizedComponents, hasAlpha, hashCode, isAlphaPremultiplied |
Methods inherited from class java.lang.Object |
---|
clone, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DirectColorModel(int bits, int rmask, int gmask, int bmask)
DirectColorModel
from the specified masks
that indicate which bits in an int
pixel representation
contain the red, green and blue color samples. As pixel values do not
contain alpha information, all pixels are treated as opaque, which
means that alpha = 1.0. All of the bits
in each mask must be contiguous and fit in the specified number
of least significant bits of an int
pixel representation.
The ColorSpace
is the default sRGB space. The
transparency value is Transparency.OPAQUE. The transfer type
is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
or DataBuffer.TYPE_INT that can hold a single pixel.
bits
- the number of bits in the pixel values; for example,
the sum of the number of bits in the masks.rmask
- specifies a mask indicating which bits in an
integer pixel contain the red componentgmask
- specifies a mask indicating which bits in an
integer pixel contain the green componentbmask
- specifies a mask indicating which bits in an
integer pixel contain the blue componentpublic DirectColorModel(int bits, int rmask, int gmask, int bmask, int amask)
DirectColorModel
from the specified masks
that indicate which bits in an int
pixel representation
contain the red, green and blue color samples and the alpha sample,
if present. If amask
is 0, pixel values do not contain
alpha information and all pixels are treated as opaque, which means
that alpha = 1.0. All of the bits in each mask must
be contiguous and fit in the specified number of least significant bits
of an int
pixel representation. Alpha, if present, is not
premultiplied. The ColorSpace
is the default sRGB space.
The transparency value is Transparency.OPAQUE if no alpha is
present, or Transparency.TRANSLUCENT otherwise. The transfer type
is the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
or DataBuffer.TYPE_INT that can hold a single pixel.
bits
- the number of bits in the pixel values; for example,
the sum of the number of bits in the masks.rmask
- specifies a mask indicating which bits in an
integer pixel contain the red componentgmask
- specifies a mask indicating which bits in an
integer pixel contain the green componentbmask
- specifies a mask indicating which bits in an
integer pixel contain the blue componentamask
- specifies a mask indicating which bits in an
integer pixel contain the alpha componentpublic DirectColorModel(ColorSpace space, int bits, int rmask, int gmask, int bmask, int amask, boolean isAlphaPremultiplied, int transferType)
DirectColorModel
from the specified
parameters. Color components are in the specified
ColorSpace
, which must be of type ColorSpace.TYPE_RGB
and have minimum normalized component values which are all 0.0
and maximum values which are all 1.0.
The masks specify which bits in an int
pixel
representation contain the red, green and blue color samples and
the alpha sample, if present. If amask
is 0, pixel
values do not contain alpha information and all pixels are treated
as opaque, which means that alpha = 1.0. All of the
bits in each mask must be contiguous and fit in the specified number
of least significant bits of an int
pixel
representation. If there is alpha, the boolean
isAlphaPremultiplied
specifies how to interpret
color and alpha samples in pixel values. If the boolean
is true
, color samples are assumed to have been
multiplied by the alpha sample. The transparency value is
Transparency.OPAQUE, if no alpha is present, or
Transparency.TRANSLUCENT otherwise. The transfer type
is the type of primitive array used to represent pixel values and
must be one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or
DataBuffer.TYPE_INT.
space
- the specified ColorSpace
bits
- the number of bits in the pixel values; for example,
the sum of the number of bits in the masks.rmask
- specifies a mask indicating which bits in an
integer pixel contain the red componentgmask
- specifies a mask indicating which bits in an
integer pixel contain the green componentbmask
- specifies a mask indicating which bits in an
integer pixel contain the blue componentamask
- specifies a mask indicating which bits in an
integer pixel contain the alpha componentisAlphaPremultiplied
- true
if color samples are
premultiplied by the alpha sample; false
otherwisetransferType
- the type of array used to represent pixel values
IllegalArgumentException
- if space
is not a
TYPE_RGB space or if the min/max normalized component
values are not 0.0/1.0.Method Detail |
---|
public final int getRedMask()
int
pixel
representation contain the red color component.
int
pixel representation contain the red color sample.public final int getGreenMask()
int
pixel
representation contain the green color component.
int
pixel representation contain the green color sample.public final int getBlueMask()
int
pixel
representation contain the blue color component.
int
pixel representation contain the blue color sample.public final int getAlphaMask()
int
pixel
representation contain the alpha component.
int
pixel representation contain the alpha sample.public final int getRed(int pixel)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
as an int
.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the red value
is 0.
getRed
in class ColorModel
pixel
- the specified pixel
ColorSpace
.public final int getGreen(int pixel)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
as an int
.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the green value
is 0.
getGreen
in class ColorModel
pixel
- the specified pixel
ColorSpace
.public final int getBlue(int pixel)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
as an int
.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the blue value
is 0.
getBlue
in class ColorModel
pixel
- the specified pixel
ColorSpace
.public final int getAlpha(int pixel)
int
.
getAlpha
in class ColorModel
pixel
- the specified pixel
pixel
from 0 to 255.public final int getRGB(int pixel)
int
.
The returned value is in a non pre-multiplied format. Thus, if
the alpha is premultiplied, this method divides it out of the
color components. If the alpha value is 0, for example, the color
values are each 0.
getRGB
in class ColorModel
pixel
- the specified pixel
ColorModel.getRGBdefault()
public int getRed(Object inData)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
by an array of data elements of type transferType
passed
in as an object reference.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the red value
is 0.
If inData
is not a primitive array of type
transferType
, a ClassCastException
is
thrown. An ArrayIndexOutOfBoundsException
is
thrown if inData
is not large enough to hold a
pixel value for this ColorModel
. Since
DirectColorModel
can be subclassed, subclasses inherit
the implementation of this method and if they don't override it
then they throw an exception if they use an unsupported
transferType
.
An UnsupportedOperationException
is thrown if this
transferType
is not supported by this
ColorModel
.
getRed
in class ColorModel
inData
- the array containing the pixel value
ArrayIndexOutOfBoundsException
- if inData
is not
large enough to hold a pixel value for this color model
ClassCastException
- if inData
is not a
primitive array of type transferType
UnsupportedOperationException
- if this transferType
is not supported by this color modelpublic int getGreen(Object inData)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
by an array of data elements of type transferType
passed
in as an object reference.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the green value
is 0. If inData
is not a primitive array of type
transferType
, a ClassCastException
is thrown.
An ArrayIndexOutOfBoundsException
is
thrown if inData
is not large enough to hold a pixel
value for this ColorModel
. Since
DirectColorModel
can be subclassed, subclasses inherit
the implementation of this method and if they don't override it
then they throw an exception if they use an unsupported
transferType
.
An UnsupportedOperationException
is
thrown if this transferType
is not supported by this
ColorModel
.
getGreen
in class ColorModel
inData
- the array containing the pixel value
ArrayIndexOutOfBoundsException
- if inData
is not
large enough to hold a pixel value for this color model
ClassCastException
- if inData
is not a
primitive array of type transferType
UnsupportedOperationException
- if this transferType
is not supported by this color modelpublic int getBlue(Object inData)
ColorSpace
, sRGB. A
color conversion is done if necessary. The pixel value is specified
by an array of data elements of type transferType
passed
in as an object reference.
The returned value is a non pre-multiplied value. Thus, if the
alpha is premultiplied, this method divides it out before returning
the value. If the alpha value is 0, for example, the blue value
is 0. If inData
is not a primitive array of type
transferType
, a ClassCastException
is thrown.
An ArrayIndexOutOfBoundsException
is
thrown if inData
is not large enough to hold a pixel
value for this ColorModel
. Since
DirectColorModel
can be subclassed, subclasses inherit
the implementation of this method and if they don't override it
then they throw an exception if they use an unsupported
transferType
.
An UnsupportedOperationException
is
thrown if this transferType
is not supported by this
ColorModel
.
getBlue
in class ColorModel
inData
- the array containing the pixel value
ArrayIndexOutOfBoundsException
- if inData
is not
large enough to hold a pixel value for this color model
ClassCastException
- if inData
is not a
primitive array of type transferType
UnsupportedOperationException
- if this transferType
is not supported by this color modelpublic int getAlpha(Object inData)
transferType
passed in as an object
reference.
If inData
is not a primitive array of type
transferType
, a ClassCastException
is
thrown. An ArrayIndexOutOfBoundsException
is
thrown if inData
is not large enough to hold a pixel
value for this ColorModel
. Since
DirectColorModel
can be subclassed, subclasses inherit
the implementation of this method and if they don't override it
then they throw an exception if they use an unsupported
transferType
.
If this transferType
is not supported, an
UnsupportedOperationException
is thrown.
getAlpha
in class ColorModel
inData
- the specified pixel
ClassCastException
- 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)
transferType
passed in as an object
reference. If inData
is not a primitive array of type
transferType
, a ClassCastException
is
thrown. An ArrayIndexOutOfBoundsException
is
thrown if inData
is not large enough to hold a pixel
value for this ColorModel
.
The returned value is in a non pre-multiplied format. Thus, if
the alpha is premultiplied, this method divides it out of the
color components. If the alpha value is 0, for example, the color
values is 0. Since DirectColorModel
can be
subclassed, subclasses inherit the implementation of this method
and if they don't override it then
they throw an exception if they use an unsupported
transferType
.
getRGB
in class ColorModel
inData
- the specified pixel
UnsupportedOperationException
- if this
transferType
is not supported by this
ColorModel
ColorModel.getRGBdefault()
public Object getDataElements(int rgb, Object pixel)
ColorModel
, given an integer pixel representation in the
default RGB color model.
This array can then be passed to the setDataElements
method of a WritableRaster
object. If the pixel variable
is null
, a new array is allocated. If pixel
is not null
, it must be a primitive array of type
transferType
; otherwise, a
ClassCastException
is thrown. An
ArrayIndexOutOfBoundsException
is
thrown if pixel
is not large enough to hold a pixel
value for this ColorModel
. The pixel array is returned.
Since DirectColorModel
can be subclassed, subclasses
inherit the implementation of this method and if they don't
override it then they throw an exception if they use an unsupported
transferType
.
getDataElements
in class ColorModel
rgb
- the integer pixel representation in the default RGB
color modelpixel
- the specified pixel
ColorModel
ClassCastException
- if pixel
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
pixel
is not large enough to hold a pixel value
for this ColorModel
UnsupportedOperationException
- if this
transferType
is not supported by this
ColorModel
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)
ColorModel
. The pixel value is specified as an
int
. If the components
array is
null
, a new array is allocated. The
components
array is returned. Color/alpha components are
stored in the components
array starting at
offset
, even if the array is allocated by this method.
An ArrayIndexOutOfBoundsException
is thrown if the
components
array is not null
and is not large
enough to hold all the color and alpha components, starting at
offset
.
getComponents
in class ColorModel
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 components
public final int[] getComponents(Object pixel, int[] components, int offset)
ColorModel
. The pixel value is specified by an
array of data elements of type transferType
passed in as
an object reference. If pixel
is not a primitive array
of type transferType
, a ClassCastException
is thrown. An ArrayIndexOutOfBoundsException
is
thrown if pixel
is not large enough to hold a
pixel value for this ColorModel
. If the
components
array is null
, a new
array is allocated. The components
array is returned.
Color/alpha components are stored in the components
array
starting at offset
, even if the array is allocated by
this method. An ArrayIndexOutOfBoundsException
is thrown if the components
array is not
null
and is not large enough to hold all the color and
alpha components, starting at offset
.
Since DirectColorModel
can be subclassed, subclasses
inherit the implementation of this method and if they don't
override it then they throw an exception if they use an unsupported
transferType
.
getComponents
in class ColorModel
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 components
ClassCastException
- if pixel
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
pixel
is not large enough to hold a pixel value
for this ColorModel
, or if components
is not null
and is not large enough to hold all the
color and alpha components, starting at offset
UnsupportedOperationException
- if this
transferType
is not supported by this
color modelpublic final WritableRaster createCompatibleWritableRaster(int w, int h)
WritableRaster
with the specified width and
height that has a data layout (SampleModel
) compatible
with this ColorModel
.
createCompatibleWritableRaster
in class ColorModel
w
- the width to apply to the new WritableRaster
h
- the height to apply to the new WritableRaster
WritableRaster
object with the specified
width and height.
IllegalArgumentException
- if w
or h
is less than or equal to zeroWritableRaster
,
SampleModel
public int getDataElement(int[] components, int offset)
int
in this
ColorModel
, given an array of unnormalized color/alpha
components. An ArrayIndexOutOfBoundsException
is
thrown if the components
array is
not large enough to hold all the color and alpha components, starting
at offset
.
getDataElement
in class ColorModel
components
- an array of unnormalized color and alpha
componentsoffset
- the index into components
at which to
begin retrieving the color and alpha components
int
pixel value in this
ColorModel
corresponding to the specified components.
ArrayIndexOutOfBoundsException
- if
the components
array is not large enough to
hold all of the color and alpha components starting at
offset
public Object getDataElements(int[] components, int offset, Object obj)
ColorModel
, given an array of unnormalized color/alpha
components.
This array can then be passed to the setDataElements
method of a WritableRaster
object.
An ArrayIndexOutOfBoundsException
is thrown if the
components
array
is not large enough to hold all the color and alpha components,
starting at offset. If the obj
variable is
null
, a new array is allocated. If obj
is
not null
, it must be a primitive array
of type transferType
; otherwise, a
ClassCastException
is thrown.
An ArrayIndexOutOfBoundsException
is thrown if
obj
is not large enough to hold a pixel value for this
ColorModel
.
Since DirectColorModel
can be subclassed, subclasses
inherit the implementation of this method and if they don't
override it then they throw an exception if they use an unsupported
transferType
.
getDataElements
in class ColorModel
components
- an array of unnormalized color and alpha
componentsoffset
- the index into components
at which to
begin retrieving color and alpha componentsobj
- the Object
representing an array of color
and alpha components
Object
representing an array of color and
alpha components.
ClassCastException
- if obj
is not a primitive array of type transferType
ArrayIndexOutOfBoundsException
- if
obj
is not large enough to hold a pixel value
for this ColorModel
or the components
array is not large enough to hold all of the color and alpha
components starting at offset
UnsupportedOperationException
- if this
transferType
is not supported by this
color modelWritableRaster.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)
isAlphaPremultiplied
variable, assuming the data is
currently correctly described by this ColorModel
. It
may multiply or divide the color raster data by alpha, or do
nothing if the data is in the correct state. If the data needs to
be coerced, this method will also return an instance of this
ColorModel
with the isAlphaPremultiplied
flag set appropriately. This method will throw a
UnsupportedOperationException
if this transferType is
not supported by this ColorModel
. Since
ColorModel
can be subclassed, subclasses inherit the
implementation of this method and if they don't override it then
they throw an exception if they use an unsupported transferType.
coerceData
in class ColorModel
raster
- the WritableRaster
dataisAlphaPremultiplied
- true
if the alpha is
premultiplied; false
otherwise
ColorModel
object that represents the
coerced data.
UnsupportedOperationException
- if this
transferType
is not supported by this
color modelpublic boolean isCompatibleRaster(Raster raster)
true
if raster
is compatible
with this ColorModel
and false
if it is
not.
isCompatibleRaster
in class ColorModel
raster
- the Raster
object to test for compatibility
true
if raster
is compatible
with this ColorModel
; false
otherwise.public String toString()
String
that represents this
DirectColorModel
.
toString
in class ColorModel
String
representing this
DirectColorModel
.