[cairo] high-fidelity anti-aliasing in Cairo/libpixman?

Bill Spitzak spitzak at d2.com
Mon Nov 8 11:05:23 PST 2004


On Friday 05 November 2004 05:19 pm, Leon Woestenberg wrote:

> I think in order to enhance Cairo's output even further, it should
> deploy weighted area sampling (optimally, where the weighing function
> is target dependent - for example, CRTs have different pixels than
> TFT's do - this can be exploited by the weighting function.)

Another thing to consider is to calculate the antialiasing and compositing 
using "linear" light levels rather than sRGB. I describe this here:

	http://mysite.verizon.net/spitzak/conversion/index.html

Here are some example images and is more relevant to Cairo:

	http://mysite.verizon.net/spitzak/conversion/transform.html

Currently in sRGB the box filtering produces a result more similar to 
sampling theory when you draw black on white (actually it goes too far). 
However when drawing white on black it produces exactly the opposite, further 
away than a linear box filter (which is what the diagrams in the above link 
use).

Linear compositing could be achieved by keeping the source image in sRGB but 
*not* premultiplied, and alpha calculated just as before. The only change 
would be to change the compositing math. However I have not thought of any 
way to merge sRGB 8-bit samples quickly except by making a huge 2^24 byte 
lookup table. The conversion from sRGB to linear can be approximated by 
squaring the number, so compositing A (non-premultiplied) over B with alpha a 
is approximated by:

	sqrt(A*A*a+B*B*(1-a))

Maybe somebody can figure out a hack with binary shifts that gets 
approximately this result. And of course some graphics cards can do this 
directly at enough speed.

Also I note on the second page linked above, there are problems with text, 
where people expect decidely non-linear results. This may mean that text must 
be composited normally...



More information about the cairo mailing list