PATHDocumentation > Mac OS 8 and 9 > Mutlimedia and Graphics > ColorSync Manager >

Managing Color With ColorSync


Color Values

The ColorSync Manager defines the following data types for storing standard color values:


CMXYZComponent

Three components combine to express a color value defined by the CMXYZColor type definition in the XYZ color space. Each color component is described by a numeric value defined by the CMXYZComponent type definition. A component value of type CMXYZComponent is expressed as a 16-bit value. This is formatted as an unsigned value with 1 bit of integer portion and 15 bits of fractional portion.

typedef unsigned short CMXYZComponent;  /* expresses value in XYZ color space; 1 bit
                                            for integer part, 15 bits for fraction */

CMXYZColor

Three color component values defined by the CMXYZComponent type definition combine to form a color value specified in the XYZ color space. The color value is defined by the CMXYZColor type definition.

Your application uses the CMXYZColor data structure to specify a color value in the CMColor union to use in general purpose color matching, color checking, or color conversion. You also use the CMXYZColor data structure to specify the XYZ white point reference used in the conversion of colors to or from the XYZ color space.

struct CMXYZColor {
    CMXYZComponent  X;  /* X component of color in XYZ color space */
    CMXYZComponent  Y;  /* Y component of color in XYZ color space */
    CMXYZComponent  Z;  /* Z component of color in XYZ color space */
};

CMFixedXYZColor

ColorSync uses the CMFixedXYZColor data type to specify the profile illuminant in the profile header's white field and to specify other profile element values. Color component values defined by the Fixed type definition can be used to specify a color value in the XYZ color space with greater precision than a color whose components are expressed as CMXYZComponent data types. The Fixed data type is a signed 32-bit value. A color value expressed in the XYZ color space whose color components are of type Fixed is defined by the CMFixedXYZColor type definition.

Your application can convert colors defined in the XYZ color space between CMXYZColor data types (in which the color components are expressed as 16-bit unsigned values) and CMFixedXYZColor data types (in which the colors are expressed as 32-bit signed values). To convert color values, you use the functions CMConvertFixedXYZToXYZ and CMConvertXYZToFixedXYZ .

struct CMFixedXYZColor {
    Fixed   X;  /* Fixed X component of color in XYZ color space */
    Fixed   Y;  /* Fixed Y component of color in XYZ color space */
    Fixed   Z;  /* Fixed Z component of color in XYZ color space */
};

CMLabColor

A color expressed in the L*a*b* color space is composed of L , a , and b component values. The L color component is expressed as a numeric value within the range of 0 to 65535, which maps to 0 to 100 inclusive. Note that this encoding is slightly different from the 0 to 65280 encoding of the L channel defined in the ICC specification for PCS L*a*b values. The a and b components range from 0 to 65535, which maps to -128 to 127.996 inclusive. The color value is defined by the CMLabColor type definition.

struct CMLabColor {
    unsigned short  L;  /* L component of color in Lab color space */
    unsigned short  a;  /* a component of color in Lab color space */
    unsigned short  b;  /* b component of color in Lab color space */
};

CMLuvColor

A color value expressed in the L*u*v* color space is composed of L , u , and v component values. Each color component is expressed as a numeric value within the range of 0 to 65535. For the L component, this maps to 0 to 100 inclusive. For the u and v components, this maps to -128 to 127.996 inclusive. The color value is defined by the CMLuvColor type definition.

struct CMLuvColor {
    unsigned short  L;  /* L component of color in Luv color space */
    unsigned short  u;  /* u component of color in Luv color space */
    unsigned short  v;  /* v component of color in Luv color space */
};

CMYxyColor

A color value expressed in the Yxy color space is composed of capY , x , and y component values. Each color component is expressed as a numeric value within the range of 0 to 65535 which maps to 0 to 1. The color value is defined by the CMYxyColor type definition

struct CMYxyColor {
    unsigned short  capY;   /* 0..65535 maps to 0..1 */
    unsigned short  x;      /* 0..65535 maps to 0..1 */
    unsigned short  y;      /* 0..65535 maps to 0..1 */
};

CMRGBColor

A color value expressed in the RGB color space is composed of red , green , and blue component values. Each color component is expressed as a numeric value within the range of 0 to 65535.

struct CMRGBColor {
    unsigned short  red;        
    unsigned short  green;      
    unsigned short  blue;   
};

CMHLSColor

A color value expressed in the HLS color space is composed of hue , lightness , and saturation component values. Each color component is expressed as a numeric value within the range of 0 to 65535 inclusive. The hue value represents a fraction of a circle in which red is positioned at 0.

struct CMHLSColor {
    unsigned short  hue;            
    unsigned short  lightness;      
    unsigned short  saturation;     
};

CMHSVColor

A color value expressed in the HSV color space is composed of hue , saturation , and value component values. Each color component is expressed as a numeric value within the range of 0 to 65535 inclusive. The hue value represents a fraction of a circle in which red is positioned at 0.

struct CMHSVColor {
    unsigned short  hue;            
    unsigned short  saturation;     
    unsigned short  value;          
};

CMCMYKColor

A color value expressed in the CMYK color space is composed of cyan , magenta , yellow , and black component values. Each color component is expressed as a numeric value within the range of 0 to 65535 inclusive.

struct CMCMYKColor {
    unsigned short  cyan;       
    unsigned short  magenta;    
    unsigned short  yellow;     
    unsigned short  black;      
};

CMCMYColor

A color value expressed in the CMY color space is composed of cyan , magenta , and yellow component values. Each color component is expressed as a numeric value within the range of 0 to 65535 inclusive.

struct CMCMYColor {
    unsigned short  cyan;       
    unsigned short  magenta;    
    unsigned short  yellow;     
};

CMGrayColor

A color value expressed in the Gray color space is composed of a single component, gray , represented as a numeric value within the range of 0 to 65535 inclusive.

struct CMGrayColor {
    unsigned short  gray;                   
};

CMNamedColor

A color value expressed in a named color space is composed of a single component, namedColorIndex , represented as a numeric value within the range of an unsigned long, or 1 to 232 - 1 inclusive.

struct CMNamedColor {
    unsigned long namedColorIndex;  /* 1..a lot */
};

HiFi Color Values

A color expressed in one of the multichannel color spaces with 5, 6, 7, or 8 channels. The color value for each channel component is expressed as an unsigned byte of type char .

struct CMMultichannel5Color {
    unsigned char   components[5];
};
struct CMMultichannel6Color {
    unsigned char   components[6];
};
struct CMMultichannel7Color {
    unsigned char   components[7];
};
struct CMMultichannel8Color {
    unsigned char   components[8];
};

CMColor

Your application can use a union of type CMColor to specify a color value defined by one of the 15 data types supported by the union. Your application uses an array of color unions to specify a list of colors to match, check, or convert. The array is passed as a parameter to the general purpose color matching, color checking, or color conversion functions. The following functions use a color union:

IMPORTANT

You do not use a union of type CMColor to convert colors expressed in the XYZ color space as values of type CMFixedXYZ because the CMColor union does not support the CMFixedXYZ data type.

The color union is defined by the CMColor type definition. Each of the color types included in the union is defined previously.

union CMColor {
    CMRGBColor              rgb;
    CMHSVColor              hsv;
    CMHLSColor              hls;
    CMXYZColor              XYZ;
    CMLabColor              Lab;
    CMLuvColor              Luv;
    CMYxyColor              Yxy;
    CMCMYKColor             cmyk;
    CMCMYColor              cmy;
    CMGrayColor             gray;
    CMMultichannel5Color    mc5;
    CMMultichannel6Color    mc6;
    CMMultichannel7Color    mc7;
    CMMultichannel8Color    mc8;
    CMNamedColor            namedColor;
};

A color union can contain one of the following fields.


Field descriptions

rgb
A color value expressed in the RGB color space as data of type CMRGBColor .
hsv
A color value expressed in the HSV color space as data of type CMHSVColor .
hls
A color value expressed in the HLS color space as data of type CMHLSColor .
XYZ
A color value expressed in the XYZ color space as data of type CMXYZColor .
Lab
A color value expressed in the L*a*b* color space as data of type CMLabColor .
Luv
A color value expressed in the L*u*v* color space as data of type CMLuvColor .
Yxy
A color value expressed in the Yxy color space as data of type CMYxyColor .
cmyk
A color value expressed in the CMYK color space as data of type CMCMYKColor .
cmy
A color value expressed in the CMY color space as data of type CMCMYColor .
gray
A color value expressed in the Gray color space as data of type CMGrayColor .

mc5
A color value expressed in the five-channel multichannel color space as data of type CMMultichannel5Color . See HiFi Color Values for a description of the CMMultichannel5Color data type.
mc6
A color value expressed in the six-channel multichannel color space as data of type CMMultichannel6Color . See HiFi Color Values for a description of the CMMultichannel6Color data type.
mc7
A color value expressed in the seven-channel multichannel color space as data of type CMMultichannel7Color . See HiFi Color Values for a description of the CMMultichannel7Color data type.
mc8
A color value expressed in the eight-channel multichannel color space as data of type CMMultichannel8Color . See HiFi Color Values for a description of the CMMultichannel8Color data type.
namedColor
A color value expressed as an index into a named color space. See CMNamedColor for a description of the CMNamedColor data type.

© 1988-1999 Apple Computer, Inc. — (Last Updated 20 Jan 99)