Thursday, July 9, 2009

How do I load PGM image data into a C++ array?

Creating a PGM from another format such as JPEG should create an array of greyscale integers however this comes up as binary information and is not readily visible in a text editor like pico/nano. I would like to have an array of this information in a C++ program so that I can do some analysis on the image.

How do I load PGM image data into a C++ array?
Do you have the PGM data in a file? Open the file as binary, declare int array of the size you need and read the data from the file using declared array as input buffer.





But if you simply want to get text representation of binary data, it's easier to use some Hex editor/viewer. Search the net. Here is the first link google gives for 'hex editor' - http://www.chmaas.handshake.de/delphi/fr...


No comments:

Post a Comment