Re: [AD] premultiplied alpha

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 29 Oct 2010, at 16:36 , Elias Pschernig wrote:
> Prompted by Trent, I was investigating the use of pre-multiplied alpha.
> And as the ex_premulalpha I just committed shows, we probably should add
> a way to use it in A5 or things will look wrong with filtering. My idea
> so far is to just add a new bitmap flag, so you could do:
> 
> al_set_new_bitmap_flags(ALLEGRO_PREMULTIPLIED_ALPHA);
> bitmap = al_load_bitmap("my.png");
> 
> It would cause the bitmap loader to multiply in the alpha, so where
> right now it does:
> 
> r, g, b, a = png.r, png.g, png.b, png.a
> 
> it will then do this when the flag is set:
> 
> r, g, b = png.r * png.a, png.g * png.a, png.b * png.a
> a = png.a

What will putpixel and getpixel calls do when applied to such a bitmap?

> Another idea would be to use pre-multiplied alpha by default, as Shawn
> Hargreaves does in XNA [1] :P But I don't really know enough about this
> I guess, yesterday is the first time I understood where i can even make
> a difference...

For what it's worth, we convert to pre-multiplied alpha when setting the application icon.
Which prompts me to go and check what the native image loader on OS X does with the colour components when loading a bitmap with an alpha channel and make sure it does the right thing.

Other than that, is it essential to have this for 5.0? I guess it is if blending won't work otherwise. It doesn't seem like it would break the API to include it from 5.1 onward (except of course when making it the default, but we don't have to do that) so in that sense it's not that this is our one chance to "get it right".

Evert



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/