Using libpng

Hi, I have a project that relies on LibPNG for various PNG manipulations. I believe that JUCE has libpng implemented in it already? How do I use it?

Without any includes I get unknown type name and undeclared identifier errors. If I try to '#include "png.h" i get a file not found error....


To link against external libraries, you need to add the header include path and the library search path to your Introjucer project.

And yes, JUCE comes with a version of libpng. It is located in modules/juce_graphics/image_formats/pnglib. but afaik it is not meant to be used directly, it's more like an internal implementation detail. The relevant public JUCE interfaces are in modules/juce_graphics/images/juce_ImageFileFormat.h.

What is it that you are trying to do that you can't do with JUCE?

ah ok - So how do I add the header include and library search for libpng into the introjuicer project?

I could probably reproduce the project in JUCE instead of libpng, but it's a large block of code and the simple solution is to stick the code in JUCEs handy app setup and just use the existing code that relies heavily on libpng, rather than re writing it all.

See below.

Be careful with the include order, so as not to cause any name clashes with the JUCE internal libpng.

Sorry, you are going to have to explain that :-)  Am I putting the path to my libpng install into 'header search paths' (i.e. /usr/local/include/libpng...), and what do i need in the external library search paths?  ....Then I just #include "png.h"?

what do i need in the external library search paths?

The folder where your compiled libpng binary resides.