[cairo] simulating partial coverage with alpha

mental at rydia.net mental at rydia.net
Thu Mar 10 16:06:57 PST 2005


Quoting Nathan Hurst <njh at hawthorn.csse.monash.edu.au>:

> This is due to computing the colours in the wrong space AFAICT.
> I don't think you get these if you live in sRGB or CIE.  Even
> getting the gamma right probably solves 90% of this.

Gamma and color space issues make it more obvious, but it's not just
those... the background color is contributing to the color of the
fringe.

You can verify this by trying different background colors behind the
adjacent shapes -- these "fringe" pixels will vary in color
accordingly.

Thought experiment: imagine a pixel exactly half covered by one
shape S1 of color C1, and the remaining half exactly covered by
another shape S2 of color C2, over a background of color C3.

Assuming S1 and S2 aren't translucent, a visually acceptable
result will require that the pixel's color is a (reasonable)
function of just C1 and C2.

However, if you assign alpha values as a function of pixel coverage
when rasterizing S1 and S2, and then try to composite them in turn
over the background, C3 will always contribute to the color of any
pixel not 100% covered by at least one of the shapes (for any
compositing rules that don't also break normal alpha behavior),
even if it's in a place where, geometrically, there is no gap.

I'm not suggesting Cairo should abandon using alpha to simulate
partial coverage when rasterizing (it works well enough for most
cases), but I would like to be able to turn it off (at least for
image surfaces) when I need to to avoid these kinds of artifacts in
preference to avoiding aliasing (since I can filter afterwards).

Or am I missing something here?

-mental



More information about the cairo mailing list