I have a programming challenge that involves reading in pixels from a PGM file. PGM is a simple format for black-and-white photographs.
The programs asks to do the following:
Read 16 pixels of input. From this, extract len, the length of the OUTPUT file. This will
be a long int, (4 bytes) stored two bits per pixel.
How can I read in the pixels and store them two bits at a time into len?
Also, here are some of the variables we have.
typedef char pixel;
class PGM {
char filetype[3]; // Should be "P5".
int width;
int height;
int maxgrey; // Should be 255
pixel* image; // Dynamically allocated array of width*height pixels.