[AD] premultiplied alpha

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


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

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...

[1]
http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>





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