Png++ is a software tool that acts as a C++ wrapper for the popular libpng library, allowing developers to easily incorporate PNG image file support into their C++ applications.
Using raw libpng in C++ can be quite challenging, as it requires a lot of precautions and error handling. Fortunately, png++ makes this process a lot simpler. With png++, you can read or write PNG images in just a single line of C++ code. For example, png::image< png::rgb_pixel > image("input.png"); image.write("output.png"); This code reads an image from the file named "input.png" and writes the image to a file named "output.png". Png++ performs all the transformations necessary to create an adequate in-memory RGB representation of the image.
With png++, it doesn't matter if the input image is in RGB, grayscale, or even indexed image format with a palette. The library will simply convert any input to RGB format. However, for technical reasons, this automatic transformation is supported for RGB and Grayscale color types only. Optionally, there may be an alpha channel in the target color space (RGBA and Gray+Alpha, respectively).
The latest version of png++ includes several new features, such as support for tRNS chunk, non-std IO streams support, and fixes for 16-bit endian problems. Additionally, the test script has been improved. Overall, png++ is an excellent choice for anyone looking to work with PNG images in C++.