Enable PNG support for Nana C ++ Library

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.