Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Loading .png Files in Allegro 5

This thread is locked; no one can reply to it. rss feed Print
Loading .png Files in Allegro 5
therpgmaker
Member #13,412
August 2011

I'm having trouble finding resources explaining how to load .png files with Allegro 5. When I installed it, I thought that it was supported without external libraries, but I see that that doesn't seem to be the case. Can someone explain to me what libraries I need, where I can get them, and how to install them?

Matthew Leverton
Supreme Loser
January 1999
avatar

The included readme file and the manual explains that. Try reading them.

If you are using prebuilt binaries on a.cc, then it is included (along with everything else).

therpgmaker
Member #13,412
August 2011

Ok, I installed libz and libpng, and added them (libz.dll.a and libpng.dll.a) to the linker settings. I #include <png.h>. I still get a null value when I try to load a .png file.

AMCerasoli
Member #11,955
May 2010
avatar

You don't need to install anything besides Allegro 5.

Use the Allegro 5 pre-built binaries and that's it.

Matthew Leverton
Supreme Loser
January 1999
avatar

There is no need to include those header files, as you are not calling any PNG specific functions. See:

http://wiki.allegro.cc/index.php?title=Loading_Resources_(Troubleshooting)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Ok, I installed libz and libpng, and added them (libz.dll.a and libpng.dll.a) to the linker settings. I #include <png.h>. I still get a null value when I try to load a .png file.

If you built A5 yourself, you will need to delete CMakeCache.txt and rebuild it from scratch, or else png support won't be built into it. If you're using the prebuilt binaries, then you're ready to go.

After that, you need to include <allegro5/allegro_image.h>, initialize allegro and the image addon, and then load your png file normally using al_load_bitmap.

therpgmaker
Member #13,412
August 2011

Thanks, that was it. I got it working.

Go to: