Important: The information in this document is obsolete and should not be used for new development.
Converting Between Color Spaces
Color conversion, which does not require the use of color profiles, is a much simpler process than color matching. The ColorSync Manager provides functions your application can call to convert a list of colors within the same base family--that is, between a base color space and any of its derived color spaces or between two derivatives of the same base family.You can convert a list of colors between XYZ and any of its derived color spaces, which include L*a*b*, L*u*v*, and Yxy, or between any two of the derived color spaces. You can also convert colors defined in the XYZ color space between
CMXYZColor
data types in which the color components are expressed as 16-bit unsigned values andCMFixedXYZColor
data types in which the colors are expressed as 32-bit signed values.You can convert a list of colors between RGB, which is the base-additive device-dependent color space, and any of its derived color spaces, such as HLS, HSV, and Gray, or between any two of the derived color spaces.
Here are brief descriptions of the XYZ color space and its derivative color spaces:
- Note
- The color conversion functions do not support conversion of HiFi colors.
Here are brief descriptions of the RGB color space and its derivative color spaces:
- The XYZ space, referred to as the interchange color space, is the fundamental, or base CIE-based independent color space.
- The L*a*b* color space is a CIE-based independent color space used for representing subtractive systems, where light is absorbed by colorants such as inks and dyes. The L*a*b* color space is derived from the XYZ color space. The default white point for the L*a*b* interchange space is the D50 white point.
- The L*u*v* color space is a CIE-based color space used for representing additive color systems, including color lights and emissive phosphor displays. The L*u*v* color space is derived from the XYZ color space.
- The Yxy color space expresses the XYZ values in terms of x and y chromaticity coordinates, somewhat analogous to the hue and saturation coordinates of HSV space. This allows color variation in Yxy space to be plotted on a two-dimensional diagram.
- The XYZ color space includes two XYZ data type formats. The
CMFixedXYZColor
data type uses the Fixed data type for each of the three components. Fixed is a signed 32-bit value. TheCMFixedXYZColor
data type is also used in the ColorSync Manager 2.x profile header (page 3-43).TheCMXYZColor
data type uses 16-bit values for each component.
To convert colors from one color space to another, you don't need to specify source and destination profiles. Instead, you just call the appropriate ColorSync Manager function to convert between the desired color spaces.
- The RGB color space is a three-dimensional color space whose components are the red, green, and blue intensities that make up a given color.
- The HLS and HSV color spaces belong to the family of RGB-based color spaces, which are directly supported by most color displays and scanners.
- Gray spaces typically have a single component, ranging from black to white. The Gray color space is used for black-and-white and grayscale display and printing.
- Note
- Prior to version 2.1, the ColorSync Manager used a component to implement color conversion. An application had to open a connection to the component with the Component Manager, then pass the component instance as a parameter to the color conversion functions. For example, the CMXYZToLab function performs the same conversion as
CMConvertXYZToLab
, but takes a first parameter ofComponentInstance ci
- For backward compatibility, component-based color conversion functions such as CMXYZToLab are still supported. However, their use is discouraged, and they are not guaranteed to work in future versions.