Mmm Donuts
Mmm Donuts

Reputation: 10283

How can I open and parse a png pixel by pixel?

I'm just wondering how I could go about iterating through each pixel of an image? I know I can open the file as I could any other, but it's not in a 'readable' format.

For example, let's say I have: world.png (1920/1080)

How do I go about parsing it within two for loops?

Upvotes: 0

Views: 1830

Answers (1)

Emanuele Paolini
Emanuele Paolini

Reputation: 10162

You should use a library to achieve what you want. In this case the library is libpng. See the "reading" section of the manual: http://www.libpng.org/pub/png/libpng-manual.txt

As noted by @Ben in the comments there is also a C++ wrapper: http://www.nongnu.org/pngpp/doc/0.2.7/

Upvotes: 1

Related Questions