/////////////////////////////////////////////////////////////////////////////// // Pixel.h // // This data class contains the information required to represent one // pixel of graphics data. Several different color models are provided, // you may access each pixel using whichever model you want. /////////////////////////////////////////////////////////////////////////////// // The following preprocessor directives makes sure this header // only gets included once. #ifndef PIXEL_HSPC #define PIXEL_HSPC // Define the Pixel class. class Pixel { public: // Default constructor -- creates a black pixel. Pixel (); // Destructor -- frees up any memory used. ~Pixel (); // These routines are used for getting at the color values of this // pixel. The range for each value is 0.0 to 1.0 inclusive. // The RGB model for the color. double getRed (); double getGreen (); double getBlue (); // The HSV model for the color. double getHue (); double getSaturation (); double getIntensity (); // The YIQ model for the color. double getBrightness (); double getChroma (); double getPurity (); // The CMY model for the color. double getCyan (); double getMagenta (); double getYellow (); // These routines are used for setting the color of the pixel. void setRGBColor (double red, double green, double blue); void setHSVColor (double hue, double saturation, double intensity); void setYIQColor (double brightness, double chroma, double purity); void setCMYColor (double cyan, double magenta, double yellow); // These routines are used for tweaking the color of a pixel. Note // that if you change a value in one color model, it will affect // all the other representations of the color. Use these routines // with great care. (You don't have to ever use these routines). // The range for each value is 0.0 to 1.0 inclusive. // The RGB model for the color. void adjustRed (double newValue); void adjustGreen (double newValue); void adjustBlue (double newValue); // The HSV model for the color. void adjustHue (double newValue); void adjustSaturation (double newValue); void adjustIntensity (double newValue); // The YIQ model for the color. void adjustBrightness (double newValue); void adjustChroma (double newValue); void adjustPurity (double newValue); // The CMY model for the color. void adjustCyan (double newValue); void adjustMagenta (double newValue); void adjustYellow (double newValue); private: // Color model information. typedef enum {RGB, HSV, YIQ, CMY} ColorModel; // The color information is stored here. ColorModel model; // 0=RGB, 1=HSV, 2=YIQ, 3=CMY union { double red; double hue; double brightness; double cyan; double value1; }; union { double green; double saturation; double chroma; double magenta; double value2; }; union { double blue; double intensity; double purity; double yellow; double value3; }; // This function makes sure all the values are in the range [0.0 ... 1.0]. void clipValues (); // A color conversion helper function. void convertTo (ColorModel newModel); }; #endif // IMAGE_HSPC