If I write drawing code in Core Graphics on Mac OS X or iPhone OS, I can set the color of the active fill to red by calling:
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
If I want a 50% gray color, I can call:
CGContextSetRGBFillColor(context, 0.5, 0.5, 0.5, 1.0);
But for shades of gray, it is tempting to make a shorter line and call:
CGContextSetGrayFillColor(context, 0.5, 1.0);
However, this function is NOT just a call to the RGB method with an intensity value copied three times; instead, it changes the color space of the context from DeviceRGB to DeviceGray. The next call to the RGB method will switch it.
I am interested to know:
- What is the punishment for switching color spaces?
- Is there a fine for painting if your context color space does not match your device color space? (i.e., in DeviceGray and DeviceRGB)
, , , , .