ColorModel class that works with pixel values that
represent color and alpha information as separate samples and that
store each sample in a separate data element. This class can be
used with an arbitrary ColorSpace. The number of
color samples in the pixel values must be same as the number of
color components in the ColorSpace. There may be a
single alpha sample.
For those methods that use
a primitive array pixel representation of type transferType,
the array length is the same as the number of color and alpha samples.
Color samples are stored first in the array followed by the alpha
sample, if present. The order of the color samples is specified
by the ColorSpace. Typically, this order reflects the
name of the color space type. For example, for TYPE_RGB,
index 0 corresponds to red, index 1 to green, and index 2 to blue.
The translation from pixel sample values to color/alpha components for
display or processing purposes is based on a one-to-one correspondence of
samples to components.
Depending on the transfer type used to create an instance of
ComponentColorModel, the pixel sample values
represented by that instance may be signed or unsigned and may
be of integral type or float or double (see below for details).
The translation from sample values to normalized color/alpha components
must follow certain rules. For float and double samples, the translation
is an identity, i.e. normalized component values are equal to the
corresponding sample values. For integral samples, the translation
should be only a simple scale and offset, where the scale and offset
constants may be different for each component. The result of
applying the scale and offset constants is a set of color/alpha
component values, which are guaranteed to fall within a certain
range. Typically, the range for a color component will be the range
defined by the getMinValue and getMaxValue
methods of the ColorSpace class. The range for an
alpha component should be 0.0 to 1.0.
Instances of ComponentColorModel created with transfer types
DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,
and DataBuffer.TYPE_INT have pixel sample values which
are treated as unsigned integral values.
The number of bits in a color or alpha sample of a pixel value might not
be the same as the number of bits for the corresponding color or alpha
sample passed to the
ComponentColorModel(ColorSpace, int[], boolean, boolean, int, int)
constructor. In
that case, this class assumes that the least significant n bits of a sample
value hold the component value, where n is the number of significant bits
for the component passed to the constructor. It also assumes that
any higher-order bits in a sample value are zero. Thus, sample values
range from 0 to 2n - 1. This class maps these sample values
to normalized color component values such that 0 maps to the value
obtained from the ColorSpace's getMinValue
method for each component and 2n - 1 maps to the value
obtained from getMaxValue. To create a
ComponentColorModel with a different color sample mapping
requires subclassing this class and overriding the
getNormalizedComponents(Object, float[], int) method.
The mapping for an alpha sample always maps 0 to 0.0 and
2n - 1 to 1.0.
For instances with unsigned sample values,
the unnormalized color/alpha component representation is only
supported if two conditions hold. First, sample value 0 must
map to normalized component value 0.0 and sample value 2n - 1
to 1.0. Second the min/max range of all color components of the
ColorSpace must be 0.0 to 1.0. In this case, the
component representation is the n least
significant bits of the corresponding sample. Thus each component is
an unsigned integral value between 0 and 2n - 1, where
n is the number of significant bits for a particular component.
If these conditions are not met, any method taking an unnormalized
component argument will throw an IllegalArgumentException.
Instances of ComponentColorModel created with transfer types
DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, and
DataBuffer.TYPE_DOUBLE have pixel sample values which
are treated as signed short, float, or double values.
Such instances do not support the unnormalized color/alpha component
representation, so any methods taking such a representation as an argument
will throw an IllegalArgumentException when called on one
of these instances. The normalized component values of instances
of this class have a range which depends on the transfer
type as follows: for float samples, the full range of the float data
type; for double samples, the full range of the float data type
(resulting from casting double to float); for short samples,
from approximately -maxVal to +maxVal, where maxVal is the per
component maximum value for the ColorSpace
(-32767 maps to -maxVal, 0 maps to 0.0, and 32767 maps
to +maxVal). A subclass may override the scaling for short sample
values to normalized component values by overriding the
getNormalizedComponents(Object, float[], int) method.
For float and double samples, the normalized component values are
taken to be equal to the corresponding sample values, and subclasses
should not attempt to add any non-identity scaling for these transfer
types.
Instances of ComponentColorModel created with transfer types
DataBuffer.TYPE_SHORT, DataBuffer.TYPE_FLOAT, and
DataBuffer.TYPE_DOUBLE
use all the bits of all sample values. Thus all color/alpha components
have 16 bits when using DataBuffer.TYPE_SHORT, 32 bits when
using DataBuffer.TYPE_FLOAT, and 64 bits when using
DataBuffer.TYPE_DOUBLE. When the
ComponentColorModel(ColorSpace, int[], boolean, boolean, int, int)
form of constructor is used with one of these transfer types, the
bits array argument is ignored.
It is possible to have color/alpha sample values
which cannot be reasonably interpreted as component values for rendering.
This can happen when ComponentColorModel is subclassed to
override the mapping of unsigned sample values to normalized color
component values or when signed sample values outside a certain range
are used. (As an example, specifying an alpha component as a signed
short value outside the range 0 to 32767, normalized range 0.0 to 1.0, can
lead to unexpected results.) It is the
responsibility of applications to appropriately scale pixel data before
rendering such that color components fall within the normalized range
of the ColorSpace (obtained using the getMinValue
and getMaxValue methods of the ColorSpace class)
and the alpha component is between 0.0 and 1.0. If color or alpha
component values fall outside these ranges, rendering results are
indeterminate.
Methods that use a single int pixel representation throw
an IllegalArgumentException, unless the number of components
for the ComponentColorModel is one and the component
value is unsigned -- in other words, a single color component using
a transfer type of DataBuffer.TYPE_BYTE,
DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT
and no alpha.
A ComponentColorModel can be used in conjunction with a
ComponentSampleModel, a BandedSampleModel,
or a PixelInterleavedSampleModel to construct a
BufferedImage.
ColorModel, ColorSpace, ComponentSampleModel, BandedSampleModel, PixelInterleavedSampleModel, BufferedImage
| Modifier and Type | Field and Description |
|---|---|
| private float[] | |
| private float[] | |
| private float[] | |
| private short[] | |
| private byte[] | |
| private short[] | |
| private byte[] | |
| private volatile int | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | |
| private float[] | |
| private boolean | |
| private boolean | |
| private boolean | |
| private boolean | signed
|
| private byte[] |
| Access | Constructor and Description |
|---|---|
| public | ComponentColorModel(ColorSpace
The colorSpace, int[] ColorSpace associated
with this color model.The number of significant bits per component.
May be null, in which case all bits of all
component samples will be significant.
Ignored if transferType is one of
bits, boolean DataBuffer.TYPE_SHORT,
DataBuffer.TYPE_FLOAT, or
DataBuffer.TYPE_DOUBLE,
in which case all bits of all component
samples will be significant.If true, this color model supports alpha. hasAlpha, boolean If true, alpha is premultiplied. isAlphaPremultiplied, int Specifies what alpha values can be represented
by this color model. transparency, int Specifies the type of primitive array used to
represent pixel values. transferType)Constructs a |
| public | ComponentColorModel(ColorSpace
The colorSpace, boolean ColorSpace associated
with this color model.If true, this color model supports alpha. hasAlpha, boolean If true, alpha is premultiplied. isAlphaPremultiplied, int Specifies what alpha values can be represented
by this color model. transparency, int Specifies the type of primitive array used to
represent pixel values. transferType)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| private static int[] | |
| private static int | |
| public ColorModel | coerceData(WritableRaster raster, boolean isAlphaPremultiplied)
Overrides java. Forces the raster data to match the state specified in the
|
| public SampleModel | Returns: ASampleModel that is compatible with this
ColorModel.The width of the w, int SampleModel you want to create.The height of the h)SampleModel you want to create.Overrides java. Creates a |
| public WritableRaster | Returns: AWritableRaster that is compatible with
this ColorModel.The width of the w, int WritableRaster you want to create.The height of the h)WritableRaster you want to create.Overrides java. Creates a |
| public boolean | Returns: true if the specified Object
is an instance of ComponentColorModel and equals this
ComponentColorModel; false otherwise.the obj)Object to test for equalityOverrides java. Tests if the specified |
| private int | |
| public int | Returns: The alpha component for the specified pixel, as an int.The pixel from which you want to get the alpha component. pixel)Implements abstract java. Returns the alpha component for the specified pixel, scaled from 0 to 255. |
| public int | Returns: The alpha component for the specified pixel, as an int.The pixel from which you want to get the alpha component,
specified by an array of data elements of type inData)transferType.Overrides java. Returns the alpha component for the specified pixel, scaled from 0 to 255. |
| public WritableRaster | Returns: AWritableRaster containing the image's alpha channel.The raster)WritableRaster from which to extract the
alpha channel.Overrides java. Returns a |
| public int | Returns: The blue color component for the specified pixel, as an int.The pixel from which you want to get the blue color component. pixel)Implements abstract java. Returns the blue color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public int | Returns: The blue color component for the specified pixel, as an int.The pixel from which you want to get the blue color component,
specified by an array of data elements of type inData)transferType.Overrides java. Returns the blue color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
| public int[] | Returns: The components array.The pixel value specified as an integer. pixel, int[] An integer array in which to store the unnormalized
color/alpha components. If the components, int components array is null,
a new array is allocated.An offset into the offset)components array.Overrides java. Returns an array of unnormalized color/alpha components given a pixel
in this |
| public int[] | Returns: Thecomponents array.A pixel value specified by an array of data elements of
type pixel, int[] transferType.An integer array in which to store the unnormalized
color/alpha components. If the components, int components array is null,
a new array is allocated.An offset into the offset)components array.Overrides java. Returns an array of unnormalized color/alpha components given a pixel
in this |
| public int | Returns: A pixel value represented as an int.An array of unnormalized color/alpha components. components, int An offset into the offset)components array.Overrides java. Returns a pixel value represented as an int in this |
| public int | Returns: anint pixel value in this
ColorModel corresponding to the specified components.an array of normalized color and alpha
components normComponents, int the index into normOffset)normComponents at which to
begin retrieving the color and alpha componentsOverrides java. Returns a pixel value represented as an |
| public Object | Returns: The data element array representation of a pixel in thisColorModel.the integer representation of the pixel in the 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: The data element array representation of a pixel in thisColorModel.An array of unnormalized color/alpha components. components, int The integer offset into the offset, Object components array.The object in which to store the data element array
representation of the pixel. If obj)obj variable is null,
a new array is allocated. If obj is not null, it must
be a primitive array of type transferType. An
ArrayIndexOutOfBoundsException is thrown if
obj is not large enough to hold a pixel value
for this ColorModel. Since
ComponentColorModel 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.Overrides java. Returns a data element array representation of a pixel in this
|
| public Object | Returns: anObject which is a primitive data array
representation of a pixelan array of normalized color and alpha
components normComponents, int the index into normOffset, Object normComponents at which to
begin retrieving color and alpha componentsa primitive data array to hold the returned pixel obj)Overrides java. Returns a data element array representation of a pixel in this
|
| public int | Returns: The green color component for the specified pixel, as an int.The pixel from which you want to get the green color component. pixel)Implements abstract java. Returns the green color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public int | Returns: The green color component for the specified pixel, as an int.The pixel from which you want to get the green color component,
specified by an array of data elements of type inData)transferType.Overrides java. Returns the green color component for the specified pixel, scaled
from 0 to 255 in the default RGB |
| public float[] | Returns: an array containing normalized color and alpha components.an array containing unnormalized components components, int the offset into the offset, float[] components array at
which to start retrieving unnormalized componentsan array that receives the normalized components normComponents, int the index into normOffset)normComponents at
which to begin storing normalized componentsOverrides java. Returns an array of all of the color/alpha components in normalized form, given an unnormalized component array. |
| public float[] | Returns: an array containing normalized color and alpha components.the specified pixel pixel, float[] an array to receive the normalized components normComponents, int the offset into the normOffset)normComponents
array at which to start storing normalized componentsOverrides java. Returns an array of all of the color/alpha components in normalized
form, given a pixel in this |
| public int | Returns: The red color component for the specified pixel, as an int.The pixel from which you want to get the red color component. pixel)Implements abstract java. Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public int | Returns: The red color component for the specified pixel, as an int.The pixel from which you want to get the red color component,
specified by an array of data elements of type inData)transferType.Overrides java. Returns the red color component for the specified pixel, scaled from 0 to 255 in the default RGB ColorSpace, sRGB. |
| public int | Returns: The color/alpha components for the specified pixel, as an int.The pixel from which you want to get the color/alpha components. pixel)Overrides java. Returns the color/alpha components of the pixel in the default RGB color model format. |
| public int | Returns: The color/alpha components for the specified pixel, as an int.The pixel from which you want to get the color/alpha components,
specified by an array of data elements of type inData)transferType.Overrides java. Returns the color/alpha components for the specified pixel in the default RGB color model format. |
| private int | |
| private int | |
| public int[] | Returns: an array containing unnormalized color and alpha components.an array containing normalized components normComponents, int the offset into the normOffset, int[] normComponents
array at which to start retrieving normalized componentsan array that receives the components from
components, int normComponentsthe index into offset)components at which to
begin storing normalized components from
normComponentsOverrides java. Returns an array of all of the color/alpha components in unnormalized form, given a normalized component array. |
| public int | Returns: a hash code for this ComponentColorModel.Overrides java. Returns the hash code for this ComponentColorModel. |
| private void | |
| public boolean | Returns: true if raster is compatible with this
ColorModel, false if it is not.The raster)Raster object to test for compatibility.Overrides java. Returns true if |
| public boolean | Returns: true if the SampleModel is
compatible with this ColorModel, false
if it is not.The sm)SampleModel to test for compatibility.Overrides java. Checks whether or not the specified |
| private void |
| compOffset | back to summary |
|---|---|
| private float[] compOffset | |
| compScale | back to summary |
|---|---|
| private float[] compScale | |
| diffMinMax | back to summary |
|---|---|
| private float[] diffMinMax | |
| fromLinearGray16ToOtherGray16LUT | back to summary |
|---|---|
| private short[] fromLinearGray16ToOtherGray16LUT | |
| fromLinearGray16ToOtherGray8LUT | back to summary |
|---|---|
| private byte[] fromLinearGray16ToOtherGray8LUT | |
| fromsRGB8LUT16 | back to summary |
|---|---|
| private short[] fromsRGB8LUT16 | |
| fromsRGB8LUT8 | back to summary |
|---|---|
| private byte[] fromsRGB8LUT8 | |
| hashCode | back to summary |
|---|---|
| private volatile int hashCode | |
| is_ICCGray_stdScale | back to summary |
|---|---|
| private boolean is_ICCGray_stdScale | |
| is_LinearGray_stdScale | back to summary |
|---|---|
| private boolean is_LinearGray_stdScale | |
| is_LinearRGB_stdScale | back to summary |
|---|---|
| private boolean is_LinearRGB_stdScale | |
| is_sRGB_stdScale | back to summary |
|---|---|
| private boolean is_sRGB_stdScale | |
| min | back to summary |
|---|---|
| private float[] min | |
| needScaleInit | back to summary |
|---|---|
| private boolean needScaleInit | |
| nonStdScale | back to summary |
|---|---|
| private boolean nonStdScale | |
| noUnnorm | back to summary |
|---|---|
| private boolean noUnnorm | |
| signed | back to summary |
|---|---|
| private boolean signed
| |
| tosRGB8LUT | back to summary |
|---|---|
| private byte[] tosRGB8LUT | |
| ComponentColorModel | back to summary |
|---|---|
| public ComponentColorModel(ColorSpace colorSpace, int[] bits, boolean hasAlpha, boolean isAlphaPremultiplied, int transparency, int transferType) Constructs a
| |
| ComponentColorModel | back to summary |
|---|---|
| public ComponentColorModel(ColorSpace colorSpace, boolean hasAlpha, boolean isAlphaPremultiplied, int transparency, int transferType) Constructs a
| |
| bitsArrayHelper | back to summary |
|---|---|
| private static int[] bitsArrayHelper(int[] origBits, int transferType, ColorSpace colorSpace, boolean hasAlpha) | |
| bitsHelper | back to summary |
|---|---|
| private static int bitsHelper(int transferType, ColorSpace colorSpace, boolean hasAlpha) | |
| coerceData | back to summary |
|---|---|
| public ColorModel coerceData(WritableRaster raster, boolean isAlphaPremultiplied) Overrides java. Forces the raster data to match the state specified in the
| |
| createCompatibleSampleModel | back to summary |
|---|---|
| public SampleModel createCompatibleSampleModel(int w, int h) Overrides java. Creates a
| |
| createCompatibleWritableRaster | back to summary |
|---|---|
| public WritableRaster createCompatibleWritableRaster(int w, int h) Overrides java. Creates a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Tests if the specified | |
| extractComponent | back to summary |
|---|---|
| private int extractComponent(Object inData, int idx, int precision) | |
| getAlpha | back to summary |
|---|---|
| public 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 int.
| |
| 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
| |
| getAlphaRaster | back to summary |
|---|---|
| public WritableRaster getAlphaRaster(WritableRaster raster) Overrides java. Returns a
| |
| getBlue | back to summary |
|---|---|
| public 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 ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the blue value will be 0).
| |
| 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
| |
| getComponents | back to summary |
|---|---|
| public 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 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 int in this
| |
| getDataElement | back to summary |
|---|---|
| public int getDataElement(float[] normComponents, int normOffset) 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
| |
| getDataElements | back to summary |
|---|---|
| public Object getDataElements(float[] normComponents, int normOffset, Object obj) Overrides java. Returns a data element array representation of a pixel in this
| |
| getGreen | back to summary |
|---|---|
| public 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 ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the green value will be 0).
| |
| 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
| |
| getNormalizedComponents | back to summary |
|---|---|
| public float[] getNormalizedComponents(int[] components, int offset, float[] normComponents, int normOffset) Overrides java. Returns an array of all of the color/alpha components in normalized
form, given an unnormalized component array. Unnormalized components
are unsigned integral values between 0 and 2n - 1, where
n is the number of bits for a particular component. Normalized
components are float values between a per component minimum and
maximum specified by the
| |
| getNormalizedComponents | back to summary |
|---|---|
| public float[] getNormalizedComponents(Object pixel, float[] normComponents, int normOffset) Overrides java. Returns an array of all of the color/alpha components in normalized
form, given a pixel in this This method must be overridden by a subclass if that subclass is designed to translate pixel sample values to color component values in a non-default way. The default translations implemented by this class is described in the class comments. Any subclass implementing a non-default translation must follow the constraints on allowable translations defined there.
| |
| getRed | back to summary |
|---|---|
| public 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 ColorSpace, sRGB. A color conversion is done if necessary. The pixel value is specified as an int. The returned value will be a non pre-multiplied value. If the alpha is premultiplied, this method divides it out before returning the value (if the alpha value is 0, the red value will be 0).
| |
| 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 ColorSpace, sRGB. A color conversion
is done if necessary. The
| |
| getRGB | back to summary |
|---|---|
| public 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 returned value will be in a non pre-multiplied format. If the alpha is premultiplied, this method divides it out of the color components (if the alpha value is 0, the color values will be 0).
| |
| 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
| |
| getRGBComponent | back to summary |
|---|---|
| private int getRGBComponent(int pixel, int idx) | |
| getRGBComponent | back to summary |
|---|---|
| private int getRGBComponent(Object inData, int idx) | |
| getUnnormalizedComponents | back to summary |
|---|---|
| public int[] getUnnormalizedComponents(float[] normComponents, int normOffset, int[] components, int offset) Overrides java. Returns an array of all of the color/alpha components in unnormalized
form, given a normalized component array. Unnormalized components
are unsigned integral values between 0 and 2n - 1, where
n is the number of bits for a particular component. Normalized
components are float values between a per component minimum and
maximum specified by the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for this ComponentColorModel.
| |
| initScale | back to summary |
|---|---|
| private void initScale() | |
| isCompatibleRaster | back to summary |
|---|---|
| public boolean isCompatibleRaster(Raster raster) Overrides java. Returns true if
| |
| isCompatibleSampleModel | back to summary |
|---|---|
| public boolean isCompatibleSampleModel(SampleModel sm) Overrides java. Checks whether or not the specified
| |
| setupLUTs | back to summary |
|---|---|
| private void setupLUTs() | |