[cairo] Color space API

Bill Spitzak spitzak at gmail.com
Fri Jul 27 13:19:58 PDT 2012

In your plan, if an on-screen surface is given colorspace X where X is 
not sRGB, what does this mean? I think this is what leads to a lot of 
the confusion when color space is discussed.

IMHO the solution is that the numbers in that surface are put unchanged 
on the screen. Thus no matter what colorspace it is set to, if there is 
a 5 in the red channel of a pixel, then a 5 is put into the output 
buffer sent to the screen.

The way to get color-correct output is to set the destination surface to 
the colorspace that the screen (or the input to the screen driver) has. 
Changing the destination colorspace never changes the appearance of that 
surface on the screen.

What the colorspace of the destination does is indicate what conversion 
is done to source colorspaces before compositing. The destination can be 
set to Y and the source to X, and what happens is the source is run 
through the X->Y conversion before compositing. However after the 
numbers come out of the compositing, the setting of Y has NO effect on 
what happens to those numbers. They go onto the screen or output device 

Any other interpretation I think results in unworkable difficulties.


Another aspect is "linear" or "gamma corrected" compositing. In this 
both the source *AND* the destination are converted from their spaces to 
a "linear" space, composited, and then the result is converted back to 
the destination space. The linear space is chosen so this conversion is 
fast (it has the same primaries as the destination).

I believe your proposal has no possible setting that will cause this to 
happen. I think this can be a different setting, independent of the 
destination color space. Either it is a flag on the destination 
surfaces, or it is different compositing operations (ie LINEAR_OVER 
verses OVER). I don't think it is part of the colorspace, because it has 
no effect on how the source is handled.

Adrian Johnson wrote:
> To experiment with color space API in cairo I've developed a very basic
> implementation of the API in my cairo and pixman repositories[2].

More information about the cairo mailing list