/**
 *\file		Canvas.h
 *
 *\brief	The Canvas class is a discrete simulation of the real life canvas. 
 *
 *\author	Xianming Chen
 *
 */


#ifndef _CANVAS_H_
#define _CANVAS_H_

#include "Point.h"
#include "color.h"

#include <string>


using namespace std;

class Canvas
{ 
public:
    Canvas(int resoH = 512, int resoV = 512) : hReso(resoH), vReso(resoV), filename("tmp.ppm"), rgbs(0)  { init(); }

    ~Canvas()                                  { delete [] rgbs; }

    RGB& Pixel(int row, int col)               { /* ... */ }              //! return a reference to the pixel at (row, col).

    void WritePPM(const char* = 0) const;      //! write to file in raw ppm format.
    void ReadPPM(const string&);               //! read from a raw ppm format image file.

    int hReso, vReso;                          //! Resolutions (pixel #)at horizontal and vertical directions.
    std::string filename;                      //! write as PPM image file name.
    RGB* rgbs;
private:
    void init();
    RGB& pixel(int row, int col)               { return *(rgbs + row * hReso + col); }
};

#endif
