A profile that specifies how to interpret a color value for display.


A color space is multi-dimensional, and each dimension represents a specific color component. For example, the colors in an RGB color space have three dimensions or components—red, green, and blue. The intensity of each component is represented by floating point values—their range and meaning depends on the color space in question.

Different types of devices (scanners, monitors, printers) operate within different color spaces (RGB, CMYK, grayscale). Additionally, two devices of the same type (for example, color displays from different manufacturers) may operate within the same kind of color space, yet still produce a different range of colors, or gamut. Color spaces that are correctly specified ensure that an image has a consistent appearance regardless of the output device.

Core Graphics supports several kinds of color spaces:

  • Calibrated color spaces ensure that colors appear the same when displayed on different devices. The visual appearance of the color is preserved, as far as the capabilities of the device allow.

  • Device-dependent color spaces are tied to the system of color representation of a particular device. Device color spaces are not recommended when high-fidelity color preservation is important.

  • Special color spaces—indexed and pattern. An indexed color space contains 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. A pattern color space is used when stroking or filling with a pattern.


Creating Device-Independent Color Spaces

init?(iccBasedNComponents: Int, range: UnsafePointer<CGFloat>?, profile: CGDataProvider, alternate: CGColorSpace?)

Creates a device-independent color space that is defined according to the ICC color profile specification.

init?(iccProfileData: CFData)

Creates an ICC-based color space using the ICC profile contained in the specified data.

init?(labWhitePoint: UnsafePointer<CGFloat>!, blackPoint: UnsafePointer<CGFloat>!, range: UnsafePointer<CGFloat>!)

Creates a device-independent color space that is relative to human color perception, according to the CIE L*a*b* standard.

Creating Generic or Device-Dependent Color Spaces

func CGColorSpaceCreateDeviceCMYK()

Creates a device-dependent CMYK color space.

func CGColorSpaceCreateDeviceGray()

Creates a device-dependent grayscale color space.

func CGColorSpaceCreateDeviceRGB()

Creates a device-dependent RGB color space.

init?(platformColorSpaceRef: UnsafeRawPointer)

Creates a platform-specific color space.

Creating Special Color Spaces

init?(indexedBaseSpace: CGColorSpace, last: Int, colorTable: UnsafePointer<UInt8>)

Creates an indexed color space, consisting of colors specified by a color lookup table.

init?(patternBaseSpace: CGColorSpace?)

Creates a pattern color space.

init?(name: CFString)

Creates a specified type of Quartz color space.

Getting Information About Color Spaces

var iccData: CFData?

Returns a copy of the ICC profile of the provided color space.

func copyICCData()

Returns a copy of the ICC profile data of the provided color space.

var supportsOutput: Bool

Returns a Boolean indicating whether the color space can be used as a destination color space.

var numberOfComponents: Int

Returns the number of color components in a color space.

class var typeID: CFTypeID

Returns the Core Foundation type identifier for Quartz color spaces.

var model: CGColorSpaceModel

Returns the color space model of the provided color space.

var isWideGamutRGB: Bool

Returns whether the RGB color space covers a significant portion of the NTSC color gamut.

var baseColorSpace: CGColorSpace?

Returns the base color space of a pattern or indexed color space.

var name: CFString?

Returns the name used to create the specified color space.

Data Types


Models for color spaces.


Handling options for colors that are not located within the destination color space of a graphics context.


A profile that specifies how to interpret a color value for display.


Color Space Names

Convenience constants for commonly used color spaces.