Creates an indexed color space, consisting of colors specified by a color lookup table.
SDKs
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Core Graphics
Declaration
CGColor Space Ref CGColorSpaceCreateIndexed(CGColor Space Ref baseSpace, size _t lastIndex, const unsigned char *colorTable);
Parameters
baseSpace
The color space on which the color table is based.
lastIndex
The maximum valid index value for the color table. The value must be less than or equal to 255.
colorTable
An array of
m*(last
bytes, whereIndex+1) m
is the number of color components in the base color space. Each byte is an unsigned integer in the range0
to255
that is scaled to the range of the corresponding color component in the base color space.
Return Value
A new indexed color space object. You are responsible for releasing this object by calling CGColor
. If unsuccessful, returns NULL
.
Discussion
An indexed color space contains a color table with up to 255 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 value in an indexed color space is treated as an index into the color table of the color space. The data in the table is in meshed format. (For example, for an RGB color space the values are R, G, B, R, G, B, and so on.)