MagickCore  7.0.9
color.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % CCCC OOO L OOO RRRR %
6 % C O O L O O R R %
7 % C O O L O O RRRR %
8 % C O O L O O R R %
9 % CCCC OOO LLLLL OOO R R %
10 % %
11 % %
12 % MagickCore Color Methods %
13 % %
14 % Software Design %
15 % Cristy %
16 % July 1992 %
17 % %
18 % %
19 % Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization %
20 % dedicated to making software imaging solutions freely available. %
21 % %
22 % You may not use this file except in compliance with the License. You may %
23 % obtain a copy of the License at %
24 % %
25 % https://imagemagick.org/script/license.php %
26 % %
27 % Unless required by applicable law or agreed to in writing, software %
28 % distributed under the License is distributed on an "AS IS" BASIS, %
29 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
30 % See the License for the specific language governing permissions and %
31 % limitations under the License. %
32 % %
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %
35 % We use linked-lists because splay-trees do not currently support duplicate
36 % key / value pairs (.e.g X11 green compliance and SVG green compliance).
37 %
38 */
39 
40 /*
41  Include declarations.
42 */
43 #include "MagickCore/studio.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/cache-view.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/color.h"
50 #include "MagickCore/client.h"
51 #include "MagickCore/configure.h"
52 #include "MagickCore/exception.h"
54 #include "MagickCore/gem.h"
55 #include "MagickCore/gem-private.h"
56 #include "MagickCore/geometry.h"
58 #include "MagickCore/memory_.h"
60 #include "MagickCore/monitor.h"
62 #include "MagickCore/option.h"
64 #include "MagickCore/quantize.h"
65 #include "MagickCore/quantum.h"
67 #include "MagickCore/semaphore.h"
68 #include "MagickCore/string_.h"
70 #include "MagickCore/token.h"
71 #include "MagickCore/utility.h"
73 #include "MagickCore/xml-tree.h"
75 
76 /*
77  Define declarations.
78 */
79 #define ColorFilename "colors.xml"
80 
81 /*
82  Typedef declarations.
83 */
84 typedef struct _ColormapInfo
85 {
86  const char
87  name[21];
88 
89  const unsigned char
90  red,
91  green,
92  blue;
93 
94  const float
96 
97  const ssize_t
99 } ColormapInfo;
100 
101 /*
102  Static declarations.
103 */
104 static const ColormapInfo
106  {
107  { "none", 0, 0, 0, 0, SVGCompliance | XPMCompliance },
108  { "black", 0, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
109  { "red", 255, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
110  { "magenta", 255, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
111  { "green", 0, 128, 0, 1, SVGCompliance },
112  { "cyan", 0, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
113  { "blue", 0, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
114  { "yellow", 255, 255, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
115  { "white", 255, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
116  { "AliceBlue", 240, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
117  { "AntiqueWhite", 250, 235, 215, 1, SVGCompliance | X11Compliance | XPMCompliance },
118  { "AntiqueWhite1", 255, 239, 219, 1, X11Compliance },
119  { "AntiqueWhite2", 238, 223, 204, 1, X11Compliance },
120  { "AntiqueWhite3", 205, 192, 176, 1, X11Compliance },
121  { "AntiqueWhite4", 139, 131, 120, 1, X11Compliance },
122  { "aqua", 0, 255, 255, 1, SVGCompliance },
123  { "aquamarine", 127, 255, 212, 1, SVGCompliance | X11Compliance | XPMCompliance },
124  { "aquamarine1", 127, 255, 212, 1, X11Compliance },
125  { "aquamarine2", 118, 238, 198, 1, X11Compliance },
126  { "aquamarine3", 102, 205, 170, 1, X11Compliance },
127  { "aquamarine4", 69, 139, 116, 1, X11Compliance },
128  { "azure", 240, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
129  { "azure1", 240, 255, 255, 1, X11Compliance },
130  { "azure2", 224, 238, 238, 1, X11Compliance },
131  { "azure3", 193, 205, 205, 1, X11Compliance },
132  { "azure4", 131, 139, 139, 1, X11Compliance },
133  { "beige", 245, 245, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
134  { "bisque", 255, 228, 196, 1, SVGCompliance | X11Compliance | XPMCompliance },
135  { "bisque1", 255, 228, 196, 1, X11Compliance },
136  { "bisque2", 238, 213, 183, 1, X11Compliance },
137  { "bisque3", 205, 183, 158, 1, X11Compliance },
138  { "bisque4", 139, 125, 107, 1, X11Compliance },
139  { "BlanchedAlmond", 255, 235, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
140  { "blue1", 0, 0, 255, 1, X11Compliance },
141  { "blue2", 0, 0, 238, 1, X11Compliance },
142  { "blue3", 0, 0, 205, 1, X11Compliance },
143  { "blue4", 0, 0, 139, 1, X11Compliance },
144  { "BlueViolet", 138, 43, 226, 1, SVGCompliance | X11Compliance | XPMCompliance },
145  { "brown", 165, 42, 42, 1, SVGCompliance | X11Compliance | XPMCompliance },
146  { "brown1", 255, 64, 64, 1, X11Compliance },
147  { "brown2", 238, 59, 59, 1, X11Compliance },
148  { "brown3", 205, 51, 51, 1, X11Compliance },
149  { "brown4", 139, 35, 35, 1, X11Compliance },
150  { "burlywood", 222, 184, 135, 1, SVGCompliance | X11Compliance | XPMCompliance },
151  { "burlywood1", 255, 211, 155, 1, X11Compliance },
152  { "burlywood2", 238, 197, 145, 1, X11Compliance },
153  { "burlywood3", 205, 170, 125, 1, X11Compliance },
154  { "burlywood4", 139, 115, 85, 1, X11Compliance },
155  { "CadetBlue", 95, 158, 160, 1, SVGCompliance | X11Compliance | XPMCompliance },
156  { "CadetBlue1", 152, 245, 255, 1, X11Compliance },
157  { "CadetBlue2", 142, 229, 238, 1, X11Compliance },
158  { "CadetBlue3", 122, 197, 205, 1, X11Compliance },
159  { "CadetBlue4", 83, 134, 139, 1, X11Compliance },
160  { "chartreuse", 127, 255, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
161  { "chartreuse1", 127, 255, 0, 1, X11Compliance },
162  { "chartreuse2", 118, 238, 0, 1, X11Compliance },
163  { "chartreuse3", 102, 205, 0, 1, X11Compliance },
164  { "chartreuse4", 69, 139, 0, 1, X11Compliance },
165  { "chocolate", 210, 105, 30, 1, SVGCompliance | X11Compliance | XPMCompliance },
166  { "chocolate1", 255, 127, 36, 1, X11Compliance },
167  { "chocolate2", 238, 118, 33, 1, X11Compliance },
168  { "chocolate3", 205, 102, 29, 1, X11Compliance },
169  { "chocolate4", 139, 69, 19, 1, X11Compliance },
170  { "coral", 255, 127, 80, 1, SVGCompliance | X11Compliance | XPMCompliance },
171  { "coral1", 255, 114, 86, 1, X11Compliance },
172  { "coral2", 238, 106, 80, 1, X11Compliance },
173  { "coral3", 205, 91, 69, 1, X11Compliance },
174  { "coral4", 139, 62, 47, 1, X11Compliance },
175  { "CornflowerBlue", 100, 149, 237, 1, SVGCompliance | X11Compliance | XPMCompliance },
176  { "cornsilk", 255, 248, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
177  { "cornsilk1", 255, 248, 220, 1, X11Compliance },
178  { "cornsilk2", 238, 232, 205, 1, X11Compliance },
179  { "cornsilk3", 205, 200, 177, 1, X11Compliance },
180  { "cornsilk4", 139, 136, 120, 1, X11Compliance },
181  { "crimson", 220, 20, 60, 1, SVGCompliance },
182  { "cyan1", 0, 255, 255, 1, X11Compliance },
183  { "cyan2", 0, 238, 238, 1, X11Compliance },
184  { "cyan3", 0, 205, 205, 1, X11Compliance },
185  { "cyan4", 0, 139, 139, 1, X11Compliance },
186  { "DarkBlue", 0, 0, 139, 1, SVGCompliance | X11Compliance },
187  { "DarkCyan", 0, 139, 139, 1, SVGCompliance | X11Compliance },
188  { "DarkGoldenrod", 184, 134, 11, 1, SVGCompliance | X11Compliance | XPMCompliance },
189  { "DarkGoldenrod1", 255, 185, 15, 1, X11Compliance },
190  { "DarkGoldenrod2", 238, 173, 14, 1, X11Compliance },
191  { "DarkGoldenrod3", 205, 149, 12, 1, X11Compliance },
192  { "DarkGoldenrod4", 139, 101, 8, 1, X11Compliance },
193  { "DarkGray", 169, 169, 169, 1, SVGCompliance | X11Compliance },
194  { "DarkGreen", 0, 100, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
195  { "DarkGrey", 169, 169, 169, 1, SVGCompliance | X11Compliance },
196  { "DarkKhaki", 189, 183, 107, 1, SVGCompliance | X11Compliance | XPMCompliance },
197  { "DarkMagenta", 139, 0, 139, 1, SVGCompliance | X11Compliance },
198  { "DarkOliveGreen", 85, 107, 47, 1, SVGCompliance | X11Compliance | XPMCompliance },
199  { "DarkOliveGreen1", 202, 255, 112, 1, X11Compliance },
200  { "DarkOliveGreen2", 188, 238, 104, 1, X11Compliance },
201  { "DarkOliveGreen3", 162, 205, 90, 1, X11Compliance },
202  { "DarkOliveGreen4", 110, 139, 61, 1, X11Compliance },
203  { "DarkOrange", 255, 140, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
204  { "DarkOrange1", 255, 127, 0, 1, X11Compliance },
205  { "DarkOrange2", 238, 118, 0, 1, X11Compliance },
206  { "DarkOrange3", 205, 102, 0, 1, X11Compliance },
207  { "DarkOrange4", 139, 69, 0, 1, X11Compliance },
208  { "DarkOrchid", 153, 50, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
209  { "DarkOrchid1", 191, 62, 255, 1, X11Compliance },
210  { "DarkOrchid2", 178, 58, 238, 1, X11Compliance },
211  { "DarkOrchid3", 154, 50, 205, 1, X11Compliance },
212  { "DarkOrchid4", 104, 34, 139, 1, X11Compliance },
213  { "DarkRed", 139, 0, 0, 1, SVGCompliance | X11Compliance },
214  { "DarkSalmon", 233, 150, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
215  { "DarkSeaGreen", 143, 188, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
216  { "DarkSeaGreen1", 193, 255, 193, 1, X11Compliance },
217  { "DarkSeaGreen2", 180, 238, 180, 1, X11Compliance },
218  { "DarkSeaGreen3", 155, 205, 155, 1, X11Compliance },
219  { "DarkSeaGreen4", 105, 139, 105, 1, X11Compliance },
220  { "DarkSlateBlue", 72, 61, 139, 1, SVGCompliance | X11Compliance | XPMCompliance },
221  { "DarkSlateGray", 47, 79, 79, 1, SVGCompliance | X11Compliance | XPMCompliance },
222  { "DarkSlateGray1", 151, 255, 255, 1, X11Compliance },
223  { "DarkSlateGray2", 141, 238, 238, 1, X11Compliance },
224  { "DarkSlateGray3", 121, 205, 205, 1, X11Compliance },
225  { "DarkSlateGray4", 82, 139, 139, 1, X11Compliance },
226  { "DarkSlateGrey", 47, 79, 79, 1, SVGCompliance | X11Compliance },
227  { "DarkTurquoise", 0, 206, 209, 1, SVGCompliance | X11Compliance | XPMCompliance },
228  { "DarkViolet", 148, 0, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
229  { "DeepPink", 255, 20, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
230  { "DeepPink1", 255, 20, 147, 1, X11Compliance },
231  { "DeepPink2", 238, 18, 137, 1, X11Compliance },
232  { "DeepPink3", 205, 16, 118, 1, X11Compliance },
233  { "DeepPink4", 139, 10, 80, 1, X11Compliance },
234  { "DeepSkyBlue", 0, 191, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
235  { "DeepSkyBlue1", 0, 191, 255, 1, X11Compliance },
236  { "DeepSkyBlue2", 0, 178, 238, 1, X11Compliance },
237  { "DeepSkyBlue3", 0, 154, 205, 1, X11Compliance },
238  { "DeepSkyBlue4", 0, 104, 139, 1, X11Compliance },
239  { "DimGray", 105, 105, 105, 1, SVGCompliance | X11Compliance | XPMCompliance },
240  { "DimGrey", 105, 105, 105, 1, SVGCompliance | X11Compliance },
241  { "DodgerBlue", 30, 144, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
242  { "DodgerBlue1", 30, 144, 255, 1, X11Compliance },
243  { "DodgerBlue2", 28, 134, 238, 1, X11Compliance },
244  { "DodgerBlue3", 24, 116, 205, 1, X11Compliance },
245  { "DodgerBlue4", 16, 78, 139, 1, X11Compliance },
246  { "firebrick", 178, 34, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
247  { "firebrick1", 255, 48, 48, 1, X11Compliance },
248  { "firebrick2", 238, 44, 44, 1, X11Compliance },
249  { "firebrick3", 205, 38, 38, 1, X11Compliance },
250  { "firebrick4", 139, 26, 26, 1, X11Compliance },
251  { "FloralWhite", 255, 250, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
252  { "ForestGreen", 34, 139, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
253  { "fractal", 128, 128, 128, 1, SVGCompliance },
254  { "freeze", 0, 0, 0, 0, SVGCompliance },
255  { "fuchsia", 255, 0, 255, 1, SVGCompliance },
256  { "gainsboro", 220, 220, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
257  { "GhostWhite", 248, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
258  { "gold", 255, 215, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
259  { "gold1", 255, 215, 0, 1, X11Compliance },
260  { "gold2", 238, 201, 0, 1, X11Compliance },
261  { "gold3", 205, 173, 0, 1, X11Compliance },
262  { "gold4", 139, 117, 0, 1, X11Compliance },
263  { "goldenrod", 218, 165, 32, 1, SVGCompliance | X11Compliance | XPMCompliance },
264  { "goldenrod1", 255, 193, 37, 1, X11Compliance },
265  { "goldenrod2", 238, 180, 34, 1, X11Compliance },
266  { "goldenrod3", 205, 155, 29, 1, X11Compliance },
267  { "goldenrod4", 139, 105, 20, 1, X11Compliance },
268  { "gray", 126, 126, 126, 1, SVGCompliance },
269  { "gray", 190, 190, 190, 1, X11Compliance | XPMCompliance },
270  { "gray0", 0, 0, 0, 1, X11Compliance | XPMCompliance },
271  { "gray1", 3, 3, 3, 1, X11Compliance | XPMCompliance },
272  { "gray10", 26, 26, 26, 1, X11Compliance | XPMCompliance },
273  { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
274  { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
275  { "gray11", 28, 28, 28, 1, X11Compliance | XPMCompliance },
276  { "gray12", 31, 31, 31, 1, X11Compliance | XPMCompliance },
277  { "gray13", 33, 33, 33, 1, X11Compliance | XPMCompliance },
278  { "gray14", 36, 36, 36, 1, X11Compliance | XPMCompliance },
279  { "gray15", 38, 38, 38, 1, X11Compliance | XPMCompliance },
280  { "gray16", 41, 41, 41, 1, X11Compliance | XPMCompliance },
281  { "gray17", 43, 43, 43, 1, X11Compliance | XPMCompliance },
282  { "gray18", 46, 46, 46, 1, X11Compliance | XPMCompliance },
283  { "gray19", 48, 48, 48, 1, X11Compliance | XPMCompliance },
284  { "gray2", 5, 5, 5, 1, X11Compliance | XPMCompliance },
285  { "gray20", 51, 51, 51, 1, X11Compliance | XPMCompliance },
286  { "gray21", 54, 54, 54, 1, X11Compliance | XPMCompliance },
287  { "gray22", 56, 56, 56, 1, X11Compliance | XPMCompliance },
288  { "gray23", 59, 59, 59, 1, X11Compliance | XPMCompliance },
289  { "gray24", 61, 61, 61, 1, X11Compliance | XPMCompliance },
290  { "gray25", 64, 64, 64, 1, X11Compliance | XPMCompliance },
291  { "gray26", 66, 66, 66, 1, X11Compliance | XPMCompliance },
292  { "gray27", 69, 69, 69, 1, X11Compliance | XPMCompliance },
293  { "gray28", 71, 71, 71, 1, X11Compliance | XPMCompliance },
294  { "gray29", 74, 74, 74, 1, X11Compliance | XPMCompliance },
295  { "gray3", 8, 8, 8, 1, X11Compliance | XPMCompliance },
296  { "gray30", 77, 77, 77, 1, X11Compliance | XPMCompliance },
297  { "gray31", 79, 79, 79, 1, X11Compliance | XPMCompliance },
298  { "gray32", 82, 82, 82, 1, X11Compliance | XPMCompliance },
299  { "gray33", 84, 84, 84, 1, X11Compliance | XPMCompliance },
300  { "gray34", 87, 87, 87, 1, X11Compliance | XPMCompliance },
301  { "gray35", 89, 89, 89, 1, X11Compliance | XPMCompliance },
302  { "gray36", 92, 92, 92, 1, X11Compliance | XPMCompliance },
303  { "gray37", 94, 94, 94, 1, X11Compliance | XPMCompliance },
304  { "gray38", 97, 97, 97, 1, X11Compliance | XPMCompliance },
305  { "gray39", 99, 99, 99, 1, X11Compliance | XPMCompliance },
306  { "gray4", 10, 10, 10, 1, X11Compliance | XPMCompliance },
307  { "gray40", 102, 102, 102, 1, X11Compliance | XPMCompliance },
308  { "gray41", 105, 105, 105, 1, X11Compliance | XPMCompliance },
309  { "gray42", 107, 107, 107, 1, X11Compliance | XPMCompliance },
310  { "gray43", 110, 110, 110, 1, X11Compliance | XPMCompliance },
311  { "gray44", 112, 112, 112, 1, X11Compliance | XPMCompliance },
312  { "gray45", 115, 115, 115, 1, X11Compliance | XPMCompliance },
313  { "gray46", 117, 117, 117, 1, X11Compliance | XPMCompliance },
314  { "gray47", 120, 120, 120, 1, X11Compliance | XPMCompliance },
315  { "gray48", 122, 122, 122, 1, X11Compliance | XPMCompliance },
316  { "gray49", 125, 125, 125, 1, X11Compliance | XPMCompliance },
317  { "gray5", 13, 13, 13, 1, X11Compliance | XPMCompliance },
318  { "gray50", 127, 127, 127, 1, X11Compliance | XPMCompliance },
319  { "gray51", 130, 130, 130, 1, X11Compliance | XPMCompliance },
320  { "gray52", 133, 133, 133, 1, X11Compliance | XPMCompliance },
321  { "gray53", 135, 135, 135, 1, X11Compliance | XPMCompliance },
322  { "gray54", 138, 138, 138, 1, X11Compliance | XPMCompliance },
323  { "gray55", 140, 140, 140, 1, X11Compliance | XPMCompliance },
324  { "gray56", 143, 143, 143, 1, X11Compliance | XPMCompliance },
325  { "gray57", 145, 145, 145, 1, X11Compliance | XPMCompliance },
326  { "gray58", 148, 148, 148, 1, X11Compliance | XPMCompliance },
327  { "gray59", 150, 150, 150, 1, X11Compliance | XPMCompliance },
328  { "gray6", 15, 15, 15, 1, X11Compliance | XPMCompliance },
329  { "gray60", 153, 153, 153, 1, X11Compliance | XPMCompliance },
330  { "gray61", 156, 156, 156, 1, X11Compliance | XPMCompliance },
331  { "gray62", 158, 158, 158, 1, X11Compliance | XPMCompliance },
332  { "gray63", 161, 161, 161, 1, X11Compliance | XPMCompliance },
333  { "gray64", 163, 163, 163, 1, X11Compliance | XPMCompliance },
334  { "gray65", 166, 166, 166, 1, X11Compliance | XPMCompliance },
335  { "gray66", 168, 168, 168, 1, X11Compliance | XPMCompliance },
336  { "gray67", 171, 171, 171, 1, X11Compliance | XPMCompliance },
337  { "gray68", 173, 173, 173, 1, X11Compliance | XPMCompliance },
338  { "gray69", 176, 176, 176, 1, X11Compliance | XPMCompliance },
339  { "gray7", 18, 18, 18, 1, X11Compliance | XPMCompliance },
340  { "gray70", 179, 179, 179, 1, X11Compliance | XPMCompliance },
341  { "gray71", 181, 181, 181, 1, X11Compliance | XPMCompliance },
342  { "gray72", 184, 184, 184, 1, X11Compliance | XPMCompliance },
343  { "gray73", 186, 186, 186, 1, X11Compliance | XPMCompliance },
344  { "gray74", 189, 189, 189, 1, X11Compliance | XPMCompliance },
345  { "gray75", 191, 191, 191, 1, X11Compliance | XPMCompliance },
346  { "gray76", 194, 194, 194, 1, X11Compliance | XPMCompliance },
347  { "gray77", 196, 196, 196, 1, X11Compliance | XPMCompliance },
348  { "gray78", 199, 199, 199, 1, X11Compliance | XPMCompliance },
349  { "gray79", 201, 201, 201, 1, X11Compliance | XPMCompliance },
350  { "gray8", 20, 20, 20, 1, X11Compliance | XPMCompliance },
351  { "gray80", 204, 204, 204, 1, X11Compliance | XPMCompliance },
352  { "gray81", 207, 207, 207, 1, X11Compliance | XPMCompliance },
353  { "gray82", 209, 209, 209, 1, X11Compliance | XPMCompliance },
354  { "gray83", 212, 212, 212, 1, X11Compliance | XPMCompliance },
355  { "gray84", 214, 214, 214, 1, X11Compliance | XPMCompliance },
356  { "gray85", 217, 217, 217, 1, X11Compliance | XPMCompliance },
357  { "gray86", 219, 219, 219, 1, X11Compliance | XPMCompliance },
358  { "gray87", 222, 222, 222, 1, X11Compliance | XPMCompliance },
359  { "gray88", 224, 224, 224, 1, X11Compliance | XPMCompliance },
360  { "gray89", 227, 227, 227, 1, X11Compliance | XPMCompliance },
361  { "gray9", 23, 23, 23, 1, X11Compliance | XPMCompliance },
362  { "gray90", 229, 229, 229, 1, X11Compliance | XPMCompliance },
363  { "gray91", 232, 232, 232, 1, X11Compliance | XPMCompliance },
364  { "gray92", 235, 235, 235, 1, X11Compliance | XPMCompliance },
365  { "gray93", 237, 237, 237, 1, X11Compliance | XPMCompliance },
366  { "gray94", 240, 240, 240, 1, X11Compliance | XPMCompliance },
367  { "gray95", 242, 242, 242, 1, X11Compliance | XPMCompliance },
368  { "gray96", 245, 245, 245, 1, X11Compliance | XPMCompliance },
369  { "gray97", 247, 247, 247, 1, X11Compliance | XPMCompliance },
370  { "gray98", 250, 250, 250, 1, X11Compliance | XPMCompliance },
371  { "gray99", 252, 252, 252, 1, X11Compliance | XPMCompliance },
372  { "green", 0, 255, 0, 1, X11Compliance | XPMCompliance },
373  { "green1", 0, 255, 0, 1, X11Compliance },
374  { "green2", 0, 238, 0, 1, X11Compliance },
375  { "green3", 0, 205, 0, 1, X11Compliance },
376  { "green4", 0, 139, 0, 1, X11Compliance },
377  { "GreenYellow", 173, 255, 47, 1, X11Compliance | XPMCompliance },
378  { "grey", 190, 190, 190, 1, SVGCompliance | X11Compliance },
379  { "grey0", 0, 0, 0, 1, SVGCompliance | X11Compliance },
380  { "grey1", 3, 3, 3, 1, SVGCompliance | X11Compliance },
381  { "grey10", 26, 26, 26, 1, SVGCompliance | X11Compliance },
382  { "grey100", 255, 255, 255, 1, SVGCompliance | X11Compliance },
383  { "grey11", 28, 28, 28, 1, SVGCompliance | X11Compliance },
384  { "grey12", 31, 31, 31, 1, SVGCompliance | X11Compliance },
385  { "grey13", 33, 33, 33, 1, SVGCompliance | X11Compliance },
386  { "grey14", 36, 36, 36, 1, SVGCompliance | X11Compliance },
387  { "grey15", 38, 38, 38, 1, SVGCompliance | X11Compliance },
388  { "grey16", 41, 41, 41, 1, SVGCompliance | X11Compliance },
389  { "grey17", 43, 43, 43, 1, SVGCompliance | X11Compliance },
390  { "grey18", 46, 46, 46, 1, SVGCompliance | X11Compliance },
391  { "grey19", 48, 48, 48, 1, SVGCompliance | X11Compliance },
392  { "grey2", 5, 5, 5, 1, SVGCompliance | X11Compliance },
393  { "grey20", 51, 51, 51, 1, SVGCompliance | X11Compliance },
394  { "grey21", 54, 54, 54, 1, SVGCompliance | X11Compliance },
395  { "grey22", 56, 56, 56, 1, SVGCompliance | X11Compliance },
396  { "grey23", 59, 59, 59, 1, SVGCompliance | X11Compliance },
397  { "grey24", 61, 61, 61, 1, SVGCompliance | X11Compliance },
398  { "grey25", 64, 64, 64, 1, SVGCompliance | X11Compliance },
399  { "grey26", 66, 66, 66, 1, SVGCompliance | X11Compliance },
400  { "grey27", 69, 69, 69, 1, SVGCompliance | X11Compliance },
401  { "grey28", 71, 71, 71, 1, SVGCompliance | X11Compliance },
402  { "grey29", 74, 74, 74, 1, SVGCompliance | X11Compliance },
403  { "grey3", 8, 8, 8, 1, SVGCompliance | X11Compliance },
404  { "grey30", 77, 77, 77, 1, SVGCompliance | X11Compliance },
405  { "grey31", 79, 79, 79, 1, SVGCompliance | X11Compliance },
406  { "grey32", 82, 82, 82, 1, SVGCompliance | X11Compliance },
407  { "grey33", 84, 84, 84, 1, SVGCompliance | X11Compliance },
408  { "grey34", 87, 87, 87, 1, SVGCompliance | X11Compliance },
409  { "grey35", 89, 89, 89, 1, SVGCompliance | X11Compliance },
410  { "grey36", 92, 92, 92, 1, SVGCompliance | X11Compliance },
411  { "grey37", 94, 94, 94, 1, SVGCompliance | X11Compliance },
412  { "grey38", 97, 97, 97, 1, SVGCompliance | X11Compliance },
413  { "grey39", 99, 99, 99, 1, SVGCompliance | X11Compliance },
414  { "grey4", 10, 10, 10, 1, SVGCompliance | X11Compliance },
415  { "grey40", 102, 102, 102, 1, SVGCompliance | X11Compliance },
416  { "grey41", 105, 105, 105, 1, SVGCompliance | X11Compliance },
417  { "grey42", 107, 107, 107, 1, SVGCompliance | X11Compliance },
418  { "grey43", 110, 110, 110, 1, SVGCompliance | X11Compliance },
419  { "grey44", 112, 112, 112, 1, SVGCompliance | X11Compliance },
420  { "grey45", 115, 115, 115, 1, SVGCompliance | X11Compliance },
421  { "grey46", 117, 117, 117, 1, SVGCompliance | X11Compliance },
422  { "grey47", 120, 120, 120, 1, SVGCompliance | X11Compliance },
423  { "grey48", 122, 122, 122, 1, SVGCompliance | X11Compliance },
424  { "grey49", 125, 125, 125, 1, SVGCompliance | X11Compliance },
425  { "grey5", 13, 13, 13, 1, SVGCompliance | X11Compliance },
426  { "grey50", 127, 127, 127, 1, SVGCompliance | X11Compliance },
427  { "grey51", 130, 130, 130, 1, SVGCompliance | X11Compliance },
428  { "grey52", 133, 133, 133, 1, SVGCompliance | X11Compliance },
429  { "grey53", 135, 135, 135, 1, SVGCompliance | X11Compliance },
430  { "grey54", 138, 138, 138, 1, SVGCompliance | X11Compliance },
431  { "grey55", 140, 140, 140, 1, SVGCompliance | X11Compliance },
432  { "grey56", 143, 143, 143, 1, SVGCompliance | X11Compliance },
433  { "grey57", 145, 145, 145, 1, SVGCompliance | X11Compliance },
434  { "grey58", 148, 148, 148, 1, SVGCompliance | X11Compliance },
435  { "grey59", 150, 150, 150, 1, SVGCompliance | X11Compliance },
436  { "grey6", 15, 15, 15, 1, SVGCompliance | X11Compliance },
437  { "grey60", 153, 153, 153, 1, SVGCompliance | X11Compliance },
438  { "grey61", 156, 156, 156, 1, SVGCompliance | X11Compliance },
439  { "grey62", 158, 158, 158, 1, SVGCompliance | X11Compliance },
440  { "grey63", 161, 161, 161, 1, SVGCompliance | X11Compliance },
441  { "grey64", 163, 163, 163, 1, SVGCompliance | X11Compliance },
442  { "grey65", 166, 166, 166, 1, SVGCompliance | X11Compliance },
443  { "grey66", 168, 168, 168, 1, SVGCompliance | X11Compliance },
444  { "grey67", 171, 171, 171, 1, SVGCompliance | X11Compliance },
445  { "grey68", 173, 173, 173, 1, SVGCompliance | X11Compliance },
446  { "grey69", 176, 176, 176, 1, SVGCompliance | X11Compliance },
447  { "grey7", 18, 18, 18, 1, SVGCompliance | X11Compliance },
448  { "grey70", 179, 179, 179, 1, SVGCompliance | X11Compliance },
449  { "grey71", 181, 181, 181, 1, SVGCompliance | X11Compliance },
450  { "grey72", 184, 184, 184, 1, SVGCompliance | X11Compliance },
451  { "grey73", 186, 186, 186, 1, SVGCompliance | X11Compliance },
452  { "grey74", 189, 189, 189, 1, SVGCompliance | X11Compliance },
453  { "grey75", 191, 191, 191, 1, SVGCompliance | X11Compliance },
454  { "grey76", 194, 194, 194, 1, SVGCompliance | X11Compliance },
455  { "grey77", 196, 196, 196, 1, SVGCompliance | X11Compliance },
456  { "grey78", 199, 199, 199, 1, SVGCompliance | X11Compliance },
457  { "grey79", 201, 201, 201, 1, SVGCompliance | X11Compliance },
458  { "grey8", 20, 20, 20, 1, SVGCompliance | X11Compliance },
459  { "grey80", 204, 204, 204, 1, SVGCompliance | X11Compliance },
460  { "grey81", 207, 207, 207, 1, SVGCompliance | X11Compliance },
461  { "grey82", 209, 209, 209, 1, SVGCompliance | X11Compliance },
462  { "grey83", 212, 212, 212, 1, SVGCompliance | X11Compliance },
463  { "grey84", 214, 214, 214, 1, SVGCompliance | X11Compliance },
464  { "grey85", 217, 217, 217, 1, SVGCompliance | X11Compliance },
465  { "grey86", 219, 219, 219, 1, SVGCompliance | X11Compliance },
466  { "grey87", 222, 222, 222, 1, SVGCompliance | X11Compliance },
467  { "grey88", 224, 224, 224, 1, SVGCompliance | X11Compliance },
468  { "grey89", 227, 227, 227, 1, SVGCompliance | X11Compliance },
469  { "grey9", 23, 23, 23, 1, SVGCompliance | X11Compliance },
470  { "grey90", 229, 229, 229, 1, SVGCompliance | X11Compliance },
471  { "grey91", 232, 232, 232, 1, SVGCompliance | X11Compliance },
472  { "grey92", 235, 235, 235, 1, SVGCompliance | X11Compliance },
473  { "grey93", 237, 237, 237, 1, SVGCompliance | X11Compliance },
474  { "grey94", 240, 240, 240, 1, SVGCompliance | X11Compliance },
475  { "grey95", 242, 242, 242, 1, SVGCompliance | X11Compliance },
476  { "grey96", 245, 245, 245, 1, SVGCompliance | X11Compliance },
477  { "grey97", 247, 247, 247, 1, SVGCompliance | X11Compliance },
478  { "grey98", 250, 250, 250, 1, SVGCompliance | X11Compliance },
479  { "grey99", 252, 252, 252, 1, SVGCompliance | X11Compliance },
480  { "honeydew", 240, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
481  { "honeydew1", 240, 255, 240, 1, X11Compliance },
482  { "honeydew2", 224, 238, 224, 1, X11Compliance },
483  { "honeydew3", 193, 205, 193, 1, X11Compliance },
484  { "honeydew4", 131, 139, 131, 1, X11Compliance },
485  { "HotPink", 255, 105, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
486  { "HotPink1", 255, 110, 180, 1, X11Compliance },
487  { "HotPink2", 238, 106, 167, 1, X11Compliance },
488  { "HotPink3", 205, 96, 144, 1, X11Compliance },
489  { "HotPink4", 139, 58, 98, 1, X11Compliance },
490  { "IndianRed", 205, 92, 92, 1, SVGCompliance | X11Compliance | XPMCompliance },
491  { "IndianRed1", 255, 106, 106, 1, X11Compliance },
492  { "IndianRed2", 238, 99, 99, 1, X11Compliance },
493  { "IndianRed3", 205, 85, 85, 1, X11Compliance },
494  { "IndianRed4", 139, 58, 58, 1, X11Compliance },
495  { "indigo", 75, 0, 130, 1, SVGCompliance },
496  { "ivory", 255, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
497  { "ivory1", 255, 255, 240, 1, X11Compliance },
498  { "ivory2", 238, 238, 224, 1, X11Compliance },
499  { "ivory3", 205, 205, 193, 1, X11Compliance },
500  { "ivory4", 139, 139, 131, 1, X11Compliance },
501  { "khaki", 240, 230, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
502  { "khaki1", 255, 246, 143, 1, X11Compliance },
503  { "khaki2", 238, 230, 133, 1, X11Compliance },
504  { "khaki3", 205, 198, 115, 1, X11Compliance },
505  { "khaki4", 139, 134, 78, 1, X11Compliance },
506  { "lavender", 230, 230, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
507  { "LavenderBlush", 255, 240, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
508  { "LavenderBlush1", 255, 240, 245, 1, X11Compliance },
509  { "LavenderBlush2", 238, 224, 229, 1, X11Compliance },
510  { "LavenderBlush3", 205, 193, 197, 1, X11Compliance },
511  { "LavenderBlush4", 139, 131, 134, 1, X11Compliance },
512  { "LawnGreen", 124, 252, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
513  { "LemonChiffon", 255, 250, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
514  { "LemonChiffon1", 255, 250, 205, 1, X11Compliance },
515  { "LemonChiffon2", 238, 233, 191, 1, X11Compliance },
516  { "LemonChiffon3", 205, 201, 165, 1, X11Compliance },
517  { "LemonChiffon4", 139, 137, 112, 1, X11Compliance },
518  { "LightBlue", 173, 216, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
519  { "LightBlue1", 191, 239, 255, 1, X11Compliance },
520  { "LightBlue2", 178, 223, 238, 1, X11Compliance },
521  { "LightBlue3", 154, 192, 205, 1, X11Compliance },
522  { "LightBlue4", 104, 131, 139, 1, X11Compliance },
523  { "LightCoral", 240, 128, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
524  { "LightCyan", 224, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
525  { "LightCyan1", 224, 255, 255, 1, X11Compliance },
526  { "LightCyan2", 209, 238, 238, 1, X11Compliance },
527  { "LightCyan3", 180, 205, 205, 1, X11Compliance },
528  { "LightCyan4", 122, 139, 139, 1, X11Compliance },
529  { "LightGoldenrod", 238, 221, 130, 1, X11Compliance | XPMCompliance },
530  { "LightGoldenrod1", 255, 236, 139, 1, X11Compliance },
531  { "LightGoldenrod2", 238, 220, 130, 1, X11Compliance },
532  { "LightGoldenrod3", 205, 190, 112, 1, X11Compliance },
533  { "LightGoldenrod4", 139, 129, 76, 1, X11Compliance },
534  { "LightGoldenrodYellow", 250, 250, 210, 1, SVGCompliance | X11Compliance | XPMCompliance },
535  { "LightGray", 211, 211, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
536  { "LightGreen", 144, 238, 144, 1, SVGCompliance | X11Compliance },
537  { "LightGrey", 211, 211, 211, 1, SVGCompliance | X11Compliance },
538  { "LightPink", 255, 182, 193, 1, SVGCompliance | X11Compliance | XPMCompliance },
539  { "LightPink1", 255, 174, 185, 1, X11Compliance },
540  { "LightPink2", 238, 162, 173, 1, X11Compliance },
541  { "LightPink3", 205, 140, 149, 1, X11Compliance },
542  { "LightPink4", 139, 95, 101, 1, X11Compliance },
543  { "LightSalmon", 255, 160, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
544  { "LightSalmon1", 255, 160, 122, 1, X11Compliance },
545  { "LightSalmon2", 238, 149, 114, 1, X11Compliance },
546  { "LightSalmon3", 205, 129, 98, 1, X11Compliance },
547  { "LightSalmon4", 139, 87, 66, 1, X11Compliance },
548  { "LightSeaGreen", 32, 178, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
549  { "LightSkyBlue", 135, 206, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
550  { "LightSkyBlue1", 176, 226, 255, 1, X11Compliance },
551  { "LightSkyBlue2", 164, 211, 238, 1, X11Compliance },
552  { "LightSkyBlue3", 141, 182, 205, 1, X11Compliance },
553  { "LightSkyBlue4", 96, 123, 139, 1, X11Compliance },
554  { "LightSlateBlue", 132, 112, 255, 1, X11Compliance | XPMCompliance },
555  { "LightSlateGray", 119, 136, 153, 1, SVGCompliance | X11Compliance | XPMCompliance },
556  { "LightSlateGrey", 119, 136, 153, 1, SVGCompliance | X11Compliance },
557  { "LightSteelBlue", 176, 196, 222, 1, SVGCompliance | X11Compliance | XPMCompliance },
558  { "LightSteelBlue1", 202, 225, 255, 1, X11Compliance },
559  { "LightSteelBlue2", 188, 210, 238, 1, X11Compliance },
560  { "LightSteelBlue3", 162, 181, 205, 1, X11Compliance },
561  { "LightSteelBlue4", 110, 123, 139, 1, X11Compliance },
562  { "LightYellow", 255, 255, 224, 1, SVGCompliance | X11Compliance | XPMCompliance },
563  { "LightYellow1", 255, 255, 224, 1, X11Compliance },
564  { "LightYellow2", 238, 238, 209, 1, X11Compliance },
565  { "LightYellow3", 205, 205, 180, 1, X11Compliance },
566  { "LightYellow4", 139, 139, 122, 1, X11Compliance },
567  { "lime", 0, 255, 0, 1, SVGCompliance },
568  { "LimeGreen", 50, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance },
569  { "linen", 250, 240, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
570  { "magenta1", 255, 0, 255, 1, X11Compliance },
571  { "magenta2", 238, 0, 238, 1, X11Compliance },
572  { "magenta3", 205, 0, 205, 1, X11Compliance },
573  { "magenta4", 139, 0, 139, 1, X11Compliance },
574  { "maroon", 128, 0, 0, 1, SVGCompliance },
575  { "maroon", 176, 48, 96, 1, X11Compliance | XPMCompliance },
576  { "maroon1", 255, 52, 179, 1, X11Compliance },
577  { "maroon2", 238, 48, 167, 1, X11Compliance },
578  { "maroon3", 205, 41, 144, 1, X11Compliance },
579  { "maroon4", 139, 28, 98, 1, X11Compliance },
580  { "MediumAquamarine", 102, 205, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
581  { "MediumBlue", 0, 0, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
582  { "MediumForestGreen", 50, 129, 75, 1, X11Compliance | XPMCompliance },
583  { "MediumGoldenRod", 209, 193, 102, 1, X11Compliance | XPMCompliance },
584  { "MediumOrchid", 186, 85, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
585  { "MediumOrchid1", 224, 102, 255, 1, X11Compliance },
586  { "MediumOrchid2", 209, 95, 238, 1, X11Compliance },
587  { "MediumOrchid3", 180, 82, 205, 1, X11Compliance },
588  { "MediumOrchid4", 122, 55, 139, 1, X11Compliance },
589  { "MediumPurple", 147, 112, 219, 1, SVGCompliance | X11Compliance | XPMCompliance },
590  { "MediumPurple1", 171, 130, 255, 1, X11Compliance },
591  { "MediumPurple2", 159, 121, 238, 1, X11Compliance },
592  { "MediumPurple3", 137, 104, 205, 1, X11Compliance },
593  { "MediumPurple4", 93, 71, 139, 1, X11Compliance },
594  { "MediumSeaGreen", 60, 179, 113, 1, SVGCompliance | X11Compliance | XPMCompliance },
595  { "MediumSlateBlue", 123, 104, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
596  { "MediumSpringGreen", 0, 250, 154, 1, SVGCompliance | X11Compliance | XPMCompliance },
597  { "MediumTurquoise", 72, 209, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
598  { "MediumVioletRed", 199, 21, 133, 1, SVGCompliance | X11Compliance | XPMCompliance },
599  { "MidnightBlue", 25, 25, 112, 1, SVGCompliance | X11Compliance | XPMCompliance },
600  { "MintCream", 245, 255, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
601  { "MistyRose", 255, 228, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
602  { "MistyRose1", 255, 228, 225, 1, X11Compliance },
603  { "MistyRose2", 238, 213, 210, 1, X11Compliance },
604  { "MistyRose3", 205, 183, 181, 1, X11Compliance },
605  { "MistyRose4", 139, 125, 123, 1, X11Compliance },
606  { "moccasin", 255, 228, 181, 1, SVGCompliance | X11Compliance | XPMCompliance },
607  { "NavajoWhite", 255, 222, 173, 1, SVGCompliance | X11Compliance | XPMCompliance },
608  { "NavajoWhite1", 255, 222, 173, 1, X11Compliance },
609  { "NavajoWhite2", 238, 207, 161, 1, X11Compliance },
610  { "NavajoWhite3", 205, 179, 139, 1, X11Compliance },
611  { "NavajoWhite4", 139, 121, 94, 1, X11Compliance },
612  { "navy", 0, 0, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
613  { "NavyBlue", 0, 0, 128, 1, X11Compliance | XPMCompliance },
614  { "matte", 0, 0, 0, 0, SVGCompliance },
615  { "OldLace", 253, 245, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
616  { "olive", 128, 128, 0, 1, SVGCompliance },
617  { "OliveDrab", 107, 142, 35, 1, SVGCompliance | X11Compliance | XPMCompliance },
618  { "OliveDrab1", 192, 255, 62, 1, X11Compliance },
619  { "OliveDrab2", 179, 238, 58, 1, X11Compliance },
620  { "OliveDrab3", 154, 205, 50, 1, X11Compliance },
621  { "OliveDrab4", 105, 139, 34, 1, X11Compliance },
622  { "opaque", 0, 0, 0, 1, SVGCompliance },
623  { "orange", 255, 165, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
624  { "orange1", 255, 165, 0, 1, X11Compliance },
625  { "orange2", 238, 154, 0, 1, X11Compliance },
626  { "orange3", 205, 133, 0, 1, X11Compliance },
627  { "orange4", 139, 90, 0, 1, X11Compliance },
628  { "OrangeRed", 255, 69, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
629  { "OrangeRed1", 255, 69, 0, 1, X11Compliance },
630  { "OrangeRed2", 238, 64, 0, 1, X11Compliance },
631  { "OrangeRed3", 205, 55, 0, 1, X11Compliance },
632  { "OrangeRed4", 139, 37, 0, 1, X11Compliance },
633  { "orchid", 218, 112, 214, 1, SVGCompliance | X11Compliance | XPMCompliance },
634  { "orchid1", 255, 131, 250, 1, X11Compliance },
635  { "orchid2", 238, 122, 233, 1, X11Compliance },
636  { "orchid3", 205, 105, 201, 1, X11Compliance },
637  { "orchid4", 139, 71, 137, 1, X11Compliance },
638  { "PaleGoldenrod", 238, 232, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
639  { "PaleGreen", 152, 251, 152, 1, SVGCompliance | X11Compliance | XPMCompliance },
640  { "PaleGreen1", 154, 255, 154, 1, X11Compliance },
641  { "PaleGreen2", 144, 238, 144, 1, X11Compliance },
642  { "PaleGreen3", 124, 205, 124, 1, X11Compliance },
643  { "PaleGreen4", 84, 139, 84, 1, X11Compliance },
644  { "PaleTurquoise", 175, 238, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
645  { "PaleTurquoise1", 187, 255, 255, 1, X11Compliance },
646  { "PaleTurquoise2", 174, 238, 238, 1, X11Compliance },
647  { "PaleTurquoise3", 150, 205, 205, 1, X11Compliance },
648  { "PaleTurquoise4", 102, 139, 139, 1, X11Compliance },
649  { "PaleVioletRed", 219, 112, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
650  { "PaleVioletRed1", 255, 130, 171, 1, X11Compliance },
651  { "PaleVioletRed2", 238, 121, 159, 1, X11Compliance },
652  { "PaleVioletRed3", 205, 104, 137, 1, X11Compliance },
653  { "PaleVioletRed4", 139, 71, 93, 1, X11Compliance },
654  { "PapayaWhip", 255, 239, 213, 1, SVGCompliance | X11Compliance | XPMCompliance },
655  { "PeachPuff", 255, 218, 185, 1, SVGCompliance | X11Compliance | XPMCompliance },
656  { "PeachPuff1", 255, 218, 185, 1, X11Compliance },
657  { "PeachPuff2", 238, 203, 173, 1, X11Compliance },
658  { "PeachPuff3", 205, 175, 149, 1, X11Compliance },
659  { "PeachPuff4", 139, 119, 101, 1, X11Compliance },
660  { "peru", 205, 133, 63, 1, SVGCompliance | X11Compliance | XPMCompliance },
661  { "pink", 255, 192, 203, 1, SVGCompliance | X11Compliance | XPMCompliance },
662  { "pink1", 255, 181, 197, 1, X11Compliance },
663  { "pink2", 238, 169, 184, 1, X11Compliance },
664  { "pink3", 205, 145, 158, 1, X11Compliance },
665  { "pink4", 139, 99, 108, 1, X11Compliance },
666  { "plum", 221, 160, 221, 1, SVGCompliance | X11Compliance | XPMCompliance },
667  { "plum1", 255, 187, 255, 1, X11Compliance },
668  { "plum2", 238, 174, 238, 1, X11Compliance },
669  { "plum3", 205, 150, 205, 1, X11Compliance },
670  { "plum4", 139, 102, 139, 1, X11Compliance },
671  { "PowderBlue", 176, 224, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
672  { "purple", 128, 0, 128, 1, SVGCompliance },
673  { "purple", 160, 32, 240, 1, X11Compliance | XPMCompliance },
674  { "purple1", 155, 48, 255, 1, X11Compliance },
675  { "purple2", 145, 44, 238, 1, X11Compliance },
676  { "purple3", 125, 38, 205, 1, X11Compliance },
677  { "purple4", 85, 26, 139, 1, X11Compliance },
678  { "red1", 255, 0, 0, 1, X11Compliance },
679  { "red2", 238, 0, 0, 1, X11Compliance },
680  { "red3", 205, 0, 0, 1, X11Compliance },
681  { "red4", 139, 0, 0, 1, X11Compliance },
682  { "RosyBrown", 188, 143, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
683  { "RosyBrown1", 255, 193, 193, 1, X11Compliance },
684  { "RosyBrown2", 238, 180, 180, 1, X11Compliance },
685  { "RosyBrown3", 205, 155, 155, 1, X11Compliance },
686  { "RosyBrown4", 139, 105, 105, 1, X11Compliance },
687  { "RoyalBlue", 65, 105, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
688  { "RoyalBlue1", 72, 118, 255, 1, X11Compliance },
689  { "RoyalBlue2", 67, 110, 238, 1, X11Compliance },
690  { "RoyalBlue3", 58, 95, 205, 1, X11Compliance },
691  { "RoyalBlue4", 39, 64, 139, 1, X11Compliance },
692  { "SaddleBrown", 139, 69, 19, 1, SVGCompliance | X11Compliance | XPMCompliance },
693  { "salmon", 250, 128, 114, 1, SVGCompliance | X11Compliance | XPMCompliance },
694  { "salmon1", 255, 140, 105, 1, X11Compliance },
695  { "salmon2", 238, 130, 98, 1, X11Compliance },
696  { "salmon3", 205, 112, 84, 1, X11Compliance },
697  { "salmon4", 139, 76, 57, 1, X11Compliance },
698  { "SandyBrown", 244, 164, 96, 1, SVGCompliance | X11Compliance | XPMCompliance },
699  { "SeaGreen", 46, 139, 87, 1, SVGCompliance | X11Compliance | XPMCompliance },
700  { "SeaGreen1", 84, 255, 159, 1, X11Compliance },
701  { "SeaGreen2", 78, 238, 148, 1, X11Compliance },
702  { "SeaGreen3", 67, 205, 128, 1, X11Compliance },
703  { "SeaGreen4", 46, 139, 87, 1, X11Compliance },
704  { "seashell", 255, 245, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
705  { "seashell1", 255, 245, 238, 1, X11Compliance },
706  { "seashell2", 238, 229, 222, 1, X11Compliance },
707  { "seashell3", 205, 197, 191, 1, X11Compliance },
708  { "seashell4", 139, 134, 130, 1, X11Compliance },
709  { "sienna", 160, 82, 45, 1, SVGCompliance | X11Compliance | XPMCompliance },
710  { "sienna1", 255, 130, 71, 1, X11Compliance },
711  { "sienna2", 238, 121, 66, 1, X11Compliance },
712  { "sienna3", 205, 104, 57, 1, X11Compliance },
713  { "sienna4", 139, 71, 38, 1, X11Compliance },
714  { "silver", 192, 192, 192, 1, SVGCompliance },
715  { "SkyBlue", 135, 206, 235, 1, SVGCompliance | X11Compliance | XPMCompliance },
716  { "SkyBlue1", 135, 206, 255, 1, X11Compliance },
717  { "SkyBlue2", 126, 192, 238, 1, X11Compliance },
718  { "SkyBlue3", 108, 166, 205, 1, X11Compliance },
719  { "SkyBlue4", 74, 112, 139, 1, X11Compliance },
720  { "SlateBlue", 106, 90, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
721  { "SlateBlue1", 131, 111, 255, 1, X11Compliance },
722  { "SlateBlue2", 122, 103, 238, 1, X11Compliance },
723  { "SlateBlue3", 105, 89, 205, 1, X11Compliance },
724  { "SlateBlue4", 71, 60, 139, 1, X11Compliance },
725  { "SlateGray", 112, 128, 144, 1, SVGCompliance | X11Compliance | XPMCompliance },
726  { "SlateGray1", 198, 226, 255, 1, X11Compliance },
727  { "SlateGray2", 185, 211, 238, 1, X11Compliance },
728  { "SlateGray3", 159, 182, 205, 1, X11Compliance },
729  { "SlateGray4", 108, 123, 139, 1, X11Compliance },
730  { "SlateGrey", 112, 128, 144, 1, SVGCompliance | X11Compliance },
731  { "snow", 255, 250, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
732  { "snow1", 255, 250, 250, 1, X11Compliance },
733  { "snow2", 238, 233, 233, 1, X11Compliance },
734  { "snow3", 205, 201, 201, 1, X11Compliance },
735  { "snow4", 139, 137, 137, 1, X11Compliance },
736  { "SpringGreen", 0, 255, 127, 1, SVGCompliance | X11Compliance | XPMCompliance },
737  { "SpringGreen1", 0, 255, 127, 1, X11Compliance },
738  { "SpringGreen2", 0, 238, 118, 1, X11Compliance },
739  { "SpringGreen3", 0, 205, 102, 1, X11Compliance },
740  { "SpringGreen4", 0, 139, 69, 1, X11Compliance },
741  { "SteelBlue", 70, 130, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
742  { "SteelBlue1", 99, 184, 255, 1, X11Compliance },
743  { "SteelBlue2", 92, 172, 238, 1, X11Compliance },
744  { "SteelBlue3", 79, 148, 205, 1, X11Compliance },
745  { "SteelBlue4", 54, 100, 139, 1, X11Compliance },
746  { "tan", 210, 180, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
747  { "tan1", 255, 165, 79, 1, X11Compliance },
748  { "tan2", 238, 154, 73, 1, X11Compliance },
749  { "tan3", 205, 133, 63, 1, X11Compliance },
750  { "tan4", 139, 90, 43, 1, X11Compliance },
751  { "teal", 0, 128, 128, 1, SVGCompliance },
752  { "thistle", 216, 191, 216, 1, SVGCompliance | X11Compliance | XPMCompliance },
753  { "thistle1", 255, 225, 255, 1, X11Compliance },
754  { "thistle2", 238, 210, 238, 1, X11Compliance },
755  { "thistle3", 205, 181, 205, 1, X11Compliance },
756  { "thistle4", 139, 123, 139, 1, X11Compliance },
757  { "tomato", 255, 99, 71, 1, SVGCompliance | X11Compliance | XPMCompliance },
758  { "tomato1", 255, 99, 71, 1, X11Compliance },
759  { "tomato2", 238, 92, 66, 1, X11Compliance },
760  { "tomato3", 205, 79, 57, 1, X11Compliance },
761  { "tomato4", 139, 54, 38, 1, X11Compliance },
762  { "transparent", 0, 0, 0, 0, SVGCompliance },
763  { "turquoise", 64, 224, 208, 1, SVGCompliance | X11Compliance | XPMCompliance },
764  { "turquoise1", 0, 245, 255, 1, X11Compliance },
765  { "turquoise2", 0, 229, 238, 1, X11Compliance },
766  { "turquoise3", 0, 197, 205, 1, X11Compliance },
767  { "turquoise4", 0, 134, 139, 1, X11Compliance },
768  { "violet", 238, 130, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
769  { "VioletRed", 208, 32, 144, 1, X11Compliance | XPMCompliance },
770  { "VioletRed1", 255, 62, 150, 1, X11Compliance },
771  { "VioletRed2", 238, 58, 140, 1, X11Compliance },
772  { "VioletRed3", 205, 50, 120, 1, X11Compliance },
773  { "VioletRed4", 139, 34, 82, 1, X11Compliance },
774  { "wheat", 245, 222, 179, 1, SVGCompliance | X11Compliance | XPMCompliance },
775  { "wheat1", 255, 231, 186, 1, X11Compliance },
776  { "wheat2", 238, 216, 174, 1, X11Compliance },
777  { "wheat3", 205, 186, 150, 1, X11Compliance },
778  { "wheat4", 139, 126, 102, 1, X11Compliance },
779  { "WhiteSmoke", 245, 245, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
780  { "yellow1", 255, 255, 0, 1, X11Compliance },
781  { "yellow2", 238, 238, 0, 1, X11Compliance },
782  { "yellow3", 205, 205, 0, 1, X11Compliance },
783  { "yellow4", 139, 139, 0, 1, X11Compliance },
784  { "YellowGreen", 154, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance }
785  };
786 
787 /*
788  Static declarations.
789 */
790 static LinkedListInfo
792 
793 static SemaphoreInfo
795 
796 /*
797  Forward declarations.
798 */
799 static MagickBooleanType
801  LoadColorCache(LinkedListInfo *,const char *,const char *,const size_t,
802  ExceptionInfo *);
803 
804 /*
805 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 % %
807 % %
808 % %
809 % A c q u i r e C o l o r C a c h e %
810 % %
811 % %
812 % %
813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
814 %
815 % AcquireColorCache() caches one or more color configurations which provides a
816 % mapping between color attributes and a color name.
817 %
818 % The format of the AcquireColorCache method is:
819 %
820 % LinkedListInfo *AcquireColorCache(const char *filename,
821 % ExceptionInfo *exception)
822 %
823 % A description of each parameter follows:
824 %
825 % o filename: the font file name.
826 %
827 % o exception: return any errors or warnings in this structure.
828 %
829 */
830 static LinkedListInfo *AcquireColorCache(const char *filename,
831  ExceptionInfo *exception)
832 {
834  *cache;
835 
837  status;
838 
839  register ssize_t
840  i;
841 
842  /*
843  Load external color map.
844  */
845  cache=NewLinkedList(0);
846  status=MagickTrue;
847 #if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
848  {
849  const StringInfo
850  *option;
851 
853  *options;
854 
855  options=GetConfigureOptions(filename,exception);
856  option=(const StringInfo *) GetNextValueInLinkedList(options);
857  while (option != (const StringInfo *) NULL)
858  {
859  status&=LoadColorCache(cache,(const char *) GetStringInfoDatum(option),
860  GetStringInfoPath(option),0,exception);
861  option=(const StringInfo *) GetNextValueInLinkedList(options);
862  }
863  options=DestroyConfigureOptions(options);
864  }
865 #endif
866  /*
867  Load built-in color map.
868  */
869  for (i=0; i < (ssize_t) (sizeof(Colormap)/sizeof(*Colormap)); i++)
870  {
871  ColorInfo
872  *color_info;
873 
874  register const ColormapInfo
875  *p;
876 
877  p=Colormap+i;
878  color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
879  if (color_info == (ColorInfo *) NULL)
880  {
881  (void) ThrowMagickException(exception,GetMagickModule(),
882  ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
883  continue;
884  }
885  (void) memset(color_info,0,sizeof(*color_info));
886  color_info->path=(char *) "[built-in]";
887  color_info->name=(char *) p->name;
888  GetPixelInfo((Image *) NULL,&color_info->color);
889  color_info->color.red=(double) ScaleCharToQuantum(p->red);
890  color_info->color.green=(double) ScaleCharToQuantum(p->green);
891  color_info->color.blue=(double) ScaleCharToQuantum(p->blue);
892  color_info->color.alpha=(double) (QuantumRange*p->alpha);
893  color_info->compliance=(ComplianceType) p->compliance;
894  color_info->exempt=MagickTrue;
895  color_info->signature=MagickCoreSignature;
896  status&=AppendValueToLinkedList(cache,color_info);
897  if (status == MagickFalse)
898  (void) ThrowMagickException(exception,GetMagickModule(),
899  ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
900  }
901  return(cache);
902 }
903 
904 /*
905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 % %
907 % %
908 % %
909 + C o l o r C o m p o n e n t G e n e s i s %
910 % %
911 % %
912 % %
913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914 %
915 % ColorComponentGenesis() instantiates the color component.
916 %
917 % The format of the ColorComponentGenesis method is:
918 %
919 % MagickBooleanType ColorComponentGenesis(void)
920 %
921 */
923 {
924  if (color_semaphore == (SemaphoreInfo *) NULL)
926  return(MagickTrue);
927 }
928 
929 /*
930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
931 % %
932 % %
933 % %
934 + C o l o r C o m p o n e n t T e r m i n u s %
935 % %
936 % %
937 % %
938 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
939 %
940 % ColorComponentTerminus() destroys the color component.
941 %
942 % The format of the ColorComponentTerminus method is:
943 %
944 % ColorComponentTerminus(void)
945 %
946 */
947 
948 static void *DestroyColorElement(void *color_info)
949 {
950  register ColorInfo
951  *p;
952 
953  p=(ColorInfo *) color_info;
954  if (p->exempt == MagickFalse)
955  {
956  if (p->path != (char *) NULL)
957  p->path=DestroyString(p->path);
958  if (p->name != (char *) NULL)
959  p->name=DestroyString(p->name);
960  }
962  return((void *) NULL);
963 }
964 
966 {
967  if (color_semaphore == (SemaphoreInfo *) NULL)
970  if (color_cache != (LinkedListInfo *) NULL)
974 }
975 
976 /*
977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
978 % %
979 % %
980 % %
981 + G e t C o l o r C o m p l i a n c e %
982 % %
983 % %
984 % %
985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
986 %
987 % GetColorInfo() searches the color list for the specified name and standards
988 % compliance and if found returns attributes for that color.
989 %
990 % The format of the GetColorInfo method is:
991 %
992 % const PixelInfo *GetColorInfo(const char *name,
993 % const ComplianceType compliance,ExceptionInfo *exception)
994 %
995 % A description of each parameter follows:
996 %
997 % o name: the color name.
998 %
999 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
1000 %
1001 % o exception: return any errors or warnings in this structure.
1002 %
1003 */
1005  const ComplianceType compliance,ExceptionInfo *exception)
1006 {
1007  char
1008  colorname[MagickPathExtent];
1009 
1010  register const ColorInfo
1011  *p;
1012 
1013  register char
1014  *q;
1015 
1016  assert(exception != (ExceptionInfo *) NULL);
1017  if (IsColorCacheInstantiated(exception) == MagickFalse)
1018  return((const ColorInfo *) NULL);
1019  /*
1020  Strip names of whitespace.
1021  */
1022  *colorname='\0';
1023  if (name != (const char *) NULL)
1024  (void) CopyMagickString(colorname,name,MagickPathExtent);
1025  for (q=colorname; *q != '\0'; q++)
1026  {
1027  if (isspace((int) ((unsigned char) *q)) == 0)
1028  continue;
1029  (void) CopyMagickString(q,q+1,MagickPathExtent);
1030  q--;
1031  }
1032  /*
1033  Search for color tag.
1034  */
1038  if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
1039  {
1041  return(p);
1042  }
1043  while (p != (const ColorInfo *) NULL)
1044  {
1045  if (((p->compliance & compliance) != 0) &&
1046  (LocaleCompare(colorname,p->name) == 0))
1047  break;
1049  }
1050  if (p == (ColorInfo *) NULL)
1052  "UnrecognizedColor","`%s'",name);
1053  else
1057  return(p);
1058 }
1059 
1060 /*
1061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1062 % %
1063 % %
1064 % %
1065 + G e t C o l o r I n f o %
1066 % %
1067 % %
1068 % %
1069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1070 %
1071 % GetColorInfo() searches the color list for the specified name and if found
1072 % returns attributes for that color.
1073 %
1074 % The format of the GetColorInfo method is:
1075 %
1076 % const PixelInfo *GetColorInfo(const char *name,
1077 % ExceptionInfo *exception)
1078 %
1079 % A description of each parameter follows:
1080 %
1081 % o color_info: search the color list for the specified name and if found
1082 % return attributes for that color.
1083 %
1084 % o name: the color name.
1085 %
1086 % o exception: return any errors or warnings in this structure.
1087 %
1088 */
1089 MagickExport const ColorInfo *GetColorInfo(const char *name,
1090  ExceptionInfo *exception)
1091 {
1092  return(GetColorCompliance(name,AllCompliance,exception));
1093 }
1094 
1095 /*
1096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1097 % %
1098 % %
1099 % %
1100 + C o n c a t e n a t e C o l o r C o m p o n e n t %
1101 % %
1102 % %
1103 % %
1104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1105 %
1106 % ConcatenateColorComponent() returns the pixel as a canonical string.
1107 %
1108 % The format of the ConcatenateColorComponent() method is:
1109 %
1110 % void ConcatenateColorComponent(const PixelInfo *pixel,
1111 % const PixelChannel channel,const ComplianceType compliance,
1112 % char *tuple)
1113 %
1114 % A description of each parameter follows.
1115 %
1116 % o pixel: The pixel.
1117 %
1118 % o channel: The pixel channel.
1119 %
1120 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
1121 %
1122 % o tuple: The color tuple.
1123 %
1124 */
1126  const PixelChannel channel,const ComplianceType compliance,char *tuple)
1127 {
1128  char
1129  component[MagickPathExtent];
1130 
1131  double
1132  color;
1133 
1134  color=0.0;
1135  switch (channel)
1136  {
1137  case RedPixelChannel:
1138  {
1139  color=pixel->red;
1140  break;
1141  }
1142  case GreenPixelChannel:
1143  {
1144  color=pixel->green;
1145  break;
1146  }
1147  case BluePixelChannel:
1148  {
1149  color=pixel->blue;
1150  break;
1151  }
1152  case AlphaPixelChannel:
1153  {
1154  color=pixel->alpha;
1155  break;
1156  }
1157  case BlackPixelChannel:
1158  {
1159  color=pixel->black;
1160  break;
1161  }
1162  default:
1163  break;
1164  }
1165  if (compliance == NoCompliance)
1166  {
1167  if (pixel->colorspace == LabColorspace)
1168  {
1169  (void) FormatLocaleString(component,MagickPathExtent,"%.*g",
1170  GetMagickPrecision(),(double) color);
1171  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1172  return;
1173  }
1174  (void) FormatLocaleString(component,MagickPathExtent,"%.*g",
1175  GetMagickPrecision(),(double) ClampToQuantum(color));
1176  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1177  return;
1178  }
1179  if (compliance != SVGCompliance)
1180  {
1181  if (pixel->depth > 16)
1182  {
1183  (void) FormatLocaleString(component,MagickPathExtent,"%10lu",
1184  (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1185  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1186  return;
1187  }
1188  if (pixel->depth > 8)
1189  {
1190  (void) FormatLocaleString(component,MagickPathExtent,"%5d",
1191  ScaleQuantumToShort(ClampToQuantum(color)));
1192  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1193  return;
1194  }
1195  (void) FormatLocaleString(component,MagickPathExtent,"%3d",
1196  ScaleQuantumToChar(ClampToQuantum(color)));
1197  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1198  return;
1199  }
1200  if (channel == AlphaPixelChannel)
1201  {
1202  (void) FormatLocaleString(component,MagickPathExtent,"%.*g",
1203  GetMagickPrecision(),(double) QuantumScale*ClampToQuantum(color));
1204  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1205  return;
1206  }
1207  if ((pixel->colorspace == HCLColorspace) ||
1208  (pixel->colorspace == HCLpColorspace) ||
1209  (pixel->colorspace == HSBColorspace) ||
1210  (pixel->colorspace == HSIColorspace) ||
1211  (pixel->colorspace == HSLColorspace) ||
1212  (pixel->colorspace == HSVColorspace) ||
1213  (pixel->colorspace == HWBColorspace))
1214  {
1215  if (channel == RedPixelChannel)
1216  (void) FormatLocaleString(component,MagickPathExtent,"%.*g",
1218  color));
1219  else
1220  (void) FormatLocaleString(component,MagickPathExtent,"%.*g%%",
1222  color));
1223  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1224  return;
1225  }
1226  if (pixel->colorspace == LabColorspace)
1227  {
1228  (void) FormatLocaleString(component,MagickPathExtent,"%.*g%%",
1229  GetMagickPrecision(),100.0*QuantumScale*color);
1230  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1231  return;
1232  }
1233  if (pixel->depth > 8)
1234  {
1235  (void) FormatLocaleString(component,MagickPathExtent,"%.*g%%",
1236  GetMagickPrecision(),(double) ClampToQuantum(100.0*QuantumScale*color));
1237  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1238  return;
1239  }
1240  (void) FormatLocaleString(component,MagickPathExtent,"%d",ScaleQuantumToChar(
1241  ClampToQuantum(color)));
1242  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1243 }
1244 
1245 /*
1246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1247 % %
1248 % %
1249 % %
1250 % G e t C o l o r I n f o L i s t %
1251 % %
1252 % %
1253 % %
1254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1255 %
1256 % GetColorInfoList() returns any colors that match the specified pattern.
1257 %
1258 % The format of the GetColorInfoList function is:
1259 %
1260 % const ColorInfo **GetColorInfoList(const char *pattern,
1261 % size_t *number_colors,ExceptionInfo *exception)
1262 %
1263 % A description of each parameter follows:
1264 %
1265 % o pattern: Specifies a pointer to a text string containing a pattern.
1266 %
1267 % o number_colors: This integer returns the number of colors in the list.
1268 %
1269 % o exception: return any errors or warnings in this structure.
1270 %
1271 */
1272 
1273 #if defined(__cplusplus) || defined(c_plusplus)
1274 extern "C" {
1275 #endif
1276 
1277 static int ColorInfoCompare(const void *x,const void *y)
1278 {
1279  const ColorInfo
1280  **p,
1281  **q;
1282 
1283  int
1284  cmp;
1285 
1286  p=(const ColorInfo **) x,
1287  q=(const ColorInfo **) y;
1288  cmp=LocaleCompare((*p)->path,(*q)->path);
1289  if (cmp == 0)
1290  return(LocaleCompare((*p)->name,(*q)->name));
1291  return(cmp);
1292 }
1293 
1294 #if defined(__cplusplus) || defined(c_plusplus)
1295 }
1296 #endif
1297 
1298 MagickExport const ColorInfo **GetColorInfoList(const char *pattern,
1299  size_t *number_colors,ExceptionInfo *exception)
1300 {
1301  const ColorInfo
1302  **colors;
1303 
1304  register const ColorInfo
1305  *p;
1306 
1307  register ssize_t
1308  i;
1309 
1310  /*
1311  Allocate color list.
1312  */
1313  assert(pattern != (char *) NULL);
1314  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1315  assert(number_colors != (size_t *) NULL);
1316  *number_colors=0;
1317  p=GetColorInfo("*",exception);
1318  if (p == (const ColorInfo *) NULL)
1319  return((const ColorInfo **) NULL);
1320  colors=(const ColorInfo **) AcquireQuantumMemory((size_t)
1321  GetNumberOfElementsInLinkedList(color_cache)+1UL,sizeof(*colors));
1322  if (colors == (const ColorInfo **) NULL)
1323  return((const ColorInfo **) NULL);
1324  /*
1325  Generate color list.
1326  */
1330  for (i=0; p != (const ColorInfo *) NULL; )
1331  {
1332  if ((p->stealth == MagickFalse) &&
1333  (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1334  colors[i++]=p;
1336  }
1338  qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
1339  colors[i]=(ColorInfo *) NULL;
1340  *number_colors=(size_t) i;
1341  return(colors);
1342 }
1343 
1344 /*
1345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1346 % %
1347 % %
1348 % %
1349 % G e t C o l o r L i s t %
1350 % %
1351 % %
1352 % %
1353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1354 %
1355 % GetColorList() returns any colors that match the specified pattern.
1356 %
1357 % The format of the GetColorList function is:
1358 %
1359 % char **GetColorList(const char *pattern,size_t *number_colors,
1360 % ExceptionInfo *exception)
1361 %
1362 % A description of each parameter follows:
1363 %
1364 % o pattern: Specifies a pointer to a text string containing a pattern.
1365 %
1366 % o number_colors: This integer returns the number of colors in the list.
1367 %
1368 % o exception: return any errors or warnings in this structure.
1369 %
1370 */
1371 
1372 #if defined(__cplusplus) || defined(c_plusplus)
1373 extern "C" {
1374 #endif
1375 
1376 static int ColorCompare(const void *x,const void *y)
1377 {
1378  register const char
1379  **p,
1380  **q;
1381 
1382  p=(const char **) x;
1383  q=(const char **) y;
1384  return(LocaleCompare(*p,*q));
1385 }
1386 
1387 #if defined(__cplusplus) || defined(c_plusplus)
1388 }
1389 #endif
1390 
1391 MagickExport char **GetColorList(const char *pattern,
1392  size_t *number_colors,ExceptionInfo *exception)
1393 {
1394  char
1395  **colors;
1396 
1397  register const ColorInfo
1398  *p;
1399 
1400  register ssize_t
1401  i;
1402 
1403  /*
1404  Allocate color list.
1405  */
1406  assert(pattern != (char *) NULL);
1407  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1408  assert(number_colors != (size_t *) NULL);
1409  *number_colors=0;
1410  p=GetColorInfo("*",exception);
1411  if (p == (const ColorInfo *) NULL)
1412  return((char **) NULL);
1413  colors=(char **) AcquireQuantumMemory((size_t)
1414  GetNumberOfElementsInLinkedList(color_cache)+1UL,sizeof(*colors));
1415  if (colors == (char **) NULL)
1416  return((char **) NULL);
1417  /*
1418  Generate color list.
1419  */
1423  for (i=0; p != (const ColorInfo *) NULL; )
1424  {
1425  if ((p->stealth == MagickFalse) &&
1426  (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1427  colors[i++]=ConstantString(p->name);
1429  }
1431  qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
1432  colors[i]=(char *) NULL;
1433  *number_colors=(size_t) i;
1434  return(colors);
1435 }
1436 
1437 /*
1438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1439 % %
1440 % %
1441 % %
1442 + G e t C o l o r T u p l e %
1443 % %
1444 % %
1445 % %
1446 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1447 %
1448 % GetColorTuple() returns a color as a color tuple string (e.g. rgba(255,0,0))
1449 % or hex string (e.g. #FF0000).
1450 %
1451 % The format of the GetColorTuple method is:
1452 %
1453 % GetColorTuple(const PixelInfo *pixel,const MagickBooleanType hex,
1454 % char *tuple)
1455 %
1456 % A description of each parameter follows.
1457 %
1458 % o pixel: the pixel.
1459 %
1460 % o hex: A value other than zero returns the tuple in a hexidecimal format.
1461 %
1462 % o tuple: Return the color tuple as this string.
1463 %
1464 */
1465 
1466 static inline MagickBooleanType IsSVGCompliant(const PixelInfo *pixel)
1467 {
1468 #define SVGCompliant(component) ((double) \
1469  ScaleCharToQuantum(ScaleQuantumToChar(ClampToQuantum(component))))
1470 
1471  /*
1472  SVG requires color depths > 8 expressed as percentages.
1473  */
1474  if (fabs(SVGCompliant(pixel->red)-pixel->red) >= MagickEpsilon)
1475  return(MagickFalse);
1476  if (fabs(SVGCompliant(pixel->green)-pixel->green) >= MagickEpsilon)
1477  return(MagickFalse);
1478  if (fabs(SVGCompliant(pixel->blue)-pixel->blue) >= MagickEpsilon)
1479  return(MagickFalse);
1480  if ((pixel->colorspace == CMYKColorspace) &&
1481  (fabs(SVGCompliant(pixel->black)-pixel->black) >= MagickEpsilon))
1482  return(MagickFalse);
1483  if ((pixel->alpha_trait != UndefinedPixelTrait) &&
1484  (fabs(SVGCompliant(pixel->alpha)-pixel->alpha) >= MagickEpsilon))
1485  return(MagickFalse);
1486  return(MagickTrue);
1487 }
1488 
1489 static void ConcatentateHexColorComponent(const PixelInfo *pixel,
1490  const PixelChannel channel,char *tuple)
1491 {
1492  char
1493  component[MagickPathExtent];
1494 
1495  double
1496  color;
1497 
1498  color=0.0;
1499  switch (channel)
1500  {
1501  case RedPixelChannel:
1502  {
1503  color=pixel->red;
1504  break;
1505  }
1506  case GreenPixelChannel:
1507  {
1508  color=pixel->green;
1509  break;
1510  }
1511  case BluePixelChannel:
1512  {
1513  color=pixel->blue;
1514  break;
1515  }
1516  case AlphaPixelChannel:
1517  {
1518  color=pixel->alpha;
1519  break;
1520  }
1521  case BlackPixelChannel:
1522  {
1523  color=pixel->black;
1524  break;
1525  }
1526  default:
1527  break;
1528  }
1529  if (pixel->depth > 32)
1530  {
1531  (void) FormatLocaleString(component,MagickPathExtent,"%08lX%08lX",
1532  (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)),
1533  (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1534  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1535  return;
1536  }
1537  if (pixel->depth > 16)
1538  {
1539  (void) FormatLocaleString(component,MagickPathExtent,"%08X",
1540  (unsigned int) ScaleQuantumToLong(ClampToQuantum(color)));
1541  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1542  return;
1543  }
1544  if (pixel->depth > 8)
1545  {
1546  (void) FormatLocaleString(component,MagickPathExtent,"%04X",
1547  ScaleQuantumToShort(ClampToQuantum(color)));
1548  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1549  return;
1550  }
1551  (void) FormatLocaleString(component,MagickPathExtent,"%02X",
1552  ScaleQuantumToChar(ClampToQuantum(color)));
1553  (void) ConcatenateMagickString(tuple,component,MagickPathExtent);
1554  return;
1555 }
1556 
1558  const MagickBooleanType hex,char *tuple)
1559 {
1560  PixelInfo
1561  color;
1562 
1563  assert(pixel != (const PixelInfo *) NULL);
1564  assert(tuple != (char *) NULL);
1565  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tuple);
1566  *tuple='\0';
1567  if (hex != MagickFalse)
1568  {
1569  /*
1570  Convert pixel to hex color.
1571  */
1572  (void) ConcatenateMagickString(tuple,"#",MagickPathExtent);
1576  if (pixel->colorspace == CMYKColorspace)
1578  if (pixel->alpha_trait != UndefinedPixelTrait)
1580  return;
1581  }
1582  /*
1583  Convert pixel to rgb() or cmyk() color.
1584  */
1585  color=(*pixel);
1586  if ((color.depth > 8) && (IsSVGCompliant(pixel) != MagickFalse))
1587  color.depth=8;
1590  if (color.alpha_trait != UndefinedPixelTrait)
1591  (void) ConcatenateMagickString(tuple,"a",MagickPathExtent);
1592  (void) ConcatenateMagickString(tuple,"(",MagickPathExtent);
1593  if ((color.colorspace == LinearGRAYColorspace) ||
1594  (color.colorspace == GRAYColorspace))
1596  else
1597  {
1599  (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1601  (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1603  }
1604  if (color.colorspace == CMYKColorspace)
1605  {
1606  (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1608  }
1609  if (color.alpha_trait != UndefinedPixelTrait)
1610  {
1611  (void) ConcatenateMagickString(tuple,",",MagickPathExtent);
1613  }
1614  (void) ConcatenateMagickString(tuple,")",MagickPathExtent);
1615  LocaleLower(tuple);
1616  return;
1617 }
1618 
1619 /*
1620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1621 % %
1622 % %
1623 % %
1624 + I s C o l o r C a c h e I n s t a n t i a t e d %
1625 % %
1626 % %
1627 % %
1628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1629 %
1630 % IsColorCacheInstantiated() determines if the color list is instantiated. If
1631 % not, it instantiates the list and returns it.
1632 %
1633 % The format of the IsColorInstantiated method is:
1634 %
1635 % MagickBooleanType IsColorCacheInstantiated(ExceptionInfo *exception)
1636 %
1637 % A description of each parameter follows.
1638 %
1639 % o exception: return any errors or warnings in this structure.
1640 %
1641 */
1643 {
1644  if (color_cache == (LinkedListInfo *) NULL)
1645  {
1646  if (color_semaphore == (SemaphoreInfo *) NULL)
1649  if (color_cache == (LinkedListInfo *) NULL)
1652  }
1653  return(color_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1654 }
1655 
1656 /*
1657 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1658 % %
1659 % %
1660 % %
1661 + I s E q u i v a l e n t A l p h a %
1662 % %
1663 % %
1664 % %
1665 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1666 %
1667 % IsEquivalentAlpha() returns true if the distance between two alpha values is
1668 % less than the specified distance in a linear color space. This method is
1669 % used by MatteFloodFill() and other algorithms which compare two alpha values.
1670 %
1671 % The format of the IsEquivalentAlpha method is:
1672 %
1673 % void IsEquivalentAlpha(const Image *image,const PixelInfo *p,
1674 % const PixelInfo *q)
1675 %
1676 % A description of each parameter follows:
1677 %
1678 % o image: the image.
1679 %
1680 % o p: Pixel p.
1681 %
1682 % o q: Pixel q.
1683 %
1684 */
1686  const PixelInfo *p,const PixelInfo *q)
1687 {
1688  double
1689  fuzz,
1690  pixel;
1691 
1692  register double
1693  distance;
1694 
1695  if (image->alpha_trait == UndefinedPixelTrait)
1696  return(MagickTrue);
1697  if (p->alpha == q->alpha)
1698  return(MagickTrue);
1699  fuzz=MagickMax(image->fuzz,MagickSQ1_2);
1700  fuzz*=fuzz;
1701  pixel=(double) p->alpha-(double) q->alpha;
1702  distance=pixel*pixel;
1703  if (distance > fuzz)
1704  return(MagickFalse);
1705  return(MagickTrue);
1706 }
1707 
1708 /*
1709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1710 % %
1711 % %
1712 % %
1713 + I s E q u i v a l e n t I m a g e %
1714 % %
1715 % %
1716 % %
1717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1718 %
1719 % IsEquivalentImage() returns true if the target is similar to a region of the
1720 % image.
1721 %
1722 % The format of the IsEquivalentImage method is:
1723 %
1724 % MagickBooleanType IsEquivalentImage(const Image *image,
1725 % const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1726 % ExceptionInfo *exception)
1727 %
1728 % A description of each parameter follows:
1729 %
1730 % o image: the image.
1731 %
1732 % o target_image: the target image.
1733 %
1734 % o x_offset: On input the starting x position to search for a match;
1735 % on output the x position of the first match found.
1736 %
1737 % o y_offset: On input the starting y position to search for a match;
1738 % on output the y position of the first match found.
1739 %
1740 % o exception: return any errors or warnings in this structure.
1741 %
1742 */
1744  const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1745  ExceptionInfo *exception)
1746 {
1747 #define SearchImageText " Searching image... "
1748 
1749  CacheView
1750  *image_view,
1751  *target_view;
1752 
1754  status;
1755 
1756  PixelInfo
1757  target,
1758  pixel;
1759 
1760  register const Quantum
1761  *p,
1762  *q;
1763 
1764  register ssize_t
1765  i,
1766  x;
1767 
1768  ssize_t
1769  j,
1770  y;
1771 
1772  assert(image != (Image *) NULL);
1773  assert(image->signature == MagickCoreSignature);
1774  if (image->debug != MagickFalse)
1775  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1776  assert(target_image != (Image *) NULL);
1777  assert(target_image->signature == MagickCoreSignature);
1778  assert(x_offset != (ssize_t *) NULL);
1779  assert(y_offset != (ssize_t *) NULL);
1780  assert(exception != (ExceptionInfo *) NULL);
1781  x=0;
1782  status=MagickTrue;
1783  GetPixelInfo(image,&pixel);
1784  GetPixelInfo(image,&target);
1785  image_view=AcquireVirtualCacheView(image,exception);
1786  target_view=AcquireVirtualCacheView(target_image,exception);
1787  for (y=(*y_offset); y < (ssize_t) image->rows; y++)
1788  {
1789  for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
1790  {
1791  for (j=0; j < (ssize_t) target_image->rows; j++)
1792  {
1793  for (i=0; i < (ssize_t) target_image->columns; i++)
1794  {
1795  p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
1796  if (p == (const Quantum *) NULL)
1797  break;
1798  GetPixelInfoPixel(image,p,&pixel);
1799  q=GetCacheViewVirtualPixels(target_view,i,j,1,1,exception);
1800  if (q == (const Quantum *) NULL)
1801  break;
1802  GetPixelInfoPixel(image,q,&target);
1803  if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)
1804  break;
1805  }
1806  if (i < (ssize_t) target_image->columns)
1807  break;
1808  }
1809  if (j == (ssize_t) target_image->rows)
1810  break;
1811  }
1812  if (x < (ssize_t) image->columns)
1813  break;
1814  if (image->progress_monitor != (MagickProgressMonitor) NULL)
1815  {
1817  proceed;
1818 
1820  image->rows);
1821  if (proceed == MagickFalse)
1822  status=MagickFalse;
1823  }
1824  }
1825  target_view=DestroyCacheView(target_view);
1826  image_view=DestroyCacheView(image_view);
1827  *x_offset=x;
1828  *y_offset=y;
1829  if (status == MagickFalse)
1830  return(status);
1831  return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
1832 }
1833 
1834 /*
1835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1836 % %
1837 % %
1838 % %
1839 + I s E q u i v a l e n t I n t e n s i t y %
1840 % %
1841 % %
1842 % %
1843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1844 %
1845 % IsEquivalentIntensity() returns true if the distance between two intensity
1846 % values is less than the specified distance in a linear color space.
1847 %
1848 % The format of the IsEquivalentIntensity method is:
1849 %
1850 % void IsEquivalentIntensity(const Image *image,const PixelInfo *p,
1851 % const PixelInfo *q)
1852 %
1853 % A description of each parameter follows:
1854 %
1855 % o image: the image.
1856 %
1857 % o p: Pixel p.
1858 %
1859 % o q: Pixel q.
1860 %
1861 */
1863  const PixelInfo *p,const PixelInfo *q)
1864 {
1865  double
1866  fuzz,
1867  pixel;
1868 
1869  register double
1870  distance;
1871 
1872  if (GetPixelInfoIntensity(image,p) == GetPixelInfoIntensity(image,q))
1873  return(MagickTrue);
1874  fuzz=MagickMax(image->fuzz,MagickSQ1_2);
1875  fuzz*=fuzz;
1876  pixel=GetPixelInfoIntensity(image,p)-GetPixelInfoIntensity(image,q);
1877  distance=pixel*pixel;
1878  if (distance > fuzz)
1879  return(MagickFalse);
1880  return(MagickTrue);
1881 }
1882 
1883 /*
1884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1885 % %
1886 % %
1887 % %
1888 % L i s t C o l o r I n f o %
1889 % %
1890 % %
1891 % %
1892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1893 %
1894 % ListColorInfo() lists color names to the specified file. Color names
1895 % are a convenience. Rather than defining a color by its red, green, and
1896 % blue intensities just use a color name such as white, blue, or yellow.
1897 %
1898 % The format of the ListColorInfo method is:
1899 %
1900 % MagickBooleanType ListColorInfo(FILE *file,ExceptionInfo *exception)
1901 %
1902 % A description of each parameter follows.
1903 %
1904 % o file: List color names to this file handle.
1905 %
1906 % o exception: return any errors or warnings in this structure.
1907 %
1908 */
1910  ExceptionInfo *exception)
1911 {
1912  char
1913  tuple[MagickPathExtent];
1914 
1915  const char
1916  *path;
1917 
1918  const ColorInfo
1919  **color_info;
1920 
1921  register ssize_t
1922  i;
1923 
1924  size_t
1925  number_colors;
1926 
1927  /*
1928  List name and attributes of each color in the list.
1929  */
1930  if (file == (const FILE *) NULL)
1931  file=stdout;
1932  color_info=GetColorInfoList("*",&number_colors,exception);
1933  if (color_info == (const ColorInfo **) NULL)
1934  return(MagickFalse);
1935  path=(const char *) NULL;
1936  for (i=0; i < (ssize_t) number_colors; i++)
1937  {
1938  if (color_info[i]->stealth != MagickFalse)
1939  continue;
1940  if ((path == (const char *) NULL) ||
1941  (LocaleCompare(path,color_info[i]->path) != 0))
1942  {
1943  if (color_info[i]->path != (char *) NULL)
1944  (void) FormatLocaleFile(file,"\nPath: %s\n\n",color_info[i]->path);
1945  (void) FormatLocaleFile(file,
1946  "Name Color "
1947  " Compliance\n");
1948  (void) FormatLocaleFile(file,
1949  "-------------------------------------------------"
1950  "------------------------------\n");
1951  }
1952  path=color_info[i]->path;
1953  (void) FormatLocaleFile(file,"%-21.21s ",color_info[i]->name);
1954  GetColorTuple(&color_info[i]->color,MagickFalse,tuple);
1955  (void) FormatLocaleFile(file,"%-45.45s ",tuple);
1956  if ((color_info[i]->compliance & SVGCompliance) != 0)
1957  (void) FormatLocaleFile(file,"SVG ");
1958  if ((color_info[i]->compliance & X11Compliance) != 0)
1959  (void) FormatLocaleFile(file,"X11 ");
1960  if ((color_info[i]->compliance & XPMCompliance) != 0)
1961  (void) FormatLocaleFile(file,"XPM ");
1962  (void) FormatLocaleFile(file,"\n");
1963  }
1964  color_info=(const ColorInfo **) RelinquishMagickMemory((void *) color_info);
1965  (void) fflush(file);
1966  return(MagickTrue);
1967 }
1968 
1969 /*
1970 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1971 % %
1972 % %
1973 % %
1974 + L o a d C o l o r C a c h e %
1975 % %
1976 % %
1977 % %
1978 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1979 %
1980 % LoadColorCache() loads the color configurations which provides a mapping
1981 % between color attributes and a color name.
1982 %
1983 % The format of the LoadColorCache method is:
1984 %
1985 % MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
1986 % const char *filename,const size_t depth,ExceptionInfo *exception)
1987 %
1988 % A description of each parameter follows:
1989 %
1990 % o xml: The color list in XML format.
1991 %
1992 % o filename: The color list filename.
1993 %
1994 % o depth: depth of <include /> statements.
1995 %
1996 % o exception: return any errors or warnings in this structure.
1997 %
1998 */
1999 static MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
2000  const char *filename,const size_t depth,ExceptionInfo *exception)
2001 {
2002  char
2003  keyword[MagickPathExtent],
2004  *token;
2005 
2006  ColorInfo
2007  *color_info;
2008 
2009  const char
2010  *q;
2011 
2013  status;
2014 
2015  size_t
2016  extent;
2017 
2018  /*
2019  Load the color map file.
2020  */
2022  "Loading color file \"%s\" ...",filename);
2023  if (xml == (char *) NULL)
2024  return(MagickFalse);
2025  status=MagickTrue;
2026  color_info=(ColorInfo *) NULL;
2027  token=AcquireString(xml);
2028  extent=strlen(token)+MagickPathExtent;
2029  for (q=(char *) xml; *q != '\0'; )
2030  {
2031  /*
2032  Interpret XML.
2033  */
2034  (void) GetNextToken(q,&q,extent,token);
2035  if (*token == '\0')
2036  break;
2037  (void) CopyMagickString(keyword,token,MagickPathExtent);
2038  if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
2039  {
2040  /*
2041  Doctype element.
2042  */
2043  while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
2044  (void) GetNextToken(q,&q,extent,token);
2045  continue;
2046  }
2047  if (LocaleNCompare(keyword,"<!--",4) == 0)
2048  {
2049  /*
2050  Comment element.
2051  */
2052  while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
2053  (void) GetNextToken(q,&q,extent,token);
2054  continue;
2055  }
2056  if (LocaleCompare(keyword,"<include") == 0)
2057  {
2058  /*
2059  Include element.
2060  */
2061  while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
2062  {
2063  (void) CopyMagickString(keyword,token,MagickPathExtent);
2064  (void) GetNextToken(q,&q,extent,token);
2065  if (*token != '=')
2066  continue;
2067  (void) GetNextToken(q,&q,extent,token);
2068  if (LocaleCompare(keyword,"file") == 0)
2069  {
2070  if (depth > MagickMaxRecursionDepth)
2071  (void) ThrowMagickException(exception,GetMagickModule(),
2072  ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
2073  else
2074  {
2075  char
2076  path[MagickPathExtent],
2077  *file_xml;
2078 
2079  GetPathComponent(filename,HeadPath,path);
2080  if (*path != '\0')
2083  if (*token == *DirectorySeparator)
2084  (void) CopyMagickString(path,token,MagickPathExtent);
2085  else
2086  (void) ConcatenateMagickString(path,token,MagickPathExtent);
2087  file_xml=FileToXML(path,~0UL);
2088  if (file_xml != (char *) NULL)
2089  {
2090  status&=LoadColorCache(cache,file_xml,path,depth+1,
2091  exception);
2092  file_xml=DestroyString(file_xml);
2093  }
2094  }
2095  }
2096  }
2097  continue;
2098  }
2099  if (LocaleCompare(keyword,"<color") == 0)
2100  {
2101  /*
2102  Color element.
2103  */
2104  color_info=(ColorInfo *) AcquireCriticalMemory(sizeof(*color_info));
2105  (void) memset(color_info,0,sizeof(*color_info));
2106  color_info->path=ConstantString(filename);
2107  color_info->exempt=MagickFalse;
2108  color_info->signature=MagickCoreSignature;
2109  continue;
2110  }
2111  if (color_info == (ColorInfo *) NULL)
2112  continue;
2113  if ((LocaleCompare(keyword,"/>") == 0) ||
2114  (LocaleCompare(keyword,"</policy>") == 0))
2115  {
2116  status=AppendValueToLinkedList(cache,color_info);
2117  if (status == MagickFalse)
2118  (void) ThrowMagickException(exception,GetMagickModule(),
2119  ResourceLimitError,"MemoryAllocationFailed","`%s'",
2120  color_info->name);
2121  color_info=(ColorInfo *) NULL;
2122  continue;
2123  }
2124  (void) GetNextToken(q,(const char **) NULL,extent,token);
2125  if (*token != '=')
2126  continue;
2127  (void) GetNextToken(q,&q,extent,token);
2128  (void) GetNextToken(q,&q,extent,token);
2129  switch (*keyword)
2130  {
2131  case 'C':
2132  case 'c':
2133  {
2134  if (LocaleCompare((char *) keyword,"color") == 0)
2135  {
2136  (void) QueryColorCompliance(token,AllCompliance,&color_info->color,
2137  exception);
2138  break;
2139  }
2140  if (LocaleCompare((char *) keyword,"compliance") == 0)
2141  {
2142  ssize_t
2143  compliance;
2144 
2145  compliance=color_info->compliance;
2146  if (StringLocateSubstring(token,"SVG") != (char *) NULL)
2147  compliance|=SVGCompliance;
2148  if (StringLocateSubstring(token,"X11") != (char *) NULL)
2149  compliance|=X11Compliance;
2150  if (StringLocateSubstring(token,"XPM") != (char *) NULL)
2151  compliance|=XPMCompliance;
2152  color_info->compliance=(ComplianceType) compliance;
2153  break;
2154  }
2155  break;
2156  }
2157  case 'N':
2158  case 'n':
2159  {
2160  if (LocaleCompare((char *) keyword,"name") == 0)
2161  {
2162  color_info->name=ConstantString(token);
2163  break;
2164  }
2165  break;
2166  }
2167  case 'S':
2168  case 's':
2169  {
2170  if (LocaleCompare((char *) keyword,"stealth") == 0)
2171  {
2172  color_info->stealth=IsStringTrue(token);
2173  break;
2174  }
2175  break;
2176  }
2177  default:
2178  break;
2179  }
2180  }
2181  token=(char *) RelinquishMagickMemory(token);
2182  return(status != 0 ? MagickTrue : MagickFalse);
2183 }
2184 
2185 /*
2186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2187 % %
2188 % %
2189 % %
2190 + Q u e r y C o l o r C o m p l i a n c e %
2191 % %
2192 % %
2193 % %
2194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2195 %
2196 % QueryColorCompliance() returns the red, green, blue, and alpha intensities
2197 % for a given color name and standards compliance.
2198 %
2199 % The format of the QueryColorCompliance method is:
2200 %
2201 % MagickBooleanType QueryColorCompliance(const char *name,
2202 % const ComplianceType compliance,PixelInfo *color,
2203 % ExceptionInfo *exception)
2204 %
2205 % A description of each parameter follows:
2206 %
2207 % o name: the color name (e.g. white, blue, yellow).
2208 %
2209 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2210 %
2211 % o color: the red, green, blue, and opacity intensities values of the
2212 % named color in this structure.
2213 %
2214 % o exception: return any errors or warnings in this structure.
2215 %
2216 */
2218  const ComplianceType compliance,PixelInfo *color,ExceptionInfo *exception)
2219 {
2220  extern const char
2221  BackgroundColor[];
2222 
2223  GeometryInfo
2224  geometry_info;
2225 
2226  double
2227  scale;
2228 
2230  flags;
2231 
2232  register const ColorInfo
2233  *p;
2234 
2235  register ssize_t
2236  i;
2237 
2238  ssize_t
2239  type;
2240 
2241  /*
2242  Initialize color return value.
2243  */
2244  assert(name != (const char *) NULL);
2245  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
2246  assert(color != (PixelInfo *) NULL);
2247  if ((name == (char *) NULL) || (*name == '\0'))
2248  name=BackgroundColor;
2249  while (isspace((int) ((unsigned char) *name)) != 0)
2250  name++;
2251  GetPixelInfo((Image *) NULL,color);
2252  if (*name == '#')
2253  {
2254  char
2255  c;
2256 
2257  PixelPacket
2258  pixel;
2259 
2260  QuantumAny
2261  range;
2262 
2263  size_t
2264  depth,
2265  n;
2266 
2267  /*
2268  Parse hex color.
2269  */
2270  (void) memset(&pixel,0,sizeof(pixel));
2271  name++;
2272  for (n=0; isxdigit((int) ((unsigned char) name[n])) != 0; n++) ;
2273  if ((n == 3) || (n == 6) || (n == 9) || (n == 12) || (n == 24) ||
2274  (n == 48))
2275  {
2276  do
2277  {
2278  pixel.red=pixel.green;
2279  pixel.green=pixel.blue;
2280  pixel.blue=0;
2281  for (i=(ssize_t) (n/3-1); i >= 0; i--)
2282  {
2283  c=(*name++);
2284  pixel.blue<<=4;
2285  if ((c >= '0') && (c <= '9'))
2286  pixel.blue|=(int) (c-'0');
2287  else
2288  if ((c >= 'A') && (c <= 'F'))
2289  pixel.blue|=(int) c-((int) 'A'-10);
2290  else
2291  if ((c >= 'a') && (c <= 'f'))
2292  pixel.blue|=(int) c-((int) 'a'-10);
2293  else
2294  return(MagickFalse);
2295  }
2296  } while (isxdigit((int) ((unsigned char) *name)) != 0);
2297  depth=4*(n/3);
2298  }
2299  else
2300  {
2301  if ((n != 4) && (n != 8) && (n != 16) && (n != 32) && (n != 64))
2302  {
2303  (void) ThrowMagickException(exception,GetMagickModule(),
2304  OptionWarning,"UnrecognizedColor","`%s'",name);
2305  return(MagickFalse);
2306  }
2307  do
2308  {
2309  pixel.red=pixel.green;
2310  pixel.green=pixel.blue;
2311  pixel.blue=pixel.alpha;
2312  pixel.alpha=0;
2313  for (i=(ssize_t) (n/4-1); i >= 0; i--)
2314  {
2315  c=(*name++);
2316  pixel.alpha<<=4;
2317  if ((c >= '0') && (c <= '9'))
2318  pixel.alpha|=(int) (c-'0');
2319  else
2320  if ((c >= 'A') && (c <= 'F'))
2321  pixel.alpha|=(int) c-((int) 'A'-10);
2322  else
2323  if ((c >= 'a') && (c <= 'f'))
2324  pixel.alpha|=(int) c-((int) 'a'-10);
2325  else
2326  return(MagickFalse);
2327  }
2328  } while (isxdigit((int) ((unsigned char) *name)) != 0);
2329  depth=4*(n/4);
2330  }
2331  color->colorspace=sRGBColorspace;
2332  color->depth=depth;
2334  range=GetQuantumRange(depth);
2335  color->red=(double) ScaleAnyToQuantum(pixel.red,range);
2336  color->green=(double) ScaleAnyToQuantum(pixel.green,range);
2337  color->blue=(double) ScaleAnyToQuantum(pixel.blue,range);
2338  color->alpha=(double) OpaqueAlpha;
2339  if ((n % 3) != 0)
2340  {
2342  color->alpha=(double) ScaleAnyToQuantum(pixel.alpha,range);
2343  }
2344  color->black=0.0;
2345  return(MagickTrue);
2346  }
2347  if (strchr(name,'(') != (char *) NULL)
2348  {
2349  char
2350  colorspace[2*MagickPathExtent];
2351 
2353  icc_color;
2354 
2355  /*
2356  Parse color of the form rgb(100,255,0).
2357  */
2358  (void) memset(colorspace,0,sizeof(colorspace));
2359  (void) CopyMagickString(colorspace,name,MagickPathExtent);
2360  for (i=0; colorspace[i] != '\0'; i++)
2361  if (colorspace[i] == '(')
2362  break;
2363  colorspace[i--]='\0';
2364  scale=(double) ScaleCharToQuantum(1);
2365  icc_color=MagickFalse;
2366  if (LocaleNCompare(colorspace,"device-",7) == 0)
2367  {
2368  (void) CopyMagickString(colorspace,colorspace+7,MagickPathExtent);
2369  scale=(double) QuantumRange;
2370  icc_color=MagickTrue;
2371  }
2372  if (LocaleCompare(colorspace,"icc-color") == 0)
2373  {
2374  register ssize_t
2375  j;
2376 
2377  (void) CopyMagickString(colorspace,name+i+2,MagickPathExtent);
2378  for (j=0; colorspace[j] != '\0'; j++)
2379  if (colorspace[j] == ',')
2380  break;
2381  colorspace[j--]='\0';
2382  i+=j+3;
2383  scale=(double) QuantumRange;
2384  icc_color=MagickTrue;
2385  }
2386  LocaleLower(colorspace);
2388  if ((i > 0) && (colorspace[i] == 'a'))
2389  {
2390  colorspace[i]='\0';
2392  }
2394  if (type < 0)
2395  {
2396  (void) ThrowMagickException(exception,GetMagickModule(),
2397  OptionWarning,"UnrecognizedColor","`%s'",name);
2398  return(MagickFalse);
2399  }
2400  color->colorspace=(ColorspaceType) type;
2401  if ((icc_color == MagickFalse) && (color->colorspace == RGBColorspace))
2402  {
2403  color->colorspace=sRGBColorspace; /* as required by SVG standard */
2404  color->depth=8;
2405  }
2406  SetGeometryInfo(&geometry_info);
2407  if (i >= (ssize_t) strlen(name))
2408  flags=ParseGeometry(name,&geometry_info);
2409  else
2410  flags=ParseGeometry(name+i+1,&geometry_info);
2411  if (flags == 0)
2412  {
2413  char
2414  *colorname;
2415 
2417  colorspaceType;
2418 
2420  status;
2421 
2422  colorspaceType=color->colorspace;
2423  if (i >= (ssize_t) strlen(name))
2424  colorname=AcquireString(name);
2425  else
2426  colorname=AcquireString(name+i+1);
2427  (void) SubstituteString(&colorname,"(","");
2428  (void) SubstituteString(&colorname,")","");
2429  status=MagickFalse;
2430  if (LocaleCompare(name,colorname) != 0)
2431  status=QueryColorCompliance(colorname,AllCompliance,color,
2432  exception);
2433  color->colorspace=colorspaceType;
2434  if (*colorname == '\0')
2435  {
2436  (void) ThrowMagickException(exception,GetMagickModule(),
2437  OptionWarning,"UnrecognizedColor","`%s'",name);
2438  status=MagickFalse;
2439  }
2440  colorname=DestroyString(colorname);
2441  return(status);
2442  }
2443  if ((flags & PercentValue) != 0)
2444  scale=(double) (QuantumRange/100.0);
2445  if ((flags & RhoValue) != 0)
2446  color->red=(double) ClampToQuantum((MagickRealType) (scale*
2447  geometry_info.rho));
2448  if ((flags & SigmaValue) != 0)
2449  color->green=(double) ClampToQuantum((MagickRealType) (scale*
2450  geometry_info.sigma));
2451  if ((flags & XiValue) != 0)
2452  color->blue=(double) ClampToQuantum((MagickRealType) (scale*
2453  geometry_info.xi));
2454  color->alpha=(double) OpaqueAlpha;
2455  if ((flags & PsiValue) != 0)
2456  {
2457  if (color->colorspace == CMYKColorspace)
2458  color->black=(double) ClampToQuantum((MagickRealType) (scale*
2459  geometry_info.psi));
2460  else
2461  if (color->alpha_trait != UndefinedPixelTrait)
2462  color->alpha=(double) ClampToQuantum(QuantumRange*
2463  geometry_info.psi);
2464  }
2465  if (((flags & ChiValue) != 0) &&
2466  (color->alpha_trait != UndefinedPixelTrait))
2467  color->alpha=(double) ClampToQuantum(QuantumRange*geometry_info.chi);
2468  if (color->colorspace == LabColorspace)
2469  {
2470  if ((flags & SigmaValue) != 0)
2472  (scale*geometry_info.sigma+(QuantumRange+1)/2.0));
2473  if ((flags & XiValue) != 0)
2475  (scale*geometry_info.xi+(QuantumRange+1)/2.0));
2476  }
2477  if ((LocaleCompare(colorspace,"gray") == 0) ||
2478  (LocaleCompare(colorspace,"lineargray") == 0))
2479  {
2480  color->green=color->red;
2481  color->blue=color->red;
2482  if (((flags & SigmaValue) != 0) &&
2483  (color->alpha_trait != UndefinedPixelTrait))
2484  color->alpha=(double) ClampToQuantum(QuantumRange*
2485  geometry_info.sigma);
2486  }
2487  if ((LocaleCompare(colorspace,"HCL") == 0) ||
2488  (LocaleCompare(colorspace,"HSB") == 0) ||
2489  (LocaleCompare(colorspace,"HSL") == 0) ||
2490  (LocaleCompare(colorspace,"HWB") == 0))
2491  {
2492  double
2493  blue,
2494  green,
2495  red;
2496 
2497  if (LocaleCompare(colorspace,"HCL") == 0)
2498  color->colorspace=HCLColorspace;
2499  else
2500  if (LocaleCompare(colorspace,"HSB") == 0)
2501  color->colorspace=HSBColorspace;
2502  else
2503  if (LocaleCompare(colorspace,"HSL") == 0)
2504  color->colorspace=HSLColorspace;
2505  else
2506  if (LocaleCompare(colorspace,"HWB") == 0)
2507  color->colorspace=HWBColorspace;
2508  scale=1.0/255.0;
2509  if ((flags & PercentValue) != 0)
2510  scale=1.0/100.0;
2511  geometry_info.sigma*=scale;
2512  geometry_info.xi*=scale;
2513  if (LocaleCompare(colorspace,"HCL") == 0)
2514  ConvertHCLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2515  360.0,geometry_info.sigma,geometry_info.xi,&red,&green,&blue);
2516  else
2517  if (LocaleCompare(colorspace,"HSB") == 0)
2518  ConvertHSBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2519  360.0,geometry_info.sigma,geometry_info.xi,&red,&green,&blue);
2520  else
2521  if (LocaleCompare(colorspace,"HSL") == 0)
2522  ConvertHSLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2523  360.0,geometry_info.sigma,geometry_info.xi,&red,&green,&blue);
2524  else
2525  ConvertHWBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2526  360.0,geometry_info.sigma,geometry_info.xi,&red,&green,&blue);
2527  color->colorspace=sRGBColorspace;
2528  color->red=(MagickRealType) red;
2529  color->green=(MagickRealType) green;
2530  color->blue=(MagickRealType) blue;
2531  }
2532  return(MagickTrue);
2533  }
2534  /*
2535  Parse named color.
2536  */
2537  p=GetColorCompliance(name,compliance,exception);
2538  if (p == (const ColorInfo *) NULL)
2539  return(MagickFalse);
2540  color->colorspace=sRGBColorspace;
2541  if ((LocaleNCompare(name,"gray",4) == 0) ||
2542  (LocaleNCompare(name,"grey",4) == 0))
2543  color->colorspace=GRAYColorspace;
2544  color->depth=8;
2547  color->red=(double) p->color.red;
2548  color->green=(double) p->color.green;
2549  color->blue=(double) p->color.blue;
2550  color->alpha=(double) p->color.alpha;
2551  color->black=0.0;
2552  return(MagickTrue);
2553 }
2554 
2555 /*
2556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2557 % %
2558 % %
2559 % %
2560 % Q u e r y C o l o r n a m e %
2561 % %
2562 % %
2563 % %
2564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2565 %
2566 % QueryColorname() returns a named color for the given color intensity.
2567 % If an exact match is not found, a hex value is returned instead. For
2568 % example an intensity of rgb:(0,0,0) returns black whereas rgb:(223,223,223)
2569 % returns #dfdfdf.
2570 %
2571 % UPDATE: the 'image' argument is no longer needed as all information should
2572 % have been preset using GetPixelInfo().
2573 %
2574 % The format of the QueryColorname method is:
2575 %
2576 % MagickBooleanType QueryColorname(const Image *image,
2577 % const PixelInfo *color,const ComplianceType compliance,char *name,
2578 % ExceptionInfo *exception)
2579 %
2580 % A description of each parameter follows.
2581 %
2582 % o image: the image. (not used! - color gets settings from GetPixelInfo()
2583 %
2584 % o color: the color intensities.
2585 %
2586 % o Compliance: Adhere to this color standard: SVG, X11, or XPM.
2587 %
2588 % o name: Return the color name or hex value.
2589 %
2590 % o exception: return any errors or warnings in this structure.
2591 %
2592 */
2593 
2595  const Image *magick_unused(image),const PixelInfo *color,
2596  const ComplianceType compliance,char *name,ExceptionInfo *exception)
2597 {
2598  PixelInfo
2599  pixel;
2600 
2601  double
2602  alpha;
2603 
2604  register const ColorInfo
2605  *p;
2606 
2607  magick_unreferenced(image);
2608  *name='\0';
2609  pixel=(*color);
2610  if (compliance == XPMCompliance)
2611  {
2613  if ( pixel.depth > 16 )
2614  pixel.depth=16;
2615  }
2616  GetColorTuple(&pixel,compliance != SVGCompliance ? MagickTrue : MagickFalse,
2617  name);
2618  if (IssRGBColorspace(pixel.colorspace) == MagickFalse)
2619  return(MagickFalse);
2620  alpha=color->alpha_trait != UndefinedPixelTrait ? color->alpha : OpaqueAlpha;
2621  (void) GetColorInfo("*",exception);
2624  while (p != (const ColorInfo *) NULL)
2625  {
2626  if (((p->compliance & compliance) != 0) &&
2627  ((fabs((double) (p->color.red-color->red)) < MagickEpsilon)) &&
2628  (fabs((double) (p->color.green-color->green)) < MagickEpsilon) &&
2629  (fabs((double) (p->color.blue-color->blue)) < MagickEpsilon) &&
2630  (fabs((double) (p->color.alpha-alpha)) < MagickEpsilon))
2631  {
2632  (void) CopyMagickString(name,p->name,MagickPathExtent);
2633  break;
2634  }
2636  }
2637  return(MagickTrue);
2638 }
double psi
Definition: geometry.h:106
size_t rows
Definition: image.h:172
MagickDoubleType MagickRealType
Definition: magick-type.h:120
MagickExport CacheView * DestroyCacheView(CacheView *cache_view)
Definition: cache-view.c:252
MagickExport const ColorInfo ** GetColorInfoList(const char *pattern, size_t *number_colors, ExceptionInfo *exception)
Definition: color.c:1298
#define MagickSQ1_2
Definition: image-private.h:32
MagickExport const char BackgroundColor[]
Definition: image.c:111
MagickExport MagickBooleanType QueryColorname(const Image *magick_unused(image), const PixelInfo *color, const ComplianceType compliance, char *name, ExceptionInfo *exception)
Definition: color.c:2594
static MagickSizeType GetQuantumRange(const size_t depth)
#define MagickMaxRecursionDepth
Definition: studio.h:344
MagickProgressMonitor progress_monitor
Definition: image.h:303
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:426
unsigned int green
Definition: pixel.h:201
PixelTrait alpha_trait
Definition: pixel.h:178
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:450
static const ColormapInfo Colormap[]
Definition: color.c:105
MagickExport void ResetLinkedListIterator(LinkedListInfo *list_info)
Definition: linked-list.c:959
MagickPrivate MagickBooleanType ColorComponentGenesis(void)
MagickExport ssize_t ParseCommandOption(const CommandOption option, const MagickBooleanType list, const char *options)
Definition: option.c:2972
MagickPrivate MagickBooleanType IsEquivalentAlpha(const Image *, const PixelInfo *, const PixelInfo *)
MagickExport MagickBooleanType ListColorInfo(FILE *file, ExceptionInfo *exception)
Definition: color.c:1909
struct _ColormapInfo ColormapInfo
ComplianceType compliance
Definition: color.h:47
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
Definition: linked-list.c:219
double rho
Definition: geometry.h:106
MagickExport void SetGeometryInfo(GeometryInfo *geometry_info)
Definition: geometry.c:1721
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition: semaphore.c:192
MagickExport MagickBooleanType InsertValueInLinkedList(LinkedListInfo *list_info, const size_t index, const void *value)
Definition: linked-list.c:447
#define OpaqueAlpha
Definition: image.h:25
static MagickBooleanType IsColorCacheInstantiated(ExceptionInfo *)
Definition: color.c:1642
const unsigned char red
Definition: color.c:90
MagickRealType red
Definition: pixel.h:190
static LinkedListInfo * color_cache
Definition: color.c:791
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
Definition: linked-list.c:111
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:499
static void * AcquireCriticalMemory(const size_t size)
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
Definition: string.c:755
MagickExport void * RemoveElementByValueFromLinkedList(LinkedListInfo *list_info, const void *value)
Definition: linked-list.c:756
unsigned int blue
Definition: pixel.h:201
MagickExport const Quantum * GetCacheViewVirtualPixels(const CacheView *cache_view, const ssize_t x, const ssize_t y, const size_t columns, const size_t rows, ExceptionInfo *exception)
Definition: cache-view.c:651
MagickRealType alpha
Definition: pixel.h:190
MagickBooleanType exempt
Definition: color.h:53
#define MagickEpsilon
Definition: magick-type.h:110
double sigma
Definition: geometry.h:106
Definition: log.h:52
ssize_t MagickOffsetType
Definition: magick-type.h:129
static Quantum ClampToQuantum(const MagickRealType quantum)
Definition: quantum.h:85
MagickExport void GetPixelInfo(const Image *image, PixelInfo *pixel)
Definition: pixel.c:2170
Definition: image.h:151
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
Definition: linked-list.c:305
static SemaphoreInfo * color_semaphore
Definition: color.c:794
#define MagickCoreSignature
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition: semaphore.c:293
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1215
char * path
Definition: color.h:43
MagickExport const ColorInfo * GetColorInfo(const char *name, ExceptionInfo *exception)
Definition: color.c:1089
MagickExport LinkedListInfo * GetConfigureOptions(const char *filename, ExceptionInfo *exception)
Definition: configure.c:639
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1213
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
Definition: locale.c:404
MagickBooleanType
Definition: magick-type.h:158
MagickExport const ColorInfo * GetColorCompliance(const char *name, const ComplianceType compliance, ExceptionInfo *exception)
Definition: color.c:1004
#define DirectorySeparator
Definition: studio.h:259
unsigned int MagickStatusType
Definition: magick-type.h:121
MagickExport char * AcquireString(const char *source)
Definition: string.c:129
char * name
Definition: color.h:43
MagickExport void LocaleLower(char *string)
Definition: locale.c:1490
#define ColorFilename
Definition: color.c:79
static Quantum ScaleAnyToQuantum(const QuantumAny quantum, const QuantumAny range)
MagickExport MagickBooleanType GlobExpression(const char *magick_restrict expression, const char *magick_restrict pattern, const MagickBooleanType case_insensitive)
Definition: token.c:355
MagickExport const char * CommandOptionToMnemonic(const CommandOption option, const ssize_t type)
Definition: option.c:2681
PixelInfo color
Definition: color.h:50
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:553
MagickExport void GetColorTuple(const PixelInfo *pixel, const MagickBooleanType hex, char *tuple)
Definition: color.c:1557
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition: locale.c:1570
MagickExport magick_hot_spot size_t GetNextToken(const char *magick_restrict start, const char **magick_restrict end, const size_t extent, char *magick_restrict token)
Definition: token.c:174
MagickExport MagickBooleanType IsEquivalentImage(const Image *image, const Image *target_image, ssize_t *x_offset, ssize_t *y_offset, ExceptionInfo *exception)
Definition: color.c:1743
#define magick_unused(x)
MagickPrivate void ColorComponentTerminus(void)
Definition: color.c:965
#define MagickPathExtent
MagickExport MagickBooleanType IsStringTrue(const char *value)
Definition: string.c:1425
static void GetPixelInfoPixel(const Image *magick_restrict image, const Quantum *magick_restrict pixel, PixelInfo *magick_restrict pixel_info)
PixelTrait alpha_trait
Definition: image.h:280
MagickExport int GetMagickPrecision(void)
Definition: magick.c:945
const float alpha
Definition: color.c:95
MagickRealType blue
Definition: pixel.h:190
static int ColorInfoCompare(const void *x, const void *y)
Definition: color.c:1277
#define SearchImageText
MagickExport MagickRealType GetPixelInfoIntensity(const Image *magick_restrict image, const PixelInfo *magick_restrict pixel)
Definition: pixel.c:2224
static MagickBooleanType IssRGBColorspace(const ColorspaceType colorspace)
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1145
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1413
const char name[21]
Definition: color.c:87
size_t signature
Definition: image.h:354
size_t columns
Definition: image.h:172
#define QuantumScale
Definition: magick-type.h:115
MagickExport MagickBooleanType SubstituteString(char **string, const char *search, const char *replace)
Definition: string.c:2575
unsigned int alpha
Definition: pixel.h:201
MagickPrivate MagickBooleanType IsEquivalentIntensity(const Image *, const PixelInfo *, const PixelInfo *)
Definition: color.c:1862
MagickExport LinkedListInfo * NewLinkedList(const size_t capacity)
Definition: linked-list.c:713
MagickExport MagickBooleanType QueryColorCompliance(const char *name, const ComplianceType compliance, PixelInfo *color, ExceptionInfo *exception)
Definition: color.c:2217
const ssize_t compliance
Definition: color.c:98
MagickExport void ConcatenateColorComponent(const PixelInfo *pixel, const PixelChannel channel, const ComplianceType compliance, char *tuple)
Definition: color.c:1125
MagickExport void ConvertHSLToRGB(const double hue, const double saturation, const double lightness, double *red, double *green, double *blue)
Definition: gem.c:462
PixelChannel
Definition: pixel.h:67
#define MagickMax(x, y)
Definition: image-private.h:26
size_t depth
Definition: pixel.h:184
static MagickBooleanType IsSVGCompliant(const PixelInfo *pixel)
Definition: color.c:1466
MagickPrivate void ConvertHWBToRGB(const double, const double, const double, double *, double *, double *)
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1435
char filename[MagickPathExtent]
Definition: image.h:319
static void ConcatentateHexColorComponent(const PixelInfo *pixel, const PixelChannel channel, char *tuple)
Definition: color.c:1489
#define GetMagickModule()
Definition: log.h:28
double chi
Definition: geometry.h:106
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
Definition: string.c:1302
MagickExport CacheView * AcquireVirtualCacheView(const Image *image, ExceptionInfo *exception)
Definition: cache-view.c:149
static int ColorCompare(const void *x, const void *y)
Definition: color.c:1376
unsigned short Quantum
Definition: magick-type.h:82
unsigned int red
Definition: pixel.h:201
double xi
Definition: geometry.h:106
MagickRealType black
Definition: pixel.h:190
MagickExport char * DestroyString(char *string)
Definition: string.c:823
MagickExport void * AcquireMagickMemory(const size_t size)
Definition: memory.c:482
static LinkedListInfo * AcquireColorCache(const char *filename, ExceptionInfo *exception)
Definition: color.c:830
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:97
MagickExport MagickBooleanType IsFuzzyEquivalencePixelInfo(const PixelInfo *p, const PixelInfo *q)
Definition: pixel.c:6065
MagickExport size_t GetNumberOfElementsInLinkedList(const LinkedListInfo *list_info)
Definition: linked-list.c:348
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:853
const unsigned char blue
Definition: color.c:90
ColorspaceType
Definition: colorspace.h:25
MagickPrivate void ConvertHCLToRGB(const double, const double, const double, double *, double *, double *)
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1084
#define magick_unreferenced(x)
MagickRealType green
Definition: pixel.h:190
static MagickBooleanType LoadColorCache(LinkedListInfo *, const char *, const char *, const size_t, ExceptionInfo *)
Definition: color.c:1999
MagickBooleanType(* MagickProgressMonitor)(const char *, const MagickOffsetType, const MagickSizeType, void *)
Definition: monitor.h:26
MagickExport char ** GetColorList(const char *pattern, size_t *number_colors, ExceptionInfo *exception)
Definition: color.c:1391
#define MagickPrivate
static void * DestroyColorElement(void *color_info)
Definition: color.c:948
MagickPrivate char * FileToXML(const char *, const size_t)
Definition: xml-tree.c:599
#define MagickExport
size_t signature
Definition: color.h:57
double fuzz
Definition: image.h:216
MagickPrivate void ConvertHSBToRGB(const double, const double, const double, double *, double *, double *)
ColorspaceType colorspace
Definition: pixel.h:175
#define SVGCompliant(component)
MagickBooleanType stealth
Definition: color.h:53
static char * StringLocateSubstring(const char *haystack, const char *needle)
ComplianceType
Definition: color.h:28
const unsigned char green
Definition: color.c:90
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition: semaphore.c:351
MagickExport LinkedListInfo * DestroyConfigureOptions(LinkedListInfo *options)
Definition: configure.c:311
MagickSizeType QuantumAny
Definition: magick-type.h:144
MagickExport char * ConstantString(const char *source)
Definition: string.c:700
#define QuantumRange
Definition: magick-type.h:83
MagickExport MagickBooleanType SetImageProgress(const Image *image, const char *tag, const MagickOffsetType offset, const MagickSizeType extent)
Definition: monitor.c:136
MagickBooleanType debug
Definition: image.h:334