|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.color.ColorSpace | +--javax.media.jai.ColorSpaceJAI
An abstract subclass of ColorSpace
which adds methods to
transform colors represented as pixels in a Raster
between
a specific color space and either sRGB or a well-defined C.I.E. X,Y,Z
color space. The class is particularly applicable for use with color
spaces which are mathematically defined and for which no I.C.C. profile
is readily available. (Note however that color conversions specified
by a simple matrix transformation might best be effected using the
"BandCombine" operation.) The JAI "ColorConvert" operation recognizes when
an instance of ColorSpaceJAI
is present and uses the
Raster
-based conversion methods to improve performance.
This is possible because without the ColorSpaceJAI
definition,
a ColorSpace
which was not an ICC_ColorSpace
would permit color conversion only by means of pixel-by-pixel invocations
of toCIEXYZ(float[])
and fromCIEXYZ(float[])
(or,
equivalently toRGB(float[])
and fromRGB(float[])
).
ColorSpace
,
ICC_ColorSpace
,
ColorConvertDescriptor
,
BandCombineDescriptor
, Serialized FormFields inherited from class java.awt.color.ColorSpace |
CS_CIEXYZ,
CS_GRAY,
CS_LINEAR_RGB,
CS_PYCC,
CS_sRGB,
TYPE_2CLR,
TYPE_3CLR,
TYPE_4CLR,
TYPE_5CLR,
TYPE_6CLR,
TYPE_7CLR,
TYPE_8CLR,
TYPE_9CLR,
TYPE_ACLR,
TYPE_BCLR,
TYPE_CCLR,
TYPE_CMY,
TYPE_CMYK,
TYPE_DCLR,
TYPE_ECLR,
TYPE_FCLR,
TYPE_GRAY,
TYPE_HLS,
TYPE_HSV,
TYPE_Lab,
TYPE_Luv,
TYPE_RGB,
TYPE_XYZ,
TYPE_YCbCr,
TYPE_Yxy |
Constructor Summary | |
protected |
ColorSpaceJAI(int type,
int numComponents,
boolean isRGBPreferredIntermediary)
Constructs a ColorSpaceJAI object given the color space
type, the number of components, and an indicator of the preferred
intermediary or connection color space. |
Method Summary | |
protected static void |
checkParameters(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
The conversion methods in ColorSpaceJAI only work when the input raster is not null and has 3 bands; if the destination raster is provided, it is must have 3 bands; if the component size is provided, it must have a length of 3. |
static WritableRaster |
CIEXYZToRGB(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
CIEXYZ to sRGB according to the equation:
|
protected static void |
convertToSigned(double[] buf,
int dataType)
after conversion, the range for a signed short is [0, Short.MAX_Value -Short.MIN_VALUE]. |
abstract WritableRaster |
fromCIEXYZ(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
CIEXYZ to the color space represented by this class. |
abstract WritableRaster |
fromRGB(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
sRGB to the color space represented by this class. |
boolean |
isRGBPreferredIntermediary()
Whether sRGB is the preferred intermediary color space when converting to another color space which is neither sRGB nor CIEXYZ. |
static WritableRaster |
RGBToCIEXYZ(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
sRGB to CIEXYZ according to the equation:
|
abstract WritableRaster |
toCIEXYZ(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
the color space represented by this class to CIEXYZ. |
abstract WritableRaster |
toRGB(Raster src,
int[] srcComponentSize,
WritableRaster dest,
int[] destComponentSize)
Transforms the pixel data in the source Raster from
the color space represented by this class to sRGB. |
Methods inherited from class java.awt.color.ColorSpace |
fromCIEXYZ,
fromRGB,
getInstance,
getName,
getNumComponents,
getType,
isCS_sRGB,
toCIEXYZ,
toRGB |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
protected ColorSpaceJAI(int type, int numComponents, boolean isRGBPreferredIntermediary)
ColorSpaceJAI
object given the color space
type, the number of components, and an indicator of the preferred
intermediary or connection color space.type
- The color space type (ColorSpace.TYPE_*
).numComponents
- The number of color components.isRGBPreferredIntermediary
- Whether sRGB (true
)
or CIEXYZ (false
) is the preferred connection
color space.numComponents
is non-positive.Method Detail |
public static WritableRaster CIEXYZToRGB(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
CIEXYZ to sRGB according to the equation:
[ R ] [ 3.240479 -1.537150 -0.498535 ] [ X ] [ G ] = [ -0.969256 1.875992 0.041556 ] [ Y ] [ B ] [ 0.055648 -0.204043 1.057311 ] [ Z ]If the destination
WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
Integral data will be normalized according to the number of bits specified for the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
This method is provided for the convenience of extenders defining a color space for which the conversion is defined with respect to CIEXYZ.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does is not 3, or either component size array
is non-null and has length not equal to 3.protected static void checkParameters(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
protected static void convertToSigned(double[] buf, int dataType)
public static WritableRaster RGBToCIEXYZ(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
sRGB to CIEXYZ according to the equation:
[ X ] [ 0.412453 0.357580 0.180423 ] [ R ] [ Y ] = [ 0.212671 0.715160 0.072169 ] [ G ] [ Z ] [ 0.019334 0.119193 0.950227 ] [ B ]
If the destination WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
Integral data will be normalized according to the number of bits specified for the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
This method is provided for the convenience of extenders defining a color space for which the conversion is defined with respect to sRGB.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does is not 3, or either component size array
is non-null and has length not equal to 3.public boolean isRGBPreferredIntermediary()
true
if sRGB is preferred, or false
if CIEXYZ is preferred.public abstract WritableRaster fromCIEXYZ(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
CIEXYZ to the color space represented by this class.
If the destination WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
If required by the underlying transformation, integral data will be normalized according to the number of bits of the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does not equal the number of components of the
respective color space, or either component size array
is non-null and has length not equal to the number of
bands in the respective Raster
.public abstract WritableRaster fromRGB(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
sRGB to the color space represented by this class.
If the destination WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
If required by the underlying transformation, integral data will be normalized according to the number of bits of the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does not equal the number of components of the
respective color space, or either component size array
is non-null and has length not equal to the number of
bands in the respective Raster
.public abstract WritableRaster toCIEXYZ(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
the color space represented by this class to CIEXYZ.
If the destination WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
If required by the underlying transformation, integral data will be normalized according to the number of bits of the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does not equal the number of components of the
respective color space, or either component size array
is non-null and has length not equal to the number of
bands in the respective Raster
.public abstract WritableRaster toRGB(Raster src, int[] srcComponentSize, WritableRaster dest, int[] destComponentSize)
Raster
from
the color space represented by this class to sRGB.
If the destination WritableRaster
is null
,
a new WritableRaster
will be created. The
Raster
s are treated as having no alpha channel, i.e.,
all bands are color bands.
If required by the underlying transformation, integral data will be normalized according to the number of bits of the respective component; floating point data should be between 0.0 and 1.0. All integral data are assumed to be unsigned; signed data should be shifted by the caller before invoking this method.
src
- the source Raster
to be converted.srcComponentSize
- array that specifies the number of significant
bits per source color component; ignored for floating point data.
If null
defaults to the value returned by
src.getSampleModel().getSampleSize()
.dest
- the destination WritableRaster
,
or null
.destComponentSize
- array that specifies the number of significant
bits per destination color component; ignored for floating point
data. If null
defaults to the value returned by
dest.getSampleModel().getSampleSize()
, or the sample
size of the newly created destination WritableRaster if dest is
null.dest
color converted from src
or a new, WritableRaster
containing the converted
pixels if dest
is null
.src
is
null
, the number of source or destination
bands does not equal the number of components of the
respective color space, or either component size array
is non-null and has length not equal to the number of
bands in the respective Raster
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |