Package snap.gfx
Class ColorSpace
java.lang.Object
snap.gfx.ColorSpace
This abstract class is used to serve as a color space tag to identify the
specific color space of a Color object or, via a ColorModel object,
of an Image, a BufferedImage, or a GraphicsDevice. It contains
methods that transform colors in a specific color space to/from sRGB
and to/from a well-defined CIEXYZ color space.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
The ColorSpaceFactory. -
Field Summary
Modifier and TypeFieldDescriptionstatic ColorSpace.ColorSpaceFactory
static final int
The CIEXYZ conversion color space defined above.static final int
The built-in linear gray scale color space.static final int
A built-in linear RGB color space.static final int
The sRGB color space defined at http://www.w3.org/pub/WWW/Graphics/Color/sRGB.htmlstatic final int
Generic 2 component color spaces.static final int
Generic 3 component color spaces.static final int
Generic 4 component color spaces.static final int
Generic 5 component color spaces.static final int
Any of the family of CMY color spaces.static final int
Any of the family of CMYK color spaces.static final int
Any of the family of GRAY color spaces.static final int
Any of the family of Lab color spaces.static final int
Any of the family of RGB color spaces. -
Constructor Summary
ModifierConstructorDescriptionprotected
ColorSpace
(int type, int numcomponents) Constructs a ColorSpace object given a color space type and the number of components. -
Method Summary
Modifier and TypeMethodDescriptionstatic ColorSpace
createColorSpaceICC
(Object aSource) Create ICC ColorSpace from source (stream or bytes)abstract float[]
fromCIEXYZ
(float[] colorvalue) Transforms a color value assumed to be in the CS_CIEXYZ conversion color space into this ColorSpace.abstract float[]
fromRGB
(float[] rgbvalue) Transforms a color value assumed to be in the default CS_sRGB color space into this ColorSpace.static ColorSpace
getInstance
(int aCS) Returns a ColorSpace representing one of the specific predefined color spaces.float
getMaxValue
(int comp) Returns the maximum normalized color component value for the specified component.float
getMinValue
(int comp) Returns the minimum normalized color component value for the specified component.getName
(int idx) Returns the name of the component given the component index.int
Returns the number of components of this ColorSpace.int
getType()
Returns the color space type of this ColorSpace (for example TYPE_RGB, TYPE_XYZ, ...).boolean
Returns true if the ColorSpace is CS_sRGB.abstract float[]
toCIEXYZ
(float[] colorvalue) Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space.abstract float[]
toRGB
(float[] colorvalue) Transforms a color value assumed to be in this ColorSpace into a value in the default CS_sRGB color space.
-
Field Details
-
TYPE_Lab
public static final int TYPE_LabAny of the family of Lab color spaces.- See Also:
-
TYPE_RGB
public static final int TYPE_RGBAny of the family of RGB color spaces.- See Also:
-
TYPE_GRAY
public static final int TYPE_GRAYAny of the family of GRAY color spaces.- See Also:
-
TYPE_CMYK
public static final int TYPE_CMYKAny of the family of CMYK color spaces.- See Also:
-
TYPE_CMY
public static final int TYPE_CMYAny of the family of CMY color spaces.- See Also:
-
TYPE_2CLR
public static final int TYPE_2CLRGeneric 2 component color spaces.- See Also:
-
TYPE_3CLR
public static final int TYPE_3CLRGeneric 3 component color spaces.- See Also:
-
TYPE_4CLR
public static final int TYPE_4CLRGeneric 4 component color spaces.- See Also:
-
TYPE_5CLR
public static final int TYPE_5CLRGeneric 5 component color spaces.- See Also:
-
CS_sRGB
public static final int CS_sRGBThe sRGB color space defined at http://www.w3.org/pub/WWW/Graphics/Color/sRGB.html- See Also:
-
CS_LINEAR_RGB
public static final int CS_LINEAR_RGBA built-in linear RGB color space. This space is based on the same RGB primaries as CS_sRGB, but has a linear tone reproduction curve.- See Also:
-
CS_CIEXYZ
public static final int CS_CIEXYZThe CIEXYZ conversion color space defined above.- See Also:
-
CS_GRAY
public static final int CS_GRAYThe built-in linear gray scale color space.- See Also:
-
_factory
-
-
Constructor Details
-
ColorSpace
protected ColorSpace(int type, int numcomponents) Constructs a ColorSpace object given a color space type and the number of components.
-
-
Method Details
-
isCS_sRGB
public boolean isCS_sRGB()Returns true if the ColorSpace is CS_sRGB. -
toRGB
public abstract float[] toRGB(float[] colorvalue) Transforms a color value assumed to be in this ColorSpace into a value in the default CS_sRGB color space. -
fromRGB
public abstract float[] fromRGB(float[] rgbvalue) Transforms a color value assumed to be in the default CS_sRGB color space into this ColorSpace. -
toCIEXYZ
public abstract float[] toCIEXYZ(float[] colorvalue) Transforms a color value assumed to be in this ColorSpace into the CS_CIEXYZ conversion color space. -
fromCIEXYZ
public abstract float[] fromCIEXYZ(float[] colorvalue) Transforms a color value assumed to be in the CS_CIEXYZ conversion color space into this ColorSpace. -
getType
public int getType()Returns the color space type of this ColorSpace (for example TYPE_RGB, TYPE_XYZ, ...). The type defines the number of components of the color space and the interpretation, e.g. TYPE_RGB identifies a color space with three components - red, green, and blue. It does not define the particular color characteristics of the space, e.g. the chromaticities of the primaries. -
getNumComponents
public int getNumComponents()Returns the number of components of this ColorSpace. -
getName
Returns the name of the component given the component index. -
getMinValue
public float getMinValue(int comp) Returns the minimum normalized color component value for the specified component. -
getMaxValue
public float getMaxValue(int comp) Returns the maximum normalized color component value for the specified component. -
getInstance
Returns a ColorSpace representing one of the specific predefined color spaces.- Parameters:
colorspace
- a specific color space identified by one of the predefined class constants (e.g. CS_sRGB, CS_LINEAR_RGB, CS_CIEXYZ, CS_GRAY, or CS_PYCC)
-
createColorSpaceICC
Create ICC ColorSpace from source (stream or bytes)
-