Transparency in bitmaps of Allegro 5
Lucas Adami

Hello. I'm unsing Allegro 5 here and I didn't find any function that makes my bitmap transparent. On the old Allegro, the functions for this were:

- set_trans_blender

- draw_trans_sprite

Could anyone help and tell me what I have to do in the new Allegro?
Thanks a lot!

Matthew Leverton

It works with the alpha channel. Something like:

al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(255,255,255));
al_draw_bitmap(bmp, 0,0);

OnlineCop

From here, the first thing that caught my eye was al_convert_mask_to_alpha

Lucas Adami

Thanks Matthew. That was what I needed!
Thanks anyway OnlineCop. But that function I use to transform my bitmaps from pink to alpha. I want half transparency ;D

Trent Gamblin

You can do this too, to give any bitmap a degree of translucency:

// load bitmap
int alpha = 128; // half translucent
al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba(255, 255, 255, alpha));
al_draw_bitmap(bmp, 0, 0, 0);

Thread #598765. Printed from Allegro.cc