Q: What color spaces does CGBitmapContextCreate support?A: CGBitmapContextCreate supports the following combinations for the colorspace (CS), bitsPerComponent (BPC), and alphaInfo parameters: Note: This document has been superseded by the Quartz 2D Programming Guide. A table describing the currently supported pixel formats for a bitmap context is contained in the section that covers the creation of bitmap contexts. The rest of this Q&A represents valid parameter combinations available on Mac OS X 10.3 or later only. Table 1: Supported Combinations | CS | BPC | alphaInfo | Resulting Bits and Description |
|---|
| NULL | 8 | kCGImageAlphaOnly | AAAAAAAA8 bits per pixel alpha-only destination. Color data is thrown away. Useful for generating alpha-only bitmaps and masks.Available in Mac OS X 10.3 and later. | | Gray | 8 | kCGImageAlphaNone | WWWWWWWW8 bits per pixel grayscale channel. | | RGB | 5 | kCGImageAlphaNoneSkipFirst | -RRRRRGGGGGBBBBB16 bits per pixel, 5 bits per RGB component. | | RGB | 8 | kCGImageAlphaNoneSkipFirst | --------RRRRRRRRRGGGGGGGGBBBBBBBB32 bits per pixel, 8 bits per RGB component where first 8 bits are ignored. | | RGB | 8 | kCGImageAlphaNoneSkipLast | RRRRRRRRRGGGGGGGGBBBBBBBB--------32 bits per pixel, 8 bits per RGB component where last 8 bits are ignored. | | RGB | 8 | kCGImageAlphaPremultipliedFirst | AAAAAAAARRRRRRRRRGGGGGGGGBBBBBBBB32 bits per pixel, 8 bits per ARGB component with premultiplied alpha. | | RGB | 8 | kCGImageAlphaPremultipliedLast | RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA32 bits per pixel, 8 bits per RGBA component with premultiplied alpha. | | CMYK | 8 | kCGImageAlphaNone | CCCCCCCCMMMMMMMMYYYYYYYYKKKKKKKK32 bits per pixel, 8 bits per CMYK component without alpha.Available in Mac OS X 10.3 and later. |
Note: To create an alpha-only bitmap context simply pass NULL for the colorspace parameter. Q&A 1369 describes how to create RGB, CYMK, Gray, and other color spaces while maintaining color matching. Table 2: and the resulting bits are designated as follows: | Bit | Description |
|---|
| W | White | | A | Alpha | | R | Red | | G | Green | | B | Blue | | C | Cyan | | M | Magenta | | Y | Yellow | | K | Black | | - | Skip |
Document Revision History| Date | Notes |
|---|
| 2007-07-18 | Updated to point to the Quartz 2D Programming Guide, minor text changes. | | 2005-10-04 | Updated to point to the Q&A describing how to properly create color spaces. Added a note that this Q&A is only valid for formats introduced in 10.3 and earlier. | | 2004-09-09 | Removed two combinations in the Gray color space that had been incorrectly documented as supported. | | 2004-02-20 | Lists the color space and alpha info combinations currently supported by CGBitmapContextCreate. |
Posted: 2007-07-18
|