#ifndef _PGM_IMAGE_H_
#define _PGM_IMAGE_H_
#include <exception>
#include <string>
typedef unsigned char pixel;
class PGMImageException: public std::exception {
public:
virtual const char *what(){
return "Image Exception.";
}
};
class PGMImage {
public:
PGMImage(int w, int h);
PGMImage(const PGMImage &image);
virtual ~PGMImage();
const PGMImage &operator=(const PGMImage &right);
virtual pixel getPixel(int x, int y) throw (PGMImageException);
virtual void setPixel(int x, int y, pixel p) throw (PGMImageException);
virtual void writeToFile(std::string name);
protected:
virtual int posToIndex(int x, int y) throw (PGMImageException) ;
pixel *m_data;
int m_width;
int m_height;
};
#endif