// Pixel.cpp Dave Reed // // implementations of the classes in the Pixel hierarchy ///////////////////////////////////////////////////////////////// #include #include "Pixel.h" using namespace std; MonoPixel::MonoPixel() { pixValue = 0; } void MonoPixel::Invert() { pixValue = 1 - pixValue; } void MonoPixel::Read(istream & istr) { istr >> pixValue; } void MonoPixel::Write(ostream & ostr) { ostr << pixValue; } ////////////////////////////////////////////////////////// GrayPixel::GrayPixel(int max) { pixValue = 1; maxValue = max; } void GrayPixel::Invert() { pixValue = maxValue - pixValue; } void GrayPixel::Read(istream & istr) { istr >> pixValue; } void GrayPixel::Write(ostream & ostr) { ostr << pixValue; } ////////////////////////////////////////////////////////////// ColorPixel::ColorPixel(int max) { redValue = 1; greenValue = 1; blueValue = 1; maxValue = max; } void ColorPixel::Invert() { redValue = maxValue - redValue; greenValue = maxValue - greenValue; blueValue = maxValue - blueValue; } void ColorPixel::Read(istream & istr) { istr >> redValue >> greenValue >> blueValue; } void ColorPixel::Write(ostream & ostr) { ostr << redValue << " " << greenValue << " " << blueValue; }