/******************************************************************/ /* Image.cpp */ /* ----------------------- */ /* */ /* The file defines an image class that stores a color buffer. */ /* This is particularly useful for offline rendering, and */ /* the class includes a very simple routine to save the image */ /* as a PPM file. */ /* */ /* Chris Wyman (10/26/2006) */ /******************************************************************/ #include "Image.h" #include "Color.h" #include #include Image::Image(int xres, int yres): xres(xres), yres(yres) { image =new Color*[yres]; for (int i=0;i=0;j--) for (int i=0;i255 ? 255 : (r<0 ? 0 : r) ); g = ( g>255 ? 255 : (g<0 ? 0 : g) ); b = ( b>255 ? 255 : (b<0 ? 0 : b) ); fprintf( file, "%d %d %d ", r, g, b ); if ((++count % 5) == 0) fprintf( file, "\n"); } fclose( file ); }