- Online Community Forums » Programming Questions » Image doesn't load

This thread is locked; no one can reply to it. rss feed Print
Image doesn't load
Hrod Ruck
Member #15,433
December 2013

I'm trying to load an image from the same folder my main is and I'm always getting null. I've tried moving the image to the folder my .exe is and it did not help. I'm using windows, by the way. Code excerpt:
bouncer = al_load_bitmap("image.png");
if (!bouncer)
fprintf(stderr, "failed to create bouncer.\n");
al_destroy_display (display);
return -1;
If the full code is needed, I will post it here as well.
Also, I'm tring to get the path using

path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
printf("%s", al_path_cstr(path, '/'));
but the program is crashing.

l j
Member #10,584
January 2009

If you're running from an IDE, the IDE may change your working directory.

Use al_get_standard_path with al_change_directory to change the working directory.

Hrod Ruck
Member #15,433
December 2013

Thanks, but how do I print the path I'm using? I don't know which path is ALLEGRO_RESOURCES_PATH, for instance.
The program is causing a seg fault when I try to change directory (I opened another thread for that)
And loading a .bmp image does not help

Matthew Leverton
Supreme Loser
January 1999

Hrod Ruck
Member #15,433
December 2013

Thanks to all for your help. I wasn't setting al_init_image_addon, probably

Go to: