Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bitmap not loading again

This thread is locked; no one can reply to it. rss feed Print
Bitmap not loading again
Auradrummer
Member #15,778
October 2014

Hi masters,

I'm cannot load bitmap from this code:

#SelectExpand
1#include "allegro5/allegro.h" 2#include "allegro5/allegro_image.h" 3#include "allegro5/allegro_native_dialog.h" 4 5int main(int argc, char **argv){ 6 7 ALLEGRO_DISPLAY *display = NULL; 8 ALLEGRO_BITMAP *image = NULL; 9 10 al_init(); 11 al_init_image_addon(); 12 display = al_create_display(800,600); 13 14 ALLEGRO_FILE * file = al_fopen("altestfile.alt","w"); 15 image = al_load_bitmap("bit.tga"); 16 17 if(!image) 18 { 19 al_show_native_message_box(display, "Error", "Error", "Failed to load image!", 20 NULL, ALLEGRO_MESSAGEBOX_ERROR); 21 al_destroy_display(display); 22 return 0; 23 } 24 25 al_draw_bitmap(image,200,200,0); 26 al_flip_display(); 27 al_rest(2); 28 al_destroy_display(display); 29 al_destroy_bitmap(image); 30 return 0; 31}

As you can see, is the allegro example.
Some things you must consider:
That "bit.tga" if the "large_bullet.tga" from cosmic protector.
That "fopen" is to ensure the path of my project is working. I presumed that if the file is created in the same directory of the "bit.tga", then the path is correct. Well, the file is created in the same directory of the "bit.tga".

I really do not know where the problem lies. Next step is to format my system.

Thanks masters!

Arthur Kalliokoski
Second in Command
February 2005
avatar

Try al_init_image_addon() before loading.

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

The code he's showing says he already did that.

I'd say to see here :
https://wiki.allegro.cc/index.php?title=Loading_Resources_%28Troubleshooting%29

but it looks like it should be working. Try using the absolute path to your file when loading, and if that doesn't work, it may be something wrong with the file, but it shouldn't be if it is just a copy of one of allegro's tga files.

pkrcel
Member #14,001
February 2012

Allegro log might be worth looking at to check if there is any error code given out from the image addon.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Thomas Fjellstrom
Member #476
June 2000
avatar

In order for there to be an allegro.like g file you have to link to the allegro debug lib. FYI.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Go to: