[cairo] Compositing strategies and pre-multiplied alpha

Russell Shaw rjshaw at netspace.net.au
Wed Sep 21 17:29:38 PDT 2005


Mauricio Piacentini wrote:
> I need some help understanding the rationale behind using pre-multiplied
> alpha in a graphics API, and I understand this is used in Cairo image 
> surfaces, according to the docs. Please understand I am not questioning 
> this decision, just trying to grasp the implications of this method as 
> far as my particular needs are concerned.
> Let me explain this better: suppose I want to display two rotated
> bitmaps and two svg files in the same screen, but animated. A possible
> optimization would be to maybe render each element to a different 
> surface, and then composite the resulting "sprites" in a final screen 
> surface. This way I would not have to re-render the svg data for example 
> or rotate the bitmap at every frame, unless I decide to rotate or scale 
> one of the elements. As long as I am simply moving the sprites in x and 
> y the caching of data as bitmaps would conceivably speed up things a 
> lot, right?
> The big question is: am I right to assume that doing the above (caching 
> the data as bitmaps with pre-multiplied alpha) will automatically reduce 
> the quality of antialiasing? The effect would probably not be noticeable 
> on a black background, but if I composite one cached bitmap on top of 
> another I will have a drop in antialiasing quality, wouldn't I? Or is 
> this not important as long as I move my sprites in whole pixel 
> increments (subpixel is obviously not possible in a scenario like this.)

It is explained here: http://keithp.com/~keithp/porterduff/p253-porter.pdf


More information about the cairo mailing list