]> granicus.if.org Git - imagemagick/blob - www/Magick++/Color.html
(no commit message)
[imagemagick] / www / Magick++ / Color.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2   "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <title>Magick::Color Class</title>
6 <meta name="GENERATOR" content="OpenOffice.org 1.0 (Win32)">
7 <meta name="AUTHOR" content="Bob Friesenhahn">
8 <meta name="CREATED" content="20020805;13543972">
9 <meta name="CHANGEDBY" content="Bob Friesenhahn">
10 <meta name="CHANGED" content="20020805;14583794">
11 <meta name="DESCRIPTION" content="Magick::Color class documentation">
12 <link rel=stylesheet type=text/css href=../../www/magick.css>
13 </head>
14 <body lang="en-US" text="#ffffff" link="#0000EE" vlink="#551A8B" bgcolor="#fbc713">
15 <h1 align="center">Magick::Color</h1>
16 <p><a href="#Color">Color</a> is the base color class in Magick++. It is a simple container class for the pixel red, green, blue, and alpha values scaled to fit ImageMagick's Quantum size. Normally users will instantiate a class derived from Color which supports the color model that fits the needs of the application. The Color class may be constructed directly from an X11-style color string.</p>
17 <p style="margin-bottom: 0cm">Available derived color specification classes are shown in the following table:</p>
18 <p align="center" style="margin-bottom: 0cm"><b>Color Derived Classes</b></p>
19 <center>
20 <table width="90%" border="1" cellpadding="2" cellspacing="3">
21 <col width="29*">
22 <col width="227*">
23 <tr>
24 <td width="12%">
25 <p><a href="#ColorRGB">ColorRGB</a></p></td>
26 <td width="88%">
27 <p>Representation of RGB color with red, green, and blue specified as ratios (0 to 1)</p></td></tr>
28 <tr>
29 <td width="12%">
30 <p><a href="#ColorGray">ColorGray</a></p></td>
31 <td width="88%">
32 <p>Representation of <span lang="en-US">grayscale</span> RGB color (equal parts red, green, and blue) specified as a ratio (0 to 1)</p></td></tr>
33 <tr>
34 <td width="12%">
35 <p><a href="#ColorMono">ColorMono</a></p></td>
36 <td width="88%">
37 <p>Representation of a black/white color (true/false)</p></td></tr>
38 <tr>
39 <td width="12%">
40 <p><a href="#ColorYUV">ColorYUV</a></p></td>
41 <td width="88%">
42 <p>Representation of a color in the YUV <span lang="en-US">colorspace</span></p></td></tr></table></center>
43 <p style="margin-bottom: 0cm">ImageMagick may be compiled to support 32 or 64 bit pixels of type <span lang="en-US">PixelPacket.</span> This is controlled by the value of the QuantumDepth define. The default is 64 bit pixels, which provides the best accuracy. If memory consumption and/or processing time must be minimized, then ImageMagick may be compiled with QuantumDepth=8. The following table shows the relationship between <i>QuantumDepth</i>, the type of <i>Quantum</i>, and the overall <i>PixelPacket</i> size.</p>
44 <p align="center" style="margin-bottom: 0cm"><b>Effect Of QuantumDepth Values</b></p>
45 <center>
46 <table width="361" border="1" cellpadding="2" cellspacing="3">
47 <col width="102">
48 <col width="121">
49 <col width="111">
50 <tr>
51 <td width="102">
52 <p align="center"><b>QuantumDepth</b></p></td>
53 <td width="121">
54 <p align="center"><b>Quantum Typedef</b></p></td>
55 <td width="111">
56 <p align="center"><b>PixelPacket Size</b></p></td></tr>
57 <tr>
58 <td width="102">
59 <p align="center">8</p></td>
60 <td width="121">
61 <p align="center">unsigned char</p></td>
62 <td width="111">
63 <p align="center">32 bits</p></td></tr>
64 <tr>
65 <td width="102">
66 <p align="center">16</p></td>
67 <td width="121">
68 <p align="center">unsigned short</p></td>
69 <td width="111">
70 <p align="center">64 bits</p></td></tr></table></center>
71 <h3><a name="Color"></a>Color Class</h3>
72 <p>The Color base class is not intended to be used directly. Normally a user will construct a derived class or inherit from this class. Color arguments are must be scaled to fit the Quantum size. The Color class contains a pointer to a PixelPacket, which may be allocated by the Color class, or may refer to an existing pixel in an image.</p>
73 <p>An alternate way to <span lang="en-US">construct</span> the class is via an X11-<span lang="en-US">compatible</span> color specification string.</p>
74 <p><tt><font size="2"><font color="#000066">class Color</font></font></tt><br>
75 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
76 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
77 <tt><font size="2"><font color="#000066">Color ( Quantum red_,</font></font></tt><br>
78 <tt><font size="2"><font color="#000066">Quantum green_,</font></font></tt><br>
79 <tt><font size="2"><font color="#000066">Quantum blue_ );</font></font></tt><br>
80 <tt><font size="2"><font color="#000066">Color ( Quantum red_,</font></font></tt><br>
81 <tt><font size="2"><font color="#000066">Quantum green_,</font></font></tt><br>
82 <tt><font size="2"><font color="#000066">Quantum blue_,</font></font></tt><br>
83 <tt><font size="2"><font color="#000066">Quantum alpha_ );</font></font></tt><br>
84 <tt><font size="2"><font color="#000066">Color ( const std::string &amp;x11color_ );</font></font></tt><br>
85 <tt><font size="2"><font color="#000066">Color ( const char * x11color_ );</font></font></tt><br>
86 <tt><font size="2"><font color="#000066">Color ( void );</font></font></tt><br>
87 <tt><font size="2"><font color="#000066">virtual ~Color ( void );</font></font></tt><br>
88 <tt><font size="2"><font color="#000066">Color ( const Color &amp; color_ );</font></font></tt></p>
89 <p><tt><font size="2"><font color="#000066">// Red color (range 0 to QuantumRange)</font></font></tt><br>
90 <tt><font size="2"><font color="#000066">void redQuantum ( Quantum red_ );</font></font></tt><br>
91 <tt><font size="2"><font color="#000066">Quantum redQuantum ( void ) const;</font></font></tt></p>
92 <p><tt><font size="2"><font color="#000066">// Green color (range 0 to QuantumRange)</font></font></tt><br>
93 <tt><font size="2"><font color="#000066">void greenQuantum ( Quantum green_ );</font></font></tt><br>
94 <tt><font size="2"><font color="#000066">Quantum greenQuantum ( void ) const;</font></font></tt></p>
95 <p><tt><font size="2"><font color="#000066">// Blue color (range 0 to QuantumRange)</font></font></tt><br>
96 <tt><font size="2"><font color="#000066">void blueQuantum ( Quantum blue_ );</font></font></tt><br>
97 <tt><font size="2"><font color="#000066">Quantum blueQuantum ( void ) const;</font></font></tt></p>
98 <p><tt><font size="2"><font color="#000066">// Alpha level (range OpaqueOpacity=0 to TransparentOpacity=QuantumRange)</font></font></tt><br>
99 <tt><font size="2"><font color="#000066">void alphaQuantum ( Quantum alpha_ );</font></font></tt><br>
100 <tt><font size="2"><font color="#000066">Quantum alphaQuantum ( void ) const;</font></font></tt></p>
101 <p><tt><font size="2"><font color="#000066">// Scaled (to 1.0) version of alpha for use in sub-classes</font></font></tt><br>
102 <tt><font size="2"><font color="#000066">// (range opaque=0 to transparent=1.0)</font></font></tt><br>
103 <tt><font size="2"><font color="#000066">void alpha ( double alpha_ );</font></font></tt><br>
104 <tt><font size="2"><font color="#000066">double alpha ( void ) const;</font></font></tt><br>
105 <br>
106 <tt><font size="2"><font color="#000066">// Does object contain valid color?</font></font></tt><br>
107 <tt><font size="2"><font color="#000066">void isValid ( bool valid_ );</font></font></tt><br>
108 <tt><font size="2"><font color="#000066">bool isValid ( void ) const;</font></font></tt><br>
109 <br>
110 <tt><font size="2"><font color="#000066">// Set color via X11 color specification string</font></font></tt><br>
111 <tt><font size="2"><font color="#000066">const Color&amp; operator= ( const std::string &amp;x11color_ );</font></font></tt><br>
112 <tt><font size="2"><font color="#000066">const Color&amp; operator= ( const char * x11color_ );</font></font></tt></p>
113 <p><tt><font size="2"><font color="#000066">// Assignment operator</font></font></tt><br>
114 <tt><font size="2"><font color="#000066">Color&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
115 <br>
116 <tt><font size="2"><font color="#000066">// Return X11 color specification string</font></font></tt><br>
117 <tt><font size="2"><font color="#000066">/* virtual */ operator std::string() const;</font></font></tt></p>
118 <p><tt><font size="2"><font color="#000066">// Return ImageMagick PixelPacket</font></font></tt><br>
119 <tt><font size="2"><font color="#000066">operator PixelPacket() const;</font></font></tt></p>
120 <p><tt><font size="2"><font color="#000066">// Construct color via ImageMagick PixelPacket</font></font></tt><br>
121 <tt><font size="2"><font color="#000066">Color ( const PixelPacket &amp;color_ );</font></font></tt></p>
122 <p><tt><font size="2"><font color="#000066">// Set color via ImageMagick PixelPacket</font></font></tt><br>
123 <tt><font size="2"><font color="#000066">const Color&amp; operator= ( PixelPacket &amp;color_ );</font></font></tt><br>
124 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
125 <h3><a name="ColorRGB"></a>ColorRGB</h3>
126 <p>Representation of an RGB color. All color arguments have a valid range of 0.0 - 1.0.</p>
127 <p><tt><font size="2"><font color="#000066">class ColorRGB : public Color</font></font></tt><br>
128 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
129 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
130 <tt><font size="2"><font color="#000066">ColorRGB ( double red_, double green_, double blue_ );</font></font></tt><br>
131 <tt><font size="2"><font color="#000066">ColorRGB ( void );</font></font></tt><br>
132 <tt><font size="2"><font color="#000066">ColorRGB ( const Color &amp; color_ );</font></font></tt><br>
133 <tt><font size="2"><font color="#000066">/* virtual */ ~ColorRGB ( void );</font></font></tt><br>
134 <br>
135 <tt><font size="2"><font color="#000066">void red ( double red_ );</font></font></tt><br>
136 <tt><font size="2"><font color="#000066">double red ( void ) const;</font></font></tt><br>
137 <br>
138 <tt><font size="2"><font color="#000066">void green ( double green_ );</font></font></tt><br>
139 <tt><font size="2"><font color="#000066">double green ( void ) const;</font></font></tt><br>
140 <br>
141 <tt><font size="2"><font color="#000066">void blue ( double blue_ );</font></font></tt><br>
142 <tt><font size="2"><font color="#000066">double blue ( void ) const;</font></font></tt></p>
143 <p><tt><font size="2"><font color="#000066">// Assignment operator from base class</font></font></tt><br>
144 <tt><font size="2"><font color="#000066">ColorRGB&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
145 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
146 <h3><a name="ColorGray"></a>ColorGray</h3>
147 <p>Representation of a grayscale color (in RGB colorspace). <span lang="en-US">Grayscale</span> is simply RGB with equal parts of red, green, and blue. All double arguments have a valid range of 0.0 - 1.0.</p>
148 <p><tt><font size="2"><font color="#000066">class ColorGray : public Color</font></font></tt><br>
149 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
150 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
151 <tt><font size="2"><font color="#000066">ColorGray ( double shade_ );</font></font></tt><br>
152 <tt><font size="2"><font color="#000066">ColorGray ( void );</font></font></tt><br>
153 <tt><font size="2"><font color="#000066">ColorGray ( const Color &amp; color_ );</font></font></tt><br>
154 <tt><font size="2"><font color="#000066">/* virtual */ ~ColorGray ();</font></font></tt></p>
155 <p><tt><font size="2"><font color="#000066">void shade ( double shade_ );</font></font></tt><br>
156 <tt><font size="2"><font color="#000066">double shade ( void ) const;</font></font></tt></p>
157 <p><tt><font size="2"><font color="#000066">// Assignment operator from base class</font></font></tt><br>
158 <tt><font size="2"><font color="#000066">ColorGray&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
159 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
160 <h3><a name="ColorMono"></a>ColorMono</h3>
161 <p>Representation of a black/white pixel (in RGB colorspace). Color arguments are constrained to 'false' (black pixel) and 'true' (white pixel).</p>
162 <p><tt><font size="2"><font color="#000066">class ColorMono : public Color</font></font></tt><br>
163 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
164 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
165 <tt><font size="2"><font color="#000066">ColorMono ( bool mono_ );</font></font></tt><br>
166 <tt><font size="2"><font color="#000066">ColorMono ( void );</font></font></tt><br>
167 <tt><font size="2"><font color="#000066">ColorMono ( const Color &amp; color_ );</font></font></tt><br>
168 <tt><font size="2"><font color="#000066">/* virtual */ ~ColorMono ();</font></font></tt><br>
169 <br>
170 <tt><font size="2"><font color="#000066">void mono ( bool mono_ );</font></font></tt><br>
171 <tt><font size="2"><font color="#000066">bool mono ( void ) const;</font></font></tt></p>
172 <p><tt><font size="2"><font color="#000066">// Assignment operator from base class</font></font></tt><br>
173 <tt><font size="2"><font color="#000066">ColorMono&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
174 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
175 <h3><a name="ColorHSL"></a>ColorHSL</h3>
176 <p>Representation of a color in Hue/Saturation/Luminosity (HSL) colorspace.</p>
177 <p><tt><font size="2"><font color="#000066">class ColorHSL : public Color</font></font></tt><br>
178 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
179 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
180 <tt><font size="2"><font color="#000066">ColorHSL ( double hue_, double saturation_, double luminosity_ );</font></font></tt><br>
181 <tt><font size="2"><font color="#000066">ColorHSL ( void );</font></font></tt><br>
182 <tt><font size="2"><font color="#000066">ColorHSL ( const Color &amp; color_ );</font></font></tt><br>
183 <tt><font size="2"><font color="#000066">/* virtual */ ~ColorHSL ( );</font></font></tt><br>
184 <br>
185 <tt><font size="2"><font color="#000066">void hue ( double hue_ );</font></font></tt><br>
186 <tt><font size="2"><font color="#000066">double hue ( void ) const;</font></font></tt><br>
187 <br>
188 <tt><font size="2"><font color="#000066">void saturation ( double saturation_ );</font></font></tt><br>
189 <tt><font size="2"><font color="#000066">double saturation ( void ) const;</font></font></tt><br>
190 <br>
191 <tt><font size="2"><font color="#000066">void luminosity ( double luminosity_ );</font></font></tt><br>
192 <tt><font size="2"><font color="#000066">double luminosity ( void ) const;</font></font></tt></p>
193 <p><tt><font size="2"><font color="#000066">// Assignment operator from base class</font></font></tt><br>
194 <tt><font size="2"><font color="#000066">ColorHSL&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
195 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
196 <h3><a name="ColorYUV"></a>ColorYUV</h3>
197 <p>Representation of a color in YUV colorspace (used to encode color for television transmission).</p>
198 <p>Argument ranges:<br>
199  Y: 0.0 through 1.0<br>
200  U: -0.5 through 0.5<br>
201  V: -0.5 through 0.5</p>
202 <p><tt><font size="2"><font color="#000066">class ColorYUV : public Color</font></font></tt><br>
203 <tt><font size="2"><font color="#000066">{</font></font></tt><br>
204 <tt><font size="2"><font color="#000066">public:</font></font></tt><br>
205 <tt><font size="2"><font color="#000066">ColorYUV ( double y_, double u_, double v_ );</font></font></tt><br>
206 <tt><font size="2"><font color="#000066">ColorYUV ( void );</font></font></tt><br>
207 <tt><font size="2"><font color="#000066">ColorYUV ( const Color &amp; color_ );</font></font></tt><br>
208 <tt><font size="2"><font color="#000066">/* virtual */ ~ColorYUV ( void );</font></font></tt><br>
209 <br>
210 <tt><font size="2"><font color="#000066">void u ( double u_ );</font></font></tt><br>
211 <tt><font size="2"><font color="#000066">double u ( void ) const;</font></font></tt><br>
212 <br>
213 <tt><font size="2"><font color="#000066">void v ( double v_ );</font></font></tt><br>
214 <tt><font size="2"><font color="#000066">double v ( void ) const;</font></font></tt><br>
215 <br>
216 <tt><font size="2"><font color="#000066">void y ( double y_ );</font></font></tt><br>
217 <tt><font size="2"><font color="#000066">double y ( void ) const;</font></font></tt></p>
218 <p><tt><font size="2"><font color="#000066">// Assignment operator from base class</font></font></tt><br>
219 <tt><font size="2"><font color="#000066">ColorYUV&amp; operator= ( const Color&amp; color_ );</font></font></tt><br>
220 <tt><font size="2"><font color="#000066">};</font></font></tt></p>
221 <br>
222 </body>
223 </html>