/************************************************************************************************
 *                                                                                              *
 * Image Class for ray tracing.                                                                 *
 *    Image is kept as 2D array of RGBvector, and the origin is at the lowerleft corner.        *
 *                                                                                              *
 *    writePPM is a routine to transformed the internal image structure to PPM format and write *
 *    to file.                                                                                  *
 *                                                                                              *
 *                                          XianMing Chen, Jan 13, 2002                         *
 *                                                                                              *
 ************************************************************************************************/


#ifndef _IMAGE_H_
#define _IMAGE_H_

#include "Ray.h"

class Image {
 public:
    Image():hReso(200), vReso(200), data(0) { }
    ~Image() { delete [] data; }

    void Init() { delete [] data; data = new RGBcolor [hReso*vReso]; }

    int& GetHResolution() { return hReso; }
    int GetHResolution() const { return hReso; }
    void SetHResolution(int d) { hReso=d; }

    int& GetVResolution() { return vReso; }
    int GetVResolution() const { return vReso; }
    void SetVResolution(int d) { vReso=d; }


    RGBcolor* operator[] (int row) { assert(row>=0&&row<vReso); return data+row*hReso; }

    void writePPM(char* filename);


 private:
    int hReso;
    int vReso;
    RGBcolor* data;
};




#endif

