[cairo] Semantics of transparent objects on opaque targets (image
vs. PostScript)
Bill Spitzak
spitzak at d2.com
Wed Jan 18 00:19:54 PST 2006
My thoughts on this black/white for clear issue:
I would propose that Cairo act like the printer at all times on all
devices. RGB surfaces would act exactly like RGBA surfaces except the
resulting color would be as though the RGBA was composited over white.
The main reason for using white is so that mistakes don't use up lots of
ink in a printer.
This means that compositing calculations that output a color c and an
alpha a, the RGB output should be C = c-a+1. If the a is kept around,
you can recover the c by c = C+a-1. Substituting this into the
compositing calculations will drop out any reference to this a value
when calculating a new value for the RGB result.
For instance if an RGBA foreground image is A,a and the RGB background
is B (where B=b+1-z where b,z is the background color if it was RGBA),
an OVER operation should produce a new background value C:
C = (A+b(1-a))+1-(a+z(1-a))
= A+(b+1-z)(1-a)
= A+B(1-a)
Note that z has disappeared and is not used in the calculation.
If the alpha of the RGB surface is needed, it should act as though the
alpha is 1. Thus clearing an RGB surface and then using it as a source
for an OVER will draw a white rectangle on the destination. Any other
solution would require the RGB surface to remember the alpha.
More information about the cairo
mailing list