#include "main.h" int main(int argc, char **argv) { if( !checkArgs(argc, argv) ) return 1; pixmap = (Pixmap*) new Pixmap(); // 1. Load an image pixmap->loadImage(argv[1]); // 2.1 Do some simple image processing ( draw a red cross hair in the center ) pixmap->setPen(255, 0, 0); //set drawing color to red pixmap->markVLine( pixmap->getWidth() / 2 ); //create a vertical line at middle pixmap->markHLine( pixmap->getHeight() / 2 ); //create a horizontal line at middle // 2.2 Find all white pixels and convert to green int width = pixmap->getWidth(); int height = pixmap->getHeight(); for( int i = 0; i < width; i++ ){ for( int j = 0; j < height; j++ ){ pixmap->switchPixel(i, j, 255, 255, 255, 0, 255, 0); } } // 3. Write out the result image pixmap->writeImage(argv[2]); return(0); } bool checkArgs(int argc, char **argv) { if( argc < 3 ) { fprintf( stderr, "Usage:\t%s theimagefile theresultimage\n", argv[0] ); return false; } return true; }