Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_load_bitmap not working for bmp

This thread is locked; no one can reply to it. rss feed Print
al_load_bitmap not working for bmp
Droid33
Member #12,844
May 2011

I have a test.png and a test.bmp in the same folder as my project files. I can load and draw the test.png, but when I try the same thing for the test.bmp it loads a black image.

Is there something that I'm forgetting to do here? I'm lost.

#SelectExpand
1#include <allegro5/allegro.h> 2#include <allegro5/allegro_image.h> 3#include <iostream> 4using namespace std; 5 6int main() 7{ 8 al_init(); 9 10 al_init_image_addon(); 11 12 ALLEGRO_DISPLAY* display = al_create_display(100, 100); 13 14 ALLEGRO_BITMAP* image = al_load_bitmap("test.png"); 15 16 if (!image) 17 { 18 cout << "Image not found" << endl; 19 } 20 21 al_draw_bitmap(image, 0, 0, NULL); 22 23 al_flip_display(); 24 25 while(1); 26}

Matthew Leverton
Supreme Loser
January 1999
avatar

Either the image isn't where you expect it to be or it's too big.

Edit: Oh the PNG works.

Upload and attach the BMP image to your post.

Droid33
Member #12,844
May 2011

I edited the bmp and saved it with 24 bit depth, that works, so its because the bmp was 32 bit. Any reason why 32 bit might not work in this basic set up? and thanks for the reply.

Evert
Member #794
November 2000
avatar

What platform is this on?

In practice you should probably stick with the PNG though, it'll be smaller than the BMP.

Droid33
Member #12,844
May 2011

Windows

Go to: