13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy// This may look like C code, but it is really -*- C++ -*-
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy//
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003, 2008
4b435339c088523d4321e119c73d104c3a1f5d27bdirk// Copyright Dirk Lemstra 2013-2014
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy//
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy// Color Implementation
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy//
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if !defined (Magick_Color_header)
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define Magick_Color_header
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "Magick++/Include.h"
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <string>
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristynamespace Magick
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
16af1dd259230d63d51f441c28bc23265a79b19c55cristy  class MagickPPExport Color;
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // Compare two Color objects regardless of LHS/RHS
191940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator ==
20be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
211940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator !=
22be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
231940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator >
24be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
251940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator <
26be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
271940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator >=
28be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
291940fe06f035ea32a4ec4df61f6897396877aa3cdirk  MagickPPExport int operator <=
30be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    (const Magick::Color& left_,const Magick::Color& right_);
31be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
32be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // Base color class stores RGBA components scaled to fit Quantum
33be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // All double arguments have a valid range of 0.0 - 1.0.
34af1dd259230d63d51f441c28bc23265a79b19c55cristy  class MagickPPExport Color
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3851d4438a77a085f4827993c677741eb3b72a8a24dirk    // PixelType specifies the interpretation of PixelInfo members
3951d4438a77a085f4827993c677741eb3b72a8a24dirk    // CYMKPixel:
4051d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Cyan     = red
4151d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Magenta  = green
4251d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Yellow   = blue
4351d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Black(K) = black
4451d4438a77a085f4827993c677741eb3b72a8a24dirk    // CYMKPixel:
4551d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Cyan     = red
4651d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Magenta  = green
4751d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Yellow   = blue
4851d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Black(K) = black
4951d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Alpha    = alpha
5051d4438a77a085f4827993c677741eb3b72a8a24dirk    // RGBPixel:
5151d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Red      = red;
5251d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Green    = green;
5351d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Blue     = blue;
5451d4438a77a085f4827993c677741eb3b72a8a24dirk    // RGBAPixel:
5551d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Red      = red;
5651d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Green    = green;
5751d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Blue     = blue;
5851d4438a77a085f4827993c677741eb3b72a8a24dirk    //   Alpha    = alpha;
5951d4438a77a085f4827993c677741eb3b72a8a24dirk    enum PixelType
6051d4438a77a085f4827993c677741eb3b72a8a24dirk    {
6151d4438a77a085f4827993c677741eb3b72a8a24dirk      CMYKPixel,
6251d4438a77a085f4827993c677741eb3b72a8a24dirk      CMYKAPixel,
6351d4438a77a085f4827993c677741eb3b72a8a24dirk      RGBPixel,
6451d4438a77a085f4827993c677741eb3b72a8a24dirk      RGBAPixel
6551d4438a77a085f4827993c677741eb3b72a8a24dirk    };
6651d4438a77a085f4827993c677741eb3b72a8a24dirk
67be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
68be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(void);
693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
70be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct Color using the specified RGB values
71be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(const Quantum red_,const Quantum green_,const Quantum blue_);
723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
73be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct Color using the specified RGBA values
74be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(const Quantum red_,const Quantum green_,const Quantum blue_,
75be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk      const Quantum alpha_);
763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
776485563b5a957c2e8c4ef9f85d35abc0f795e043dirk    // Construct Color using the specified CMYKA values
786485563b5a957c2e8c4ef9f85d35abc0f795e043dirk    Color(const Quantum cyan_,const Quantum magenta_,const Quantum yellow_,
796485563b5a957c2e8c4ef9f85d35abc0f795e043dirk      const Quantum black_,const Quantum alpha_);
806485563b5a957c2e8c4ef9f85d35abc0f795e043dirk
8133f4ed0a364e414efa8758c7f8d3a59f3c3bf9d8dirk    // Construct Color using the specified color string
8233f4ed0a364e414efa8758c7f8d3a59f3c3bf9d8dirk    Color(const char *color_);
8333f4ed0a364e414efa8758c7f8d3a59f3c3bf9d8dirk
84be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
85be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(const Color &color_);
86be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
87be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct color via ImageMagick PixelInfo
88be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(const PixelInfo &color_);
89be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
90be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Constructor Color using the specified color string
91be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(const std::string &color_);
92be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
93be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
94be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    virtual ~Color(void);
953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Assignment operator
97be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color& operator=(const Color &color_);
98be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
99aa3ec099d81e5660a5452ad0fd76d10722ea313adirk    // Set color via X11 color specification string
100aa3ec099d81e5660a5452ad0fd76d10722ea313adirk    const Color& operator=(const char *color);
101aa3ec099d81e5660a5452ad0fd76d10722ea313adirk
102be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Set color via ImageMagick PixelInfo
103be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    const Color& operator=(const PixelInfo &color_);
1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
105be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Set color via color specification string
106be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    const Color& operator=(const std::string &color);
1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
108101ab708b0574518ac5715da4d3915400e9df79acristy    // Return ImageMagick PixelInfo
109101ab708b0574518ac5715da4d3915400e9df79acristy    operator PixelInfo() const;
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
111be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Return color specification string
112be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    operator std::string() const;
1133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1144c281a65f6f114fd0cc07e88093bec3328fb491edirk    // Returns true if the distance between the other color is less than the
1154c281a65f6f114fd0cc07e88093bec3328fb491edirk    // specified distance in a linear three(or four) % dimensional color space.
11622d1e094559e53ee6661c2b361343153a3c402d8dirk    bool isFuzzyEquivalent(const Color &color_,const double fuzz_) const;
1174c281a65f6f114fd0cc07e88093bec3328fb491edirk
118be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Does object contain valid color?
119be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void isValid(const bool valid_);
120be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    bool isValid(void) const;
1213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12251d4438a77a085f4827993c677741eb3b72a8a24dirk    // Returns pixel type of the color
12351d4438a77a085f4827993c677741eb3b72a8a24dirk    Magick::Color::PixelType pixelType(void) const;
12451d4438a77a085f4827993c677741eb3b72a8a24dirk
125be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Alpha level (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
126be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void quantumAlpha(const Quantum alpha_);
127be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Quantum quantumAlpha(void) const;
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Black color (range 0 to QuantumRange)
13066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void quantumBlack(const Quantum black_);
13166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    Quantum quantumBlack(void) const;
13266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
13366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Blue/Yellow color (range 0 to QuantumRange)
134be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void quantumBlue(const Quantum blue_);
135be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Quantum quantumBlue(void) const;
136be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
13766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Green/Magenta color (range 0 to QuantumRange)
138be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void quantumGreen(const Quantum green_);
139be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Quantum quantumGreen(void) const;
140be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
14166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Red/Cyan color (range 0 to QuantumRange)
142be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void quantumRed(const Quantum red_);
143be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Quantum quantumRed(void) const;
144be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  protected:
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
147101ab708b0574518ac5715da4d3915400e9df79acristy    // Constructor to construct with PixelInfo*
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Used to point Color at a pixel in an image
149be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    Color(PixelInfo *rep_,PixelType pixelType_);
1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
15166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Constructor to construct with PixelType
15266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    Color(PixelType pixelType_);
15366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Set pixel
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Used to point Color at a pixel in an image
156be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void pixel(PixelInfo *rep_,PixelType pixelType_);
157be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
158be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Scale a value expressed as a double (0-1) to Quantum range (0-QuantumRange)
159be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    static Quantum scaleDoubleToQuantum(const double double_);
160be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
161be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Scale a value expressed as a Quantum (0-QuantumRange) to double range (0-1)
162be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    static double scaleQuantumToDouble(const Quantum quantum_);
1633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
164101ab708b0574518ac5715da4d3915400e9df79acristy    // PixelInfo represents a color pixel:
1654cec710491f784e655c41ace5fb4ef558d73bc38cristy    //  red     = red   (range 0 to QuantumRange)
1664cec710491f784e655c41ace5fb4ef558d73bc38cristy    //  green   = green (range 0 to QuantumRange)
1674cec710491f784e655c41ace5fb4ef558d73bc38cristy    //  blue    = blue  (range 0 to QuantumRange)
168be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    //  alpha   = alpha (range OpaqueAlpha=0 to TransparentAlpha=QuantumRange)
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    //  index   = PseudoColor colormap index
170be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    PixelInfo *_pixel;
1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  private:
1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
174be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    bool _isValid; // Set true if pixel is "valid"
175be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    bool _pixelOwn; // Set true if we allocated pixel
176be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    PixelType _pixelType; // Color type supported by _pixel
177be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
178101ab708b0574518ac5715da4d3915400e9df79acristy    // Common initializer for PixelInfo representation
1793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    void initPixel();
18066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
18166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Sets the pixel type using the specified PixelInfo.
18266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void setPixelType(const PixelInfo &color_);
18366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk  };
18466a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
18566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk  class MagickPPExport ColorCMYK: public Color
18666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk  {
18766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk  public:
18866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
18966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Default constructor
19066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK(void);
19166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
19266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Copy constructor
19366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK(const Color &color_);
19466a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
19566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Construct ColorCMYK using the specified CMYK values
19666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK(const double cyan_,const double magenta_,const double yellow_,
19766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk      const double black_);
19866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
19966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Construct ColorCMYK using the specified CMYKA values
20066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK(const double cyan_,const double magenta_,const double yellow_,
20166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk      const double black_,const double alpha_);
20266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
20366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Destructor
20466a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ~ColorCMYK(void);
20566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
20666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Assignment operator from base class
20766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK& operator=(const Color& color_);
20866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
20966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Alpha level (range 0 to 1.0)
21066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void alpha(const double alpha_);
21166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double alpha(void) const;
21266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
21366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Black/Key color (range 0 to 1.0)
21466a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void black(const double black_);
21566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double black(void) const;
21666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
21766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Black/Key color (range 0.0 to 1.0)
21866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void cyan(const double cyan_);
21966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double cyan(void) const;
22066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
22166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Magenta color (range 0 to 1.0)
22266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void magenta(const double magenta_);
22366a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double magenta(void) const;
22466a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
22566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Yellow color (range 0 to 1.0)
22666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void yellow(const double yellow_);
22766a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double yellow(void) const;
22866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
22966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk  protected:
23066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
23166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Constructor to construct with PixelInfo*
23266a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    ColorCMYK(PixelInfo *rep_,PixelType pixelType_);
2333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  };
2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
236be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // Grayscale RGB color
2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
238be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // Grayscale is simply RGB with equal parts of red, green, and blue
239be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // All double arguments have a valid range of 0.0 - 1.0.
240be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  class MagickPPExport ColorGray: public Color
2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
243be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
244be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
245be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorGray(void);
246be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
247be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
248be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorGray(const Color &color_);
249be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
250be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct ColorGray using the specified shade
251be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorGray(const double shade_);
252be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
253be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
254be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ~ColorGray();
255be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
256be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Shade
257be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void shade(const double shade_);
258be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double shade(void) const;
2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Assignment operator from base class
261be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorGray& operator=(const Color& color_);
2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  protected:
264be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
265101ab708b0574518ac5715da4d3915400e9df79acristy    // Constructor to construct with PixelInfo*
266be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorGray(PixelInfo *rep_,PixelType pixelType_);
2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  };
268be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
270be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  // HSL Colorspace colors
2713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
2723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // All double arguments have a valid range of 0.0 - 1.0.
273be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  class MagickPPExport ColorHSL: public Color
2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
277be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
278be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorHSL(void);
279be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
280be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
281be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorHSL(const Color &color_);
282be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
283be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct ColorHSL using the specified HSL values
284be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorHSL(const double hue_,const double saturation_,
285018189d8b8f6797251dd12dbeb83382a17814bfcdirk      const double lightness_);
286be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
287be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
288be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ~ColorHSL();
2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Assignment operator from base class
291be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorHSL& operator=(const Color& color_);
292be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
293be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Hue color
294be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void hue(const double hue_);
295be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double hue(void) const;
296be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
297018189d8b8f6797251dd12dbeb83382a17814bfcdirk    // Lightness color
298018189d8b8f6797251dd12dbeb83382a17814bfcdirk    void lightness(const double lightness_);
299018189d8b8f6797251dd12dbeb83382a17814bfcdirk    double lightness(void) const;
300be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
301be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Saturation color
302be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void saturation(const double saturation_);
303be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double saturation(void) const;
3043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  protected:
306be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
307101ab708b0574518ac5715da4d3915400e9df79acristy    // Constructor to construct with PixelInfo*
308be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorHSL(PixelInfo *rep_,PixelType pixelType_);
3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  };
310be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // Monochrome color
3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // Color arguments are constrained to 'false' (black pixel) and 'true'
3153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // (white pixel)
316be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  class MagickPPExport ColorMono: public Color
3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
319be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
320be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
321be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorMono(void);
322be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
323be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct ColorMono (false=black, true=white)
324be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorMono(const bool mono_);
325be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
326be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
327be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorMono(const Color &color_);
328be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
329be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
330be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ~ColorMono();
3313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Assignment operator from base class
333be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorMono& operator=(const Color& color_);
334be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
335be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Mono color
336be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void mono(const bool mono_);
337be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    bool mono(void) const;
3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  protected:
340be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
341101ab708b0574518ac5715da4d3915400e9df79acristy    // Constructor to construct with PixelInfo*
342be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorMono(PixelInfo* rep_,PixelType pixelType_);
3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  };
344be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
3453bd1b5e065e4658066fa1a1033164d9807cb612adirk  class MagickPPExport ColorRGB: public Color
3463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
348be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
349be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
3503bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB(void);
351be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
352be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
3533bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB(const Color &color_);
354be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
35566a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Construct ColorRGB using the specified RGB values
3563bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB(const double red_,const double green_,const double blue_);
357be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
35866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Construct ColorRGB using the specified RGBA values
3593bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB(const double red_,const double green_,const double blue_,
36066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk      const double alpha_);
361be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
362be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
3633bd1b5e065e4658066fa1a1033164d9807cb612adirk    ~ColorRGB(void);
3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    // Assignment operator from base class
3663bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB& operator=(const Color& color_);
3673bd1b5e065e4658066fa1a1033164d9807cb612adirk
36866a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Alpha level (range 0 to 1.0)
36966a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    void alpha(const double alpha_);
37066a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    double alpha(void) const;
37166a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk
3723bd1b5e065e4658066fa1a1033164d9807cb612adirk    // Blue color (range 0.0 to 1.0)
3733bd1b5e065e4658066fa1a1033164d9807cb612adirk    void blue(const double blue_);
3743bd1b5e065e4658066fa1a1033164d9807cb612adirk    double blue(void) const;
3753bd1b5e065e4658066fa1a1033164d9807cb612adirk
37666a0c5b9e3f8a7fde0bec2869b6d0b87977bca41dirk    // Green color (range 0 to 1.0)
3773bd1b5e065e4658066fa1a1033164d9807cb612adirk    void green(const double green_);
3783bd1b5e065e4658066fa1a1033164d9807cb612adirk    double green(void) const;
3793bd1b5e065e4658066fa1a1033164d9807cb612adirk
3803bd1b5e065e4658066fa1a1033164d9807cb612adirk    // Red color (range 0 to 1.0)
3813bd1b5e065e4658066fa1a1033164d9807cb612adirk    void red(const double red_);
3823bd1b5e065e4658066fa1a1033164d9807cb612adirk    double red(void) const;
3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  protected:
385be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
386101ab708b0574518ac5715da4d3915400e9df79acristy    // Constructor to construct with PixelInfo*
3873bd1b5e065e4658066fa1a1033164d9807cb612adirk    ColorRGB(PixelInfo *rep_,PixelType pixelType_);
3883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  };
389be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk
3903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // YUV Colorspace color
3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //
3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  // Argument ranges:
3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //        Y:  0.0 through 1.0
3953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //        U: -0.5 through 0.5
3963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  //        V: -0.5 through 0.5
397be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  class MagickPPExport ColorYUV: public Color
3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  public:
4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
401be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Default constructor
402be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorYUV(void);
4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
404be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Copy constructor
405be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorYUV(const Color &color_);
4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
407be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Construct ColorYUV using the specified YUV values
408be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorYUV(const double y_,const double u_,const double v_);
4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
410be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Destructor
411be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ~ColorYUV(void);
4123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
413be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Assignment operator from base class
414be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorYUV& operator=(const Color& color_);
4153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
416be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Color U (0.0 through 1.0)
417be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void u(const double u_);
418be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double u(void) const;
4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
420be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Color V (-0.5 through 0.5)
421be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void v(const double v_);
422be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double v(void) const;
4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
424be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Color Y (-0.5 through 0.5)
425be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void y(const double y_);
426be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    double y(void) const;
4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
428be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  protected:
4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
430be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    // Constructor to construct with PixelInfo*
431be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    ColorYUV(PixelInfo *rep_,PixelType pixelType_);
4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
433be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  private:
4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
435be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk    void convert(const double y_,const double u_,const double v_);
4363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
437be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk  };
438be9f62c7943cfd2c3fc13892319933a9e7ae1322dirk} // namespace Magick
4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif // Magick_Color_header
441