[cairo] Cairo gradients and pre-mul data

Bill Spitzak spitzak at d2.com
Tue Jun 20 17:23:19 PDT 2006


This sounds like a gradient from transparent to solid white composited 
OVER a black background will produce a different image than a gradient 
from solid black to solid white. If so, this is probably not a good idea!

If the source is a gradient and OVER is the operation, it should act 
like the gradient is premultiplied. You can get a non-premultiplied 
gradient by using COPY and using the gradient also as the mask input (at 
least this should be possible, I'm not sure if the Cairo api allows it).

Using COPY and the same image as the mask also works for getting 
non-premultiplied images to composite correctly.

In many ways this is easier and more intuitive than trying to define 
what type of data the source buffer contains. The only loss is that you 
cannot composite a non-premultiplied image through a mask. But this 
could be solved by adding an api to allow several masks to be 
intersected and used as a mask, which would also be much more useful 
than an api to set the source surface premultiplied setting.

The 4 numbers used to set the gradient stops should not be treated as 
having any meaning. All 4 should be interpolated using exactly the same 
math, with no crosstalk.

Carl Worth wrote:
> On Tue, 20 Jun 2006 21:58:31 GMT, "jose_ogp at juno.com" wrote:
>> 	While Cairo seems to be faithfully committed to using 
>> alpha-pre-multiplied color data when transforming and compositing 
>> 'surfaces', it seems that when generating the 'spectrum' of a 
>> gradient it assumes non pre-mul color data, does its linear 
>> interpolation with such, and only then pre-muls the results. 
>


More information about the cairo mailing list