Last Updated: August 01, 2023
·
3.517K
· okaram

Simple C++ library for reading pngs

Loading and saving images is usually not too simple; I recently discovered png++[http://www.nongnu.org/pngpp/doc/0.2.0/], which makes it really really simple.

after installing, just #include <png++/png.hpp>

and then you can do code like:
png::image< png::rgb_pixel > img("myimage.png");

and you have img.getwidth(), img.getwidth(), and image[row][col] to get the pixel data. To save back, just do img.write("other.png").