Loading .png Files in Allegro 5
therpgmaker

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

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

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

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

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

Matthew Leverton

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

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

Thanks, that was it. I got it working.

Thread #608505. Printed from Allegro.cc