// Pixel.h Dave Reed // // Definitions of classes in the Pixel hierarchy // Pixel: abstract class that specifies operations on all pixel types // MonoPixel: for black and white (PBM) images // GrayPixel: for grayscale (PGM) images // ColorPixel: for color (PPM) images ///////////////////////////////////////////////////////////////////////////// #ifndef _PIXEL_H_ #define _PIXEL_H_ #include #include using namespace std; class Pixel { public: virtual void Invert() = 0; virtual void Read(istream & istr) = 0; virtual void Write(ostream & ostr) = 0; }; class MonoPixel : public Pixel { public: MonoPixel(); void Invert(); void Read(istream & istr); void Write(ostream & ostr); private: short int pixValue; }; class GrayPixel : public Pixel { public: GrayPixel(int max = 1); void Invert(); void Read(istream & istr); void Write(ostream & ostr); private: int pixValue; int maxValue; }; class ColorPixel : public Pixel { public: ColorPixel(int max = 1); void Invert(); void Read(istream & istr); void Write(ostream & ostr); private: int redValue, greenValue, blueValue; int maxValue; }; #endif