Package snap.gfx

Class ColorSpace

java.lang.Object
snap.gfx.ColorSpace

public abstract class ColorSpace extends Object
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

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    The ColorSpaceFactory.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    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.html
    static 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

    Constructors
    Modifier
    Constructor
    Description
    protected
    ColorSpace(int type, int numcomponents)
    Constructs a ColorSpace object given a color space type and the number of components.
  • Method Summary

    Modifier and Type
    Method
    Description
    static ColorSpace
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TYPE_Lab

      public static final int TYPE_Lab
      Any of the family of Lab color spaces.
      See Also:
    • TYPE_RGB

      public static final int TYPE_RGB
      Any of the family of RGB color spaces.
      See Also:
    • TYPE_GRAY

      public static final int TYPE_GRAY
      Any of the family of GRAY color spaces.
      See Also:
    • TYPE_CMYK

      public static final int TYPE_CMYK
      Any of the family of CMYK color spaces.
      See Also:
    • TYPE_CMY

      public static final int TYPE_CMY
      Any of the family of CMY color spaces.
      See Also:
    • TYPE_2CLR

      public static final int TYPE_2CLR
      Generic 2 component color spaces.
      See Also:
    • TYPE_3CLR

      public static final int TYPE_3CLR
      Generic 3 component color spaces.
      See Also:
    • TYPE_4CLR

      public static final int TYPE_4CLR
      Generic 4 component color spaces.
      See Also:
    • TYPE_5CLR

      public static final int TYPE_5CLR
      Generic 5 component color spaces.
      See Also:
    • CS_sRGB

      public static final int CS_sRGB
      The 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_RGB
      A 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_CIEXYZ
      The CIEXYZ conversion color space defined above.
      See Also:
    • CS_GRAY

      public static final int CS_GRAY
      The built-in linear gray scale color space.
      See Also:
    • _factory

      public static ColorSpace.ColorSpaceFactory _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

      public String getName(int idx)
      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

      public static ColorSpace getInstance(int aCS)
      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

      public static ColorSpace createColorSpaceICC(Object aSource)
      Create ICC ColorSpace from source (stream or bytes)