[cairo] four-channel alpha and destination alpha

Bill Spitzak spitzak at d2.com
Tue Feb 1 18:17:06 PST 2005


It might be better to think of the ClearType text as a single alpha 
channel, but at 3x higher horizontal resolution. Ignore the alpha and 
use the rgb values as the 3 pixels.

Owen Taylor wrote:
> So, I was thinking about whether it was possible to derive a RENDER-
> style 4-channel alpha mask from a ClearType image of text drawn
> white-on-black. And the obvious question was "how do you compute
> the right value for the A channel of the mask". Do you use 0xFF
> always? Do you use the max of the other channels? Do you average them?
> 
> But then I realized two things:
> 
>  - The A channel of the alpha mask is irrelevant when compositing
>    to a destination without alpha.
> 
>  - You won't get very useful results in any case if the destination
>    surface has alpha. Take a simple case ... draw text to an empty ARGB
>    surface, then composite that surface OVER a whitebackground. There's
>    no result for the ARGB surface that would give the same result as
>    compositing the text directly on the background.
> 
> Given those two ideas, the choice of using the average of the 
> other channels seems the best choice. There are some problems:
>  
>  - There is some color shifting ... if I draw pure FFFF0000
>    red through a ARGB mask onto a ARGB background, the result
>    will include pixels like 88AA00000 or AA880000. If I then
>    composite that onto a pure red surface, you'll get some
>    shadowing around the edges of the text.
> 
>  - You get super-luminous pixels like the above mentioned 
>    88AA0000. pixman handles that OK, but it's conceivable that
>    hardware-accelerated compositing paths would have difficulty.
> 
> Still, since correct behavior isn't possible, these issues seem
> acceptable and I don't think it's possible to do better.
> 
> Anyways, something I hadn't thought through before, so thrown out in
> case other people find it useful, or want to correct me.
> 
> Regards,
> 						Owen
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.freedesktop.org/mailman/listinfo/cairo



More information about the cairo mailing list