[cairo] Color space API

Bill Spitzak spitzak at gmail.com
Fri Aug 3 11:39:45 PDT 2012


Francois Robert wrote:

>> The color space setting of any destination image, such as an on-screen
>> window, has ZERO effect on how numbers stored in that image are placed
>> onto the screen. In the typical case where the destination image is 3
>> 8-bit channels, and your screen's buffer is 3 8-bit channels, the
>> numbers for opaque pixels are copied UNCHANGED from the destination
>> image to the screen buffer.
> I am not sure what you call "screen buffer". I believe it is an OS responsibility to alter color values passed to your video card, in accordance to the colorspace definition for your -calibrated- display. If by "screen buffer" you intend the array of values passed to the OS for blitting, then I believe you are more or less correct. If by "screen buffer" you intend the memory internal to the video card which is accessed by the DACs when they construct the signal sent down a VGA wire to the display, I believe you are wrong.

Yes, the OS/Driver can do some more mapping between the final image that 
cairo draws and the hardware. However this mapping is not affected by 
the cairo destination color space.

>> This also means that changing the colorspace of a destination image is
>> allowed, and does NOTHING to these numbers and nothing to what you see
>> on the screen. Changing to any colorspace and then back to the original
>> colorspace is always a lossless operation.
> Hmmm. I don't think so.

You are talking about the conversion from the source color space to the 
destination color space.

What I am saying is that changing the destination color space does 
nothing to the destination image buffer. All it does is alter the 
conversion that *will* be done if a source is composited into that 
destination.

If you really want to change an image to a new color space, this will 
require copying it as a source to a new destination (ie using the copy 
op in cairo).

It is not clear if the color space is actually attached to surfaces, or 
that instead the source/dest color spaces are just part of the cairo_t 
state. If it is the latter it may be possible to alter a surface 
in-place by copying to itself with the source and destination color 
spaces different.


More information about the cairo mailing list