Bitmap not loading again
Auradrummer

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

Try al_init_image_addon() before loading.

Edgar Reynaldo

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

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

Thomas Fjellstrom

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

Thread #614749. Printed from Allegro.cc