- Online Community Forums » Programming Questions » Transparency in bitmaps of Allegro 5

Credits go to Matthew Leverton for helping out!
This thread is locked; no one can reply to it. rss feed Print
Transparency in bitmaps of Allegro 5
Lucas Adami
Member #8,528
April 2007

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
Supreme Loser
January 1999

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);

Member #7,919
October 2006

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

I made a VR game!

Lucas Adami
Member #8,528
April 2007

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
Member #261
April 2000

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);

Go to: