Here is the
PPM specification.
The PPM file is built in 9 sections separated by white-spaces.
- Open the file
- read until the first white space and check you got
P6
. Then skip other white-spaces.
- read until the next white space, convert your buffer to an integer width. Then skip other white-spaces
- read until the next white space, convert your buffer to an integer height. Then skip other white-spaces
- Allocate a 2D array of integers in the size of height*width
- read the max-val
- read line by line and fill the array