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