ColorSync Color Matching on Intel-based Macs

Q: Do I need to byte-swap my bitmap before performing color matching with the ColorSync APIs on an Intel-based Macintosh?

A: If you are using CWMatchColors then make sure the values in the array of CMColors are in host endian order.

If you are using CWMatchBitmap, the CMBitmapColorSpace field of the source and destination CMBitmap structs can be flagged with cmLittleEndianPacking.

IMPORTANT: The cmLittleEndianPacking flag only indicates the color component values are in little endian order and does not indicate the order of components within a pixel. You will only need to use this flag if you are working with 16 bits per component pixel formats.

The ColorSync APIs only accept data in canonical component order (RGB is R,G,B, CMYK is C,M,Y,K, and so on).

For example, if you have a "Green" CMYK pixel seen as 0x00FF00FF on an Intel-based Mac you will need to swap it before (and possibly after) calling ColorSync. Specifying cmLittleEndianPacking in the CMBitmapColorSpace field of the source and destination CMBitmap structs will not help in this case because the pixel is represented by 8 bits per component.

Should you need to swap the component order within a pixel we recommend you use the CMFloatBitmap structure which is very flexible with regard to component ordering and even allows for planar bitmaps. See Technical Note 2035 ColorSync on Mac OS X for more information.

ICC Profiles need not and should not be changed to swap pixel data. The ICC specification (see International Color Consortium) provides for big-endian data in profiles and for component data to be in canonical order.

Document Revision History

2006-03-16First Version

Posted: 2006-03-16

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.