Main Page | File List

Canvas.h

Go to the documentation of this file.
00001 /**
00002  *\file         Canvas.h
00003  *
00004  *\brief        The Canvas class is a discrete simulation of the real life canvas. 
00005  *
00006  *\author       Xianming Chen
00007  *
00008  */
00009 
00010 
00011 #ifndef _CANVAS_H_
00012 #define _CANVAS_H_
00013 
00014 #include "Point.h"
00015 #include "color.h"
00016 
00017 #include <string>
00018 
00019 
00020 using namespace std;
00021 
00022 class Canvas
00023 { 
00024 public:
00025     Canvas(int resoH = 512, int resoV = 512) : hReso(resoH), vReso(resoV), filename("tmp.ppm"), rgbs(0)  { init(); }
00026 
00027     ~Canvas()                                  { delete [] rgbs; }
00028 
00029     RGB& Pixel(int row, int col)               { /* ... */ }              //! return a reference to the pixel at (row, col).
00030 
00031     void WritePPM(const char* = 0) const;      //! write to file in raw ppm format.
00032     void ReadPPM(const string&);               //! read from a raw ppm format image file.
00033 
00034     int hReso, vReso;                          //! Resolutions (pixel #)at horizontal and vertical directions.
00035     std::string filename;                      //! write as PPM image file name.
00036     RGB* rgbs;
00037 private:
00038     void init();
00039     RGB& pixel(int row, int col)               { return *(rgbs + row * hReso + col); }
00040 };
00041 
00042 #endif

Generated on Mon Aug 2 16:51:15 2004 by doxygen 1.3.6