In the release of version 0.2, Nana provides support for PNG. However, by default, Nana disables the support for PNG feature for convenient and quick library configuration.
For PNG support, Nana C ++ library uses libpng (www.libpng.org ). Therefore, there are two different policies to support this feature.
1. Use the libpng
2. Use libpng provided in the operating system, which means we need to install libpng on our own.
Enable PNG support
Open the config. HPP header file in the nana inclusion directory. We can find a comment like this:
//#define NANA_ENABLE_PNG
Undo this annotation to enable support for PNG. Now the code looks like this:
#define NANA_ENABLE_PNG 1#if defined(NANA_ENABLE_PNG) //Comment it for using the libpng from operating system. #define NANA_LIBPNG 1#endif
If # define nana_libpng is retained, use the libpng that comes with the nana library. Note: Use the libpng provided in the operating system.
By defaultThe Nana library of the Win32 package uses the accompanying LibPNG, while the Linux (X11) package uses the OS.
After the configuration is complete, re-compile the nana library and create a program to display a PNG image.
#include <nana/gui/wvl.hpp>#include <nana/gui/widgets/picture.hpp>#include <nana/gui/layout.hpp>int main(){ using namespace nana::gui; form fm; picture pic(fm); gird gd(fm); gd.push(pic, 0, 0); pic.load(STR(“a_png_file.png”)); fm.show(); exec();}
On WindowsThe link is located in libpng in the "% Nana %/extrlib" folder.
Libpng. A: For Dev-C ++ and code: Blocks
Libpng. md. lib/LibPNG. md. x64.lib: for VC and multi-threaded DLL Runtime Library.
Libpng. mt. lib/LibPNG. mt. x64.lib: for VC and multi-threaded Runtime Library.
On Linux (X11)Modify Your makefile and add a "-lpng" to the compiler"