Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Displaying bitmap with alpha

This thread is locked; no one can reply to it. rss feed Print
Displaying bitmap with alpha
mentalDisorder
Member #13,376
August 2011

I'm trying to draw bitmap with alpha channel.
If there is no alpha channel everything looks good, but once I add some alpha to the image gray rectangle is displayed :(
Should I set some blender flags or wha ? If so, which ?

Trent Gamblin
Member #261
April 2000
avatar

Show some code, please.

mentalDisorder
Member #13,376
August 2011

ALLEGRO_FILE *file = al_fopen("gfx/something.bmp", "r");
al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA);
bitmap = al_load_bitmap_f(file, ".bmp");

Drawing:
al_draw_bitmap(bitmap, 10, 10, 0);

Trent Gamblin
Member #261
April 2000
avatar

Allegro can't load alpha from .bmps. Use .png.

Matthew Leverton
Supreme Loser
January 1999
avatar

ALLEGRO_FILE *file = al_fopen("gfx/something.bmp", "r");
bitmap = al_load_bitmap_f(file, ".bmp");
al_fclose(file);

could be written as:

bitmap = al_load_bitmap("gfx/something.bmp");

mentalDisorder
Member #13,376
August 2011

oh yee I know it can be done in a shorter way, I had some issues with loading .bmps and I tried different solutions :)

By the way, allegro5 seems not to cope with .tga files, manual says it should ?

Trent Gamblin
Member #261
April 2000
avatar

It probably doesn't support every type of TGA, but it does work.

Go to: