Image Class Summary Class image stores an image and provides methods for reading, writing, and manipulating images. It requires libjpeg, which is installed by default with most Linux distributions. More info on libjpeg may be found here . The following formats are supported: raw PGM read/write raw PPM read/write JPEG(RGB or gray) read/write raw TARGA(gray, RGB or RGBA) read rle TARGA(gray, RGB or RGBA) read State uint width image width in pixels uint height image height in pixels uint depth number of color channels(bytes) per pixel. Though the I/O methods only use depths [1, 4], the image manipulation methods handle arbitrary depths. ulong size total bytes needed to store the image: width by height by depth byte *pixmap pointer to pixel map Methods image() Set numbers to zero, pointer to NULL. ~image() Free pixel map memory. void dump(FILE *OUT=stdout) Dump resolution and size information to the given file pointer. image& operator=(const image &img) Allocate a new pixel map and copy all data. Return a reference to the current image. void fliph() Flip image horizontally. void flipv() Flip image vertically. image* conform(uint width, uint height, char crop_align=0) Crop and scale to the given width and height. Crop alignment may be 'c'(center), 'l'(left), 'r'(right), 't'(top), or 'b'(bottom), or zero(no cropping). Return a pointer to the new image. int read_PNM(FILE *IN) Read a raw PGM(P5) or raw PPM(P6) image from the given file pointer. Return zero upon success, less-than-zero upon failure. int write_PNM(FILE *OUT) Write a raw PGM(P5) if depth is 1, or a raw PPM(P6) if depth is 3, to the given file pointer. Return zero upon success, less-than-zero upon failure. int read_JPEG(FILE *IN) Read a JPEG file, which may be RGB or grayscale, from the given file pointer. Return zero upon success, less-than-zero upon failure. int write_JPEG(FILE *OUT, int quality=75) Write a JPEG file, which may be RGB or grayscale, at the given quality, to the given file pointer. Return zero upon success, less-than-zero upon failure. int read_TARGA(FILE *IN) Read a TARGA image from the given file pointer. The following TARGA types are supported: 2 raw RGB(A) 3 raw grayscale 10 rle RGB(A) 11 rle grayscale Return zero upon success, less-than-zero upon failure. int read(char *path) Read any type suppored by the above read functions by calling the appropriate one, depending on the suffix(pgm, ppm, jpg, tga) of the given path. Return zero upon success, less-than-zero upon failure.