Quartz supports the standard color spaces used by color management systems for device-independent color spaces and also supports generic, indexed, and pattern, color spaces. Device-independent color spaces represent color in a way that is portable between devices. They are used for the interchanges of color data from the native color space of one device to the native color space of another device. Colors in a device-independent color space appear the same when displayed on different devices, to the extent that the capabilities of the device allow. For that reason, device-independent color spaces are your best choice for representing color.
Applications that have precise color requirements should always use a device-independent color space. A common device independent color space is the generic color space. Generic color spaces let Mac OS X provide the best color space for your application. Drawing to the display will look as good as printing the same content to a printer.
Device color spaces (DeviceGray, DeviceRGB, and DeviceCMYK) are tied to the system of color representation for a particular device. Because these color spaces are not portable between devices, they are no longer recommended as of Mac OS X v10.4. If your application runs in earlier versions of Mac OS X, it’s best to use device-independent color spaces instead of device-dependent ones. If your application runs in Mac OS X v10.4 and later, you can use device-independent color spaces or generic color spaces.
Creating Device-Independent Color Spaces
Creating Generic Color Spaces
Creating Device Color Spaces (Deprecated in Mac OS X v10.4)
Creating Indexed and Pattern Color Spaces
To create a device-independent color space, you provide Quartz with the reference white point, reference black point, and gamma values for a particular device. Quartz uses this information to convert colors from your source color space into the color space of the output device.
The device-independent color spaces supported by Quartz, and the functions that create them are:
L*a*b* is a nonlinear transformation of the Munsell color notation system (a system which specifies colors by hue, value, and saturation—or chroma —values) that matches perceived color difference with quantitative distance in color space. The L* component represents the lightness value, the a* component represents values from green to red, and the b* component represents values from blue to yellow. This color space is designed to mimic how the human brain decodes color. Use the function CGColorSpaceCreateLab.
ICC is a color space from an ICC color profile, as defined by the International Color Consortium. ICC profiles define the gamut of colors supported by a device along with other device characteristics so that this information can be used to accurately transform the color space of one device to the color space of another. The manufacturer of the device typically provides an ICC profile. Some color monitors and printers contain embedded ICC profile information, as do some bitmap formats such as TIFF. Use the function CGColorSpaceCreateICCBased.
Calibrated RGB is a device-independent RGB color space that represents colors relative to a reference white point that is based on the whitest light that can be generated by the output device. Use the function CGColorSpaceCreateCalibratedRGB.
Calibrated gray is a device-independent grayscale color space that represents colors relative to a reference white point that is based on the whitest light that can be generated by the output device. Use the function CGColorSpaceCreateCalibratedGray.
Generic color spaces leave color matching to the system. For most cases, the result is acceptable. Although the name may imply otherwise, each “generic” color space—GenericGray, GenericRGB, and GenericCMYK—is a specific device-independent color space.
Generic color spaces are easy to use; you don’t need to supply any reference point information. You create a generic color space by using the function CGColorSpaceCreateWithName along with one of the following constants:
kCGColorSpaceGenericGray, which specifies GenericGray, a monochromatic color space that permits the specification of a single value ranging from absolute black (value 0.0) to absolute white (value 1.0).
kCGColorSpaceGenericRGB, which specifies GenericRGB, a three-component color space (red, green, and blue) that models the way an individual pixel is composed on a color monitor. Each component of the RGB color space ranges in value from 0.0 (zero intensity) to 1.0 (full intensity).
kCGColorSpaceGenericCMYK, which specifies Generic CMYK, a four-component color space (cyan, magenta, yellow, and black) that models the way ink builds up during printing. Each component of the CMYK color space ranges in value from 0.0 (does not absorb the color) to 1.0 (fully absorbs the color).
For historical purposes, these are the functions that create device-dependent color spaces in Mac OS X v10.3 and earlier:
CGColorSpaceCreateDeviceGray for DeviceGray.
CGColorSpaceCreateDeviceRGB for DeviceRGB.
CGColorSpaceCreateDeviceCMYK for DeviceCMYK.
Indexed color spaces contain a color table with up to 256 entries, and a base color space to which the color table entries are mapped. Each entry in the color table specifies one color in the base color space. Use the function CGColorSpaceCreateIndexed.
Pattern color spaces, discussed in “Patterns,” are used when painting with patterns. Use the function CGColorSpaceCreatePattern. The pattern color space is available in Mac OS X v10.1 and later.
Last updated: 2007-12-11