Search code examples
c++bitmapalphaallegro

Allegro 5 - creating a custom bitmap with alpha channel


Afternoon everyone,

I was wondering if there's any way I could create a custom bitmap with alpha channel

bitmap = al_create_bitmap(30, 30);
al_set_target_bitmap(bitmap);
al_clear_to_color(al_map_rgb(255,255,255));
....
al_draw_tinted_bitmap(bitmap, al_map_rgba(0, 0, 0, 0.5),  X,  Y, 0);

I'm sure that I'm either not creating or drawing the bitmap correctly, so I could really use some advice.

Thanks in advance, Alex


Solution

  • after I set the

    al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
    

    it allowed me to draw my "bouncer" bitmap and change its alpha channel using the below function:

    al_draw_tinted_bitmap(bouncer, al_map_rgba_f(1, 1, 1, alpha) 40, 0, 0);
    

    This previously did not work , so I guess adding the al_set_blender solved the "mistery".

    Thanks for all your help.