2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 % CCCC OOO L OOO RRRR %
9 % CCCC OOO LLLLL OOO R R %
12 % MagickCore Color Methods %
19 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
20 % dedicated to making software imaging solutions freely available. %
22 % You may not use this file except in compliance with the License. You may %
23 % obtain a copy of the License at %
25 % http://www.imagemagick.org/script/license.php %
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. %
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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).
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"
48 #include "MagickCore/color-private.h"
49 #include "MagickCore/client.h"
50 #include "MagickCore/configure.h"
51 #include "MagickCore/exception.h"
52 #include "MagickCore/exception-private.h"
53 #include "MagickCore/gem.h"
54 #include "MagickCore/geometry.h"
55 #include "MagickCore/image-private.h"
56 #include "MagickCore/memory_.h"
57 #include "MagickCore/monitor.h"
58 #include "MagickCore/monitor-private.h"
59 #include "MagickCore/option.h"
60 #include "MagickCore/pixel-accessor.h"
61 #include "MagickCore/quantize.h"
62 #include "MagickCore/quantum.h"
63 #include "MagickCore/quantum-private.h"
64 #include "MagickCore/semaphore.h"
65 #include "MagickCore/string_.h"
66 #include "MagickCore/token.h"
67 #include "MagickCore/utility.h"
68 #include "MagickCore/xml-tree.h"
73 #define ColorFilename "colors.xml"
78 typedef struct _ColorMapInfo
98 static const ColorMapInfo
101 { "none", 0, 0, 0, 0, SVGCompliance | XPMCompliance },
102 { "black", 0, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
103 { "red", 255, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
104 { "magenta", 255, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
105 { "green", 0, 128, 0, 1, SVGCompliance },
106 { "cyan", 0, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
107 { "blue", 0, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
108 { "yellow", 255, 255, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
109 { "white", 255, 255, 255, 1, SVGCompliance | X11Compliance },
110 { "AliceBlue", 240, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
111 { "AntiqueWhite", 250, 235, 215, 1, SVGCompliance | X11Compliance | XPMCompliance },
112 { "AntiqueWhite1", 255, 239, 219, 1, X11Compliance },
113 { "AntiqueWhite2", 238, 223, 204, 1, X11Compliance },
114 { "AntiqueWhite3", 205, 192, 176, 1, X11Compliance },
115 { "AntiqueWhite4", 139, 131, 120, 1, X11Compliance },
116 { "aqua", 0, 255, 255, 1, SVGCompliance },
117 { "aquamarine", 127, 255, 212, 1, SVGCompliance | X11Compliance | XPMCompliance },
118 { "aquamarine1", 127, 255, 212, 1, X11Compliance },
119 { "aquamarine2", 118, 238, 198, 1, X11Compliance },
120 { "aquamarine3", 102, 205, 170, 1, X11Compliance },
121 { "aquamarine4", 69, 139, 116, 1, X11Compliance },
122 { "azure", 240, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
123 { "azure1", 240, 255, 255, 1, X11Compliance },
124 { "azure2", 224, 238, 238, 1, X11Compliance },
125 { "azure3", 193, 205, 205, 1, X11Compliance },
126 { "azure4", 131, 139, 139, 1, X11Compliance },
127 { "beige", 245, 245, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
128 { "bisque", 255, 228, 196, 1, SVGCompliance | X11Compliance | XPMCompliance },
129 { "bisque1", 255, 228, 196, 1, X11Compliance },
130 { "bisque2", 238, 213, 183, 1, X11Compliance },
131 { "bisque3", 205, 183, 158, 1, X11Compliance },
132 { "bisque4", 139, 125, 107, 1, X11Compliance },
133 { "BlanchedAlmond", 255, 235, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
134 { "blue1", 0, 0, 255, 1, X11Compliance },
135 { "blue2", 0, 0, 238, 1, X11Compliance },
136 { "blue3", 0, 0, 205, 1, X11Compliance },
137 { "blue4", 0, 0, 139, 1, X11Compliance },
138 { "BlueViolet", 138, 43, 226, 1, SVGCompliance | X11Compliance | XPMCompliance },
139 { "brown", 165, 42, 42, 1, SVGCompliance | X11Compliance | XPMCompliance },
140 { "brown1", 255, 64, 64, 1, X11Compliance },
141 { "brown2", 238, 59, 59, 1, X11Compliance },
142 { "brown3", 205, 51, 51, 1, X11Compliance },
143 { "brown4", 139, 35, 35, 1, X11Compliance },
144 { "burlywood", 222, 184, 135, 1, SVGCompliance | X11Compliance | XPMCompliance },
145 { "burlywood1", 255, 211, 155, 1, X11Compliance },
146 { "burlywood2", 238, 197, 145, 1, X11Compliance },
147 { "burlywood3", 205, 170, 125, 1, X11Compliance },
148 { "burlywood4", 139, 115, 85, 1, X11Compliance },
149 { "CadetBlue", 95, 158, 160, 1, SVGCompliance | X11Compliance | XPMCompliance },
150 { "CadetBlue1", 152, 245, 255, 1, X11Compliance },
151 { "CadetBlue2", 142, 229, 238, 1, X11Compliance },
152 { "CadetBlue3", 122, 197, 205, 1, X11Compliance },
153 { "CadetBlue4", 83, 134, 139, 1, X11Compliance },
154 { "chartreuse", 127, 255, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
155 { "chartreuse1", 127, 255, 0, 1, X11Compliance },
156 { "chartreuse2", 118, 238, 0, 1, X11Compliance },
157 { "chartreuse3", 102, 205, 0, 1, X11Compliance },
158 { "chartreuse4", 69, 139, 0, 1, X11Compliance },
159 { "chocolate", 210, 105, 30, 1, SVGCompliance | X11Compliance | XPMCompliance },
160 { "chocolate1", 255, 127, 36, 1, X11Compliance },
161 { "chocolate2", 238, 118, 33, 1, X11Compliance },
162 { "chocolate3", 205, 102, 29, 1, X11Compliance },
163 { "chocolate4", 139, 69, 19, 1, X11Compliance },
164 { "coral", 255, 127, 80, 1, SVGCompliance | X11Compliance | XPMCompliance },
165 { "coral1", 255, 114, 86, 1, X11Compliance },
166 { "coral2", 238, 106, 80, 1, X11Compliance },
167 { "coral3", 205, 91, 69, 1, X11Compliance },
168 { "coral4", 139, 62, 47, 1, X11Compliance },
169 { "CornflowerBlue", 100, 149, 237, 1, SVGCompliance | X11Compliance | XPMCompliance },
170 { "cornsilk", 255, 248, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
171 { "cornsilk1", 255, 248, 220, 1, X11Compliance },
172 { "cornsilk2", 238, 232, 205, 1, X11Compliance },
173 { "cornsilk3", 205, 200, 177, 1, X11Compliance },
174 { "cornsilk4", 139, 136, 120, 1, X11Compliance },
175 { "crimson", 220, 20, 60, 1, SVGCompliance },
176 { "cyan1", 0, 255, 255, 1, X11Compliance },
177 { "cyan2", 0, 238, 238, 1, X11Compliance },
178 { "cyan3", 0, 205, 205, 1, X11Compliance },
179 { "cyan4", 0, 139, 139, 1, X11Compliance },
180 { "DarkBlue", 0, 0, 139, 1, SVGCompliance | X11Compliance },
181 { "DarkCyan", 0, 139, 139, 1, SVGCompliance | X11Compliance },
182 { "DarkGoldenrod", 184, 134, 11, 1, SVGCompliance | X11Compliance | XPMCompliance },
183 { "DarkGoldenrod1", 255, 185, 15, 1, X11Compliance },
184 { "DarkGoldenrod2", 238, 173, 14, 1, X11Compliance },
185 { "DarkGoldenrod3", 205, 149, 12, 1, X11Compliance },
186 { "DarkGoldenrod4", 139, 101, 8, 1, X11Compliance },
187 { "DarkGray", 169, 169, 169, 1, SVGCompliance | X11Compliance },
188 { "DarkGreen", 0, 100, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
189 { "DarkGrey", 169, 169, 169, 1, SVGCompliance | X11Compliance },
190 { "DarkKhaki", 189, 183, 107, 1, SVGCompliance | X11Compliance | XPMCompliance },
191 { "DarkMagenta", 139, 0, 139, 1, SVGCompliance | X11Compliance },
192 { "DarkOliveGreen", 85, 107, 47, 1, SVGCompliance | X11Compliance | XPMCompliance },
193 { "DarkOliveGreen1", 202, 255, 112, 1, X11Compliance },
194 { "DarkOliveGreen2", 188, 238, 104, 1, X11Compliance },
195 { "DarkOliveGreen3", 162, 205, 90, 1, X11Compliance },
196 { "DarkOliveGreen4", 110, 139, 61, 1, X11Compliance },
197 { "DarkOrange", 255, 140, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
198 { "DarkOrange1", 255, 127, 0, 1, X11Compliance },
199 { "DarkOrange2", 238, 118, 0, 1, X11Compliance },
200 { "DarkOrange3", 205, 102, 0, 1, X11Compliance },
201 { "DarkOrange4", 139, 69, 0, 1, X11Compliance },
202 { "DarkOrchid", 153, 50, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
203 { "DarkOrchid1", 191, 62, 255, 1, X11Compliance },
204 { "DarkOrchid2", 178, 58, 238, 1, X11Compliance },
205 { "DarkOrchid3", 154, 50, 205, 1, X11Compliance },
206 { "DarkOrchid4", 104, 34, 139, 1, X11Compliance },
207 { "DarkRed", 139, 0, 0, 1, SVGCompliance | X11Compliance },
208 { "DarkSalmon", 233, 150, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
209 { "DarkSeaGreen", 143, 188, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
210 { "DarkSeaGreen1", 193, 255, 193, 1, X11Compliance },
211 { "DarkSeaGreen2", 180, 238, 180, 1, X11Compliance },
212 { "DarkSeaGreen3", 155, 205, 155, 1, X11Compliance },
213 { "DarkSeaGreen4", 105, 139, 105, 1, X11Compliance },
214 { "DarkSlateBlue", 72, 61, 139, 1, SVGCompliance | X11Compliance | XPMCompliance },
215 { "DarkSlateGray", 47, 79, 79, 1, SVGCompliance | X11Compliance | XPMCompliance },
216 { "DarkSlateGray1", 151, 255, 255, 1, X11Compliance },
217 { "DarkSlateGray2", 141, 238, 238, 1, X11Compliance },
218 { "DarkSlateGray3", 121, 205, 205, 1, X11Compliance },
219 { "DarkSlateGray4", 82, 139, 139, 1, X11Compliance },
220 { "DarkSlateGrey", 47, 79, 79, 1, SVGCompliance | X11Compliance },
221 { "DarkTurquoise", 0, 206, 209, 1, SVGCompliance | X11Compliance | XPMCompliance },
222 { "DarkViolet", 148, 0, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
223 { "DeepPink", 255, 20, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
224 { "DeepPink1", 255, 20, 147, 1, X11Compliance },
225 { "DeepPink2", 238, 18, 137, 1, X11Compliance },
226 { "DeepPink3", 205, 16, 118, 1, X11Compliance },
227 { "DeepPink4", 139, 10, 80, 1, X11Compliance },
228 { "DeepSkyBlue", 0, 191, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
229 { "DeepSkyBlue1", 0, 191, 255, 1, X11Compliance },
230 { "DeepSkyBlue2", 0, 178, 238, 1, X11Compliance },
231 { "DeepSkyBlue3", 0, 154, 205, 1, X11Compliance },
232 { "DeepSkyBlue4", 0, 104, 139, 1, X11Compliance },
233 { "DimGray", 105, 105, 105, 1, SVGCompliance | X11Compliance | XPMCompliance },
234 { "DimGrey", 105, 105, 105, 1, SVGCompliance | X11Compliance },
235 { "DodgerBlue", 30, 144, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
236 { "DodgerBlue1", 30, 144, 255, 1, X11Compliance },
237 { "DodgerBlue2", 28, 134, 238, 1, X11Compliance },
238 { "DodgerBlue3", 24, 116, 205, 1, X11Compliance },
239 { "DodgerBlue4", 16, 78, 139, 1, X11Compliance },
240 { "firebrick", 178, 34, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
241 { "firebrick1", 255, 48, 48, 1, X11Compliance },
242 { "firebrick2", 238, 44, 44, 1, X11Compliance },
243 { "firebrick3", 205, 38, 38, 1, X11Compliance },
244 { "firebrick4", 139, 26, 26, 1, X11Compliance },
245 { "FloralWhite", 255, 250, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
246 { "ForestGreen", 34, 139, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
247 { "fractal", 128, 128, 128, 1, SVGCompliance },
248 { "freeze", 0, 0, 0, 0, SVGCompliance },
249 { "fuchsia", 255, 0, 255, 1, SVGCompliance },
250 { "gainsboro", 220, 220, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
251 { "GhostWhite", 248, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
252 { "gold", 255, 215, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
253 { "gold1", 255, 215, 0, 1, X11Compliance },
254 { "gold2", 238, 201, 0, 1, X11Compliance },
255 { "gold3", 205, 173, 0, 1, X11Compliance },
256 { "gold4", 139, 117, 0, 1, X11Compliance },
257 { "goldenrod", 218, 165, 32, 1, SVGCompliance | X11Compliance | XPMCompliance },
258 { "goldenrod1", 255, 193, 37, 1, X11Compliance },
259 { "goldenrod2", 238, 180, 34, 1, X11Compliance },
260 { "goldenrod3", 205, 155, 29, 1, X11Compliance },
261 { "goldenrod4", 139, 105, 20, 1, X11Compliance },
262 { "gray", 126, 126, 126, 1, SVGCompliance },
263 { "gray", 190, 190, 190, 1, X11Compliance | XPMCompliance },
264 { "gray0", 0, 0, 0, 1, X11Compliance | XPMCompliance },
265 { "gray1", 3, 3, 3, 1, X11Compliance | XPMCompliance },
266 { "gray10", 26, 26, 26, 1, X11Compliance | XPMCompliance },
267 { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
268 { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
269 { "gray11", 28, 28, 28, 1, X11Compliance | XPMCompliance },
270 { "gray12", 31, 31, 31, 1, X11Compliance | XPMCompliance },
271 { "gray13", 33, 33, 33, 1, X11Compliance | XPMCompliance },
272 { "gray14", 36, 36, 36, 1, X11Compliance | XPMCompliance },
273 { "gray15", 38, 38, 38, 1, X11Compliance | XPMCompliance },
274 { "gray16", 41, 41, 41, 1, X11Compliance | XPMCompliance },
275 { "gray17", 43, 43, 43, 1, X11Compliance | XPMCompliance },
276 { "gray18", 46, 46, 46, 1, X11Compliance | XPMCompliance },
277 { "gray19", 48, 48, 48, 1, X11Compliance | XPMCompliance },
278 { "gray2", 5, 5, 5, 1, X11Compliance | XPMCompliance },
279 { "gray20", 51, 51, 51, 1, X11Compliance | XPMCompliance },
280 { "gray21", 54, 54, 54, 1, X11Compliance | XPMCompliance },
281 { "gray22", 56, 56, 56, 1, X11Compliance | XPMCompliance },
282 { "gray23", 59, 59, 59, 1, X11Compliance | XPMCompliance },
283 { "gray24", 61, 61, 61, 1, X11Compliance | XPMCompliance },
284 { "gray25", 64, 64, 64, 1, X11Compliance | XPMCompliance },
285 { "gray26", 66, 66, 66, 1, X11Compliance | XPMCompliance },
286 { "gray27", 69, 69, 69, 1, X11Compliance | XPMCompliance },
287 { "gray28", 71, 71, 71, 1, X11Compliance | XPMCompliance },
288 { "gray29", 74, 74, 74, 1, X11Compliance | XPMCompliance },
289 { "gray3", 8, 8, 8, 1, X11Compliance | XPMCompliance },
290 { "gray30", 77, 77, 77, 1, X11Compliance | XPMCompliance },
291 { "gray31", 79, 79, 79, 1, X11Compliance | XPMCompliance },
292 { "gray32", 82, 82, 82, 1, X11Compliance | XPMCompliance },
293 { "gray33", 84, 84, 84, 1, X11Compliance | XPMCompliance },
294 { "gray34", 87, 87, 87, 1, X11Compliance | XPMCompliance },
295 { "gray35", 89, 89, 89, 1, X11Compliance | XPMCompliance },
296 { "gray36", 92, 92, 92, 1, X11Compliance | XPMCompliance },
297 { "gray37", 94, 94, 94, 1, X11Compliance | XPMCompliance },
298 { "gray38", 97, 97, 97, 1, X11Compliance | XPMCompliance },
299 { "gray39", 99, 99, 99, 1, X11Compliance | XPMCompliance },
300 { "gray4", 10, 10, 10, 1, X11Compliance | XPMCompliance },
301 { "gray40", 102, 102, 102, 1, X11Compliance | XPMCompliance },
302 { "gray41", 105, 105, 105, 1, X11Compliance | XPMCompliance },
303 { "gray42", 107, 107, 107, 1, X11Compliance | XPMCompliance },
304 { "gray43", 110, 110, 110, 1, X11Compliance | XPMCompliance },
305 { "gray44", 112, 112, 112, 1, X11Compliance | XPMCompliance },
306 { "gray45", 115, 115, 115, 1, X11Compliance | XPMCompliance },
307 { "gray46", 117, 117, 117, 1, X11Compliance | XPMCompliance },
308 { "gray47", 120, 120, 120, 1, X11Compliance | XPMCompliance },
309 { "gray48", 122, 122, 122, 1, X11Compliance | XPMCompliance },
310 { "gray49", 125, 125, 125, 1, X11Compliance | XPMCompliance },
311 { "gray5", 13, 13, 13, 1, X11Compliance | XPMCompliance },
312 { "gray50", 127, 127, 127, 1, X11Compliance | XPMCompliance },
313 { "gray51", 130, 130, 130, 1, X11Compliance | XPMCompliance },
314 { "gray52", 133, 133, 133, 1, X11Compliance | XPMCompliance },
315 { "gray53", 135, 135, 135, 1, X11Compliance | XPMCompliance },
316 { "gray54", 138, 138, 138, 1, X11Compliance | XPMCompliance },
317 { "gray55", 140, 140, 140, 1, X11Compliance | XPMCompliance },
318 { "gray56", 143, 143, 143, 1, X11Compliance | XPMCompliance },
319 { "gray57", 145, 145, 145, 1, X11Compliance | XPMCompliance },
320 { "gray58", 148, 148, 148, 1, X11Compliance | XPMCompliance },
321 { "gray59", 150, 150, 150, 1, X11Compliance | XPMCompliance },
322 { "gray6", 15, 15, 15, 1, X11Compliance | XPMCompliance },
323 { "gray60", 153, 153, 153, 1, X11Compliance | XPMCompliance },
324 { "gray61", 156, 156, 156, 1, X11Compliance | XPMCompliance },
325 { "gray62", 158, 158, 158, 1, X11Compliance | XPMCompliance },
326 { "gray63", 161, 161, 161, 1, X11Compliance | XPMCompliance },
327 { "gray64", 163, 163, 163, 1, X11Compliance | XPMCompliance },
328 { "gray65", 166, 166, 166, 1, X11Compliance | XPMCompliance },
329 { "gray66", 168, 168, 168, 1, X11Compliance | XPMCompliance },
330 { "gray67", 171, 171, 171, 1, X11Compliance | XPMCompliance },
331 { "gray68", 173, 173, 173, 1, X11Compliance | XPMCompliance },
332 { "gray69", 176, 176, 176, 1, X11Compliance | XPMCompliance },
333 { "gray7", 18, 18, 18, 1, X11Compliance | XPMCompliance },
334 { "gray70", 179, 179, 179, 1, X11Compliance | XPMCompliance },
335 { "gray71", 181, 181, 181, 1, X11Compliance | XPMCompliance },
336 { "gray72", 184, 184, 184, 1, X11Compliance | XPMCompliance },
337 { "gray73", 186, 186, 186, 1, X11Compliance | XPMCompliance },
338 { "gray74", 189, 189, 189, 1, X11Compliance | XPMCompliance },
339 { "gray75", 191, 191, 191, 1, X11Compliance | XPMCompliance },
340 { "gray76", 194, 194, 194, 1, X11Compliance | XPMCompliance },
341 { "gray77", 196, 196, 196, 1, X11Compliance | XPMCompliance },
342 { "gray78", 199, 199, 199, 1, X11Compliance | XPMCompliance },
343 { "gray79", 201, 201, 201, 1, X11Compliance | XPMCompliance },
344 { "gray8", 20, 20, 20, 1, X11Compliance | XPMCompliance },
345 { "gray80", 204, 204, 204, 1, X11Compliance | XPMCompliance },
346 { "gray81", 207, 207, 207, 1, X11Compliance | XPMCompliance },
347 { "gray82", 209, 209, 209, 1, X11Compliance | XPMCompliance },
348 { "gray83", 212, 212, 212, 1, X11Compliance | XPMCompliance },
349 { "gray84", 214, 214, 214, 1, X11Compliance | XPMCompliance },
350 { "gray85", 217, 217, 217, 1, X11Compliance | XPMCompliance },
351 { "gray86", 219, 219, 219, 1, X11Compliance | XPMCompliance },
352 { "gray87", 222, 222, 222, 1, X11Compliance | XPMCompliance },
353 { "gray88", 224, 224, 224, 1, X11Compliance | XPMCompliance },
354 { "gray89", 227, 227, 227, 1, X11Compliance | XPMCompliance },
355 { "gray9", 23, 23, 23, 1, X11Compliance | XPMCompliance },
356 { "gray90", 229, 229, 229, 1, X11Compliance | XPMCompliance },
357 { "gray91", 232, 232, 232, 1, X11Compliance | XPMCompliance },
358 { "gray92", 235, 235, 235, 1, X11Compliance | XPMCompliance },
359 { "gray93", 237, 237, 237, 1, X11Compliance | XPMCompliance },
360 { "gray94", 240, 240, 240, 1, X11Compliance | XPMCompliance },
361 { "gray95", 242, 242, 242, 1, X11Compliance | XPMCompliance },
362 { "gray96", 245, 245, 245, 1, X11Compliance | XPMCompliance },
363 { "gray97", 247, 247, 247, 1, X11Compliance | XPMCompliance },
364 { "gray98", 250, 250, 250, 1, X11Compliance | XPMCompliance },
365 { "gray99", 252, 252, 252, 1, X11Compliance | XPMCompliance },
366 { "green", 0, 255, 0, 1, X11Compliance | XPMCompliance },
367 { "green1", 0, 255, 0, 1, X11Compliance },
368 { "green2", 0, 238, 0, 1, X11Compliance },
369 { "green3", 0, 205, 0, 1, X11Compliance },
370 { "green4", 0, 139, 0, 1, X11Compliance },
371 { "GreenYellow", 173, 255, 47, 1, X11Compliance | XPMCompliance },
372 { "grey", 190, 190, 190, 1, SVGCompliance | X11Compliance },
373 { "grey0", 0, 0, 0, 1, SVGCompliance | X11Compliance },
374 { "grey1", 3, 3, 3, 1, SVGCompliance | X11Compliance },
375 { "grey10", 26, 26, 26, 1, SVGCompliance | X11Compliance },
376 { "grey100", 255, 255, 255, 1, SVGCompliance | X11Compliance },
377 { "grey11", 28, 28, 28, 1, SVGCompliance | X11Compliance },
378 { "grey12", 31, 31, 31, 1, SVGCompliance | X11Compliance },
379 { "grey13", 33, 33, 33, 1, SVGCompliance | X11Compliance },
380 { "grey14", 36, 36, 36, 1, SVGCompliance | X11Compliance },
381 { "grey15", 38, 38, 38, 1, SVGCompliance | X11Compliance },
382 { "grey16", 41, 41, 41, 1, SVGCompliance | X11Compliance },
383 { "grey17", 43, 43, 43, 1, SVGCompliance | X11Compliance },
384 { "grey18", 46, 46, 46, 1, SVGCompliance | X11Compliance },
385 { "grey19", 48, 48, 48, 1, SVGCompliance | X11Compliance },
386 { "grey2", 5, 5, 5, 1, SVGCompliance | X11Compliance },
387 { "grey20", 51, 51, 51, 1, SVGCompliance | X11Compliance },
388 { "grey21", 54, 54, 54, 1, SVGCompliance | X11Compliance },
389 { "grey22", 56, 56, 56, 1, SVGCompliance | X11Compliance },
390 { "grey23", 59, 59, 59, 1, SVGCompliance | X11Compliance },
391 { "grey24", 61, 61, 61, 1, SVGCompliance | X11Compliance },
392 { "grey25", 64, 64, 64, 1, SVGCompliance | X11Compliance },
393 { "grey26", 66, 66, 66, 1, SVGCompliance | X11Compliance },
394 { "grey27", 69, 69, 69, 1, SVGCompliance | X11Compliance },
395 { "grey28", 71, 71, 71, 1, SVGCompliance | X11Compliance },
396 { "grey29", 74, 74, 74, 1, SVGCompliance | X11Compliance },
397 { "grey3", 8, 8, 8, 1, SVGCompliance | X11Compliance },
398 { "grey30", 77, 77, 77, 1, SVGCompliance | X11Compliance },
399 { "grey31", 79, 79, 79, 1, SVGCompliance | X11Compliance },
400 { "grey32", 82, 82, 82, 1, SVGCompliance | X11Compliance },
401 { "grey33", 84, 84, 84, 1, SVGCompliance | X11Compliance },
402 { "grey34", 87, 87, 87, 1, SVGCompliance | X11Compliance },
403 { "grey35", 89, 89, 89, 1, SVGCompliance | X11Compliance },
404 { "grey36", 92, 92, 92, 1, SVGCompliance | X11Compliance },
405 { "grey37", 94, 94, 94, 1, SVGCompliance | X11Compliance },
406 { "grey38", 97, 97, 97, 1, SVGCompliance | X11Compliance },
407 { "grey39", 99, 99, 99, 1, SVGCompliance | X11Compliance },
408 { "grey4", 10, 10, 10, 1, SVGCompliance | X11Compliance },
409 { "grey40", 102, 102, 102, 1, SVGCompliance | X11Compliance },
410 { "grey41", 105, 105, 105, 1, SVGCompliance | X11Compliance },
411 { "grey42", 107, 107, 107, 1, SVGCompliance | X11Compliance },
412 { "grey43", 110, 110, 110, 1, SVGCompliance | X11Compliance },
413 { "grey44", 112, 112, 112, 1, SVGCompliance | X11Compliance },
414 { "grey45", 115, 115, 115, 1, SVGCompliance | X11Compliance },
415 { "grey46", 117, 117, 117, 1, SVGCompliance | X11Compliance },
416 { "grey47", 120, 120, 120, 1, SVGCompliance | X11Compliance },
417 { "grey48", 122, 122, 122, 1, SVGCompliance | X11Compliance },
418 { "grey49", 125, 125, 125, 1, SVGCompliance | X11Compliance },
419 { "grey5", 13, 13, 13, 1, SVGCompliance | X11Compliance },
420 { "grey50", 127, 127, 127, 1, SVGCompliance | X11Compliance },
421 { "grey51", 130, 130, 130, 1, SVGCompliance | X11Compliance },
422 { "grey52", 133, 133, 133, 1, SVGCompliance | X11Compliance },
423 { "grey53", 135, 135, 135, 1, SVGCompliance | X11Compliance },
424 { "grey54", 138, 138, 138, 1, SVGCompliance | X11Compliance },
425 { "grey55", 140, 140, 140, 1, SVGCompliance | X11Compliance },
426 { "grey56", 143, 143, 143, 1, SVGCompliance | X11Compliance },
427 { "grey57", 145, 145, 145, 1, SVGCompliance | X11Compliance },
428 { "grey58", 148, 148, 148, 1, SVGCompliance | X11Compliance },
429 { "grey59", 150, 150, 150, 1, SVGCompliance | X11Compliance },
430 { "grey6", 15, 15, 15, 1, SVGCompliance | X11Compliance },
431 { "grey60", 153, 153, 153, 1, SVGCompliance | X11Compliance },
432 { "grey61", 156, 156, 156, 1, SVGCompliance | X11Compliance },
433 { "grey62", 158, 158, 158, 1, SVGCompliance | X11Compliance },
434 { "grey63", 161, 161, 161, 1, SVGCompliance | X11Compliance },
435 { "grey64", 163, 163, 163, 1, SVGCompliance | X11Compliance },
436 { "grey65", 166, 166, 166, 1, SVGCompliance | X11Compliance },
437 { "grey66", 168, 168, 168, 1, SVGCompliance | X11Compliance },
438 { "grey67", 171, 171, 171, 1, SVGCompliance | X11Compliance },
439 { "grey68", 173, 173, 173, 1, SVGCompliance | X11Compliance },
440 { "grey69", 176, 176, 176, 1, SVGCompliance | X11Compliance },
441 { "grey7", 18, 18, 18, 1, SVGCompliance | X11Compliance },
442 { "grey70", 179, 179, 179, 1, SVGCompliance | X11Compliance },
443 { "grey71", 181, 181, 181, 1, SVGCompliance | X11Compliance },
444 { "grey72", 184, 184, 184, 1, SVGCompliance | X11Compliance },
445 { "grey73", 186, 186, 186, 1, SVGCompliance | X11Compliance },
446 { "grey74", 189, 189, 189, 1, SVGCompliance | X11Compliance },
447 { "grey75", 191, 191, 191, 1, SVGCompliance | X11Compliance },
448 { "grey76", 194, 194, 194, 1, SVGCompliance | X11Compliance },
449 { "grey77", 196, 196, 196, 1, SVGCompliance | X11Compliance },
450 { "grey78", 199, 199, 199, 1, SVGCompliance | X11Compliance },
451 { "grey79", 201, 201, 201, 1, SVGCompliance | X11Compliance },
452 { "grey8", 20, 20, 20, 1, SVGCompliance | X11Compliance },
453 { "grey80", 204, 204, 204, 1, SVGCompliance | X11Compliance },
454 { "grey81", 207, 207, 207, 1, SVGCompliance | X11Compliance },
455 { "grey82", 209, 209, 209, 1, SVGCompliance | X11Compliance },
456 { "grey83", 212, 212, 212, 1, SVGCompliance | X11Compliance },
457 { "grey84", 214, 214, 214, 1, SVGCompliance | X11Compliance },
458 { "grey85", 217, 217, 217, 1, SVGCompliance | X11Compliance },
459 { "grey86", 219, 219, 219, 1, SVGCompliance | X11Compliance },
460 { "grey87", 222, 222, 222, 1, SVGCompliance | X11Compliance },
461 { "grey88", 224, 224, 224, 1, SVGCompliance | X11Compliance },
462 { "grey89", 227, 227, 227, 1, SVGCompliance | X11Compliance },
463 { "grey9", 23, 23, 23, 1, SVGCompliance | X11Compliance },
464 { "grey90", 229, 229, 229, 1, SVGCompliance | X11Compliance },
465 { "grey91", 232, 232, 232, 1, SVGCompliance | X11Compliance },
466 { "grey92", 235, 235, 235, 1, SVGCompliance | X11Compliance },
467 { "grey93", 237, 237, 237, 1, SVGCompliance | X11Compliance },
468 { "grey94", 240, 240, 240, 1, SVGCompliance | X11Compliance },
469 { "grey95", 242, 242, 242, 1, SVGCompliance | X11Compliance },
470 { "grey96", 245, 245, 245, 1, SVGCompliance | X11Compliance },
471 { "grey97", 247, 247, 247, 1, SVGCompliance | X11Compliance },
472 { "grey98", 250, 250, 250, 1, SVGCompliance | X11Compliance },
473 { "grey99", 252, 252, 252, 1, SVGCompliance | X11Compliance },
474 { "honeydew", 240, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
475 { "honeydew1", 240, 255, 240, 1, X11Compliance },
476 { "honeydew2", 224, 238, 224, 1, X11Compliance },
477 { "honeydew3", 193, 205, 193, 1, X11Compliance },
478 { "honeydew4", 131, 139, 131, 1, X11Compliance },
479 { "HotPink", 255, 105, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
480 { "HotPink1", 255, 110, 180, 1, X11Compliance },
481 { "HotPink2", 238, 106, 167, 1, X11Compliance },
482 { "HotPink3", 205, 96, 144, 1, X11Compliance },
483 { "HotPink4", 139, 58, 98, 1, X11Compliance },
484 { "IndianRed", 205, 92, 92, 1, SVGCompliance | X11Compliance | XPMCompliance },
485 { "IndianRed1", 255, 106, 106, 1, X11Compliance },
486 { "IndianRed2", 238, 99, 99, 1, X11Compliance },
487 { "IndianRed3", 205, 85, 85, 1, X11Compliance },
488 { "IndianRed4", 139, 58, 58, 1, X11Compliance },
489 { "indigo", 75, 0, 130, 1, SVGCompliance },
490 { "ivory", 255, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
491 { "ivory1", 255, 255, 240, 1, X11Compliance },
492 { "ivory2", 238, 238, 224, 1, X11Compliance },
493 { "ivory3", 205, 205, 193, 1, X11Compliance },
494 { "ivory4", 139, 139, 131, 1, X11Compliance },
495 { "khaki", 240, 230, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
496 { "khaki1", 255, 246, 143, 1, X11Compliance },
497 { "khaki2", 238, 230, 133, 1, X11Compliance },
498 { "khaki3", 205, 198, 115, 1, X11Compliance },
499 { "khaki4", 139, 134, 78, 1, X11Compliance },
500 { "lavender", 230, 230, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
501 { "LavenderBlush", 255, 240, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
502 { "LavenderBlush1", 255, 240, 245, 1, X11Compliance },
503 { "LavenderBlush2", 238, 224, 229, 1, X11Compliance },
504 { "LavenderBlush3", 205, 193, 197, 1, X11Compliance },
505 { "LavenderBlush4", 139, 131, 134, 1, X11Compliance },
506 { "LawnGreen", 124, 252, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
507 { "LemonChiffon", 255, 250, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
508 { "LemonChiffon1", 255, 250, 205, 1, X11Compliance },
509 { "LemonChiffon2", 238, 233, 191, 1, X11Compliance },
510 { "LemonChiffon3", 205, 201, 165, 1, X11Compliance },
511 { "LemonChiffon4", 139, 137, 112, 1, X11Compliance },
512 { "LightBlue", 173, 216, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
513 { "LightBlue1", 191, 239, 255, 1, X11Compliance },
514 { "LightBlue2", 178, 223, 238, 1, X11Compliance },
515 { "LightBlue3", 154, 192, 205, 1, X11Compliance },
516 { "LightBlue4", 104, 131, 139, 1, X11Compliance },
517 { "LightCoral", 240, 128, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
518 { "LightCyan", 224, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
519 { "LightCyan1", 224, 255, 255, 1, X11Compliance },
520 { "LightCyan2", 209, 238, 238, 1, X11Compliance },
521 { "LightCyan3", 180, 205, 205, 1, X11Compliance },
522 { "LightCyan4", 122, 139, 139, 1, X11Compliance },
523 { "LightGoldenrod", 238, 221, 130, 1, X11Compliance | XPMCompliance },
524 { "LightGoldenrod1", 255, 236, 139, 1, X11Compliance },
525 { "LightGoldenrod2", 238, 220, 130, 1, X11Compliance },
526 { "LightGoldenrod3", 205, 190, 112, 1, X11Compliance },
527 { "LightGoldenrod4", 139, 129, 76, 1, X11Compliance },
528 { "LightGoldenrodYellow", 250, 250, 210, 1, SVGCompliance | X11Compliance | XPMCompliance },
529 { "LightGray", 211, 211, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
530 { "LightGreen", 144, 238, 144, 1, SVGCompliance | X11Compliance },
531 { "LightGrey", 211, 211, 211, 1, SVGCompliance | X11Compliance },
532 { "LightPink", 255, 182, 193, 1, SVGCompliance | X11Compliance | XPMCompliance },
533 { "LightPink1", 255, 174, 185, 1, X11Compliance },
534 { "LightPink2", 238, 162, 173, 1, X11Compliance },
535 { "LightPink3", 205, 140, 149, 1, X11Compliance },
536 { "LightPink4", 139, 95, 101, 1, X11Compliance },
537 { "LightSalmon", 255, 160, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
538 { "LightSalmon1", 255, 160, 122, 1, X11Compliance },
539 { "LightSalmon2", 238, 149, 114, 1, X11Compliance },
540 { "LightSalmon3", 205, 129, 98, 1, X11Compliance },
541 { "LightSalmon4", 139, 87, 66, 1, X11Compliance },
542 { "LightSeaGreen", 32, 178, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
543 { "LightSkyBlue", 135, 206, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
544 { "LightSkyBlue1", 176, 226, 255, 1, X11Compliance },
545 { "LightSkyBlue2", 164, 211, 238, 1, X11Compliance },
546 { "LightSkyBlue3", 141, 182, 205, 1, X11Compliance },
547 { "LightSkyBlue4", 96, 123, 139, 1, X11Compliance },
548 { "LightSlateBlue", 132, 112, 255, 1, X11Compliance | XPMCompliance },
549 { "LightSlateGray", 119, 136, 153, 1, SVGCompliance | X11Compliance | XPMCompliance },
550 { "LightSlateGrey", 119, 136, 153, 1, SVGCompliance | X11Compliance },
551 { "LightSteelBlue", 176, 196, 222, 1, SVGCompliance | X11Compliance | XPMCompliance },
552 { "LightSteelBlue1", 202, 225, 255, 1, X11Compliance },
553 { "LightSteelBlue2", 188, 210, 238, 1, X11Compliance },
554 { "LightSteelBlue3", 162, 181, 205, 1, X11Compliance },
555 { "LightSteelBlue4", 110, 123, 139, 1, X11Compliance },
556 { "LightYellow", 255, 255, 224, 1, SVGCompliance | X11Compliance | XPMCompliance },
557 { "LightYellow1", 255, 255, 224, 1, X11Compliance },
558 { "LightYellow2", 238, 238, 209, 1, X11Compliance },
559 { "LightYellow3", 205, 205, 180, 1, X11Compliance },
560 { "LightYellow4", 139, 139, 122, 1, X11Compliance },
561 { "lime", 0, 255, 0, 1, SVGCompliance },
562 { "LimeGreen", 50, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance },
563 { "linen", 250, 240, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
564 { "magenta1", 255, 0, 255, 1, X11Compliance },
565 { "magenta2", 238, 0, 238, 1, X11Compliance },
566 { "magenta3", 205, 0, 205, 1, X11Compliance },
567 { "magenta4", 139, 0, 139, 1, X11Compliance },
568 { "maroon", 128, 0, 0, 1, SVGCompliance },
569 { "maroon", 176, 48, 96, 1, X11Compliance | XPMCompliance },
570 { "maroon1", 255, 52, 179, 1, X11Compliance },
571 { "maroon2", 238, 48, 167, 1, X11Compliance },
572 { "maroon3", 205, 41, 144, 1, X11Compliance },
573 { "maroon4", 139, 28, 98, 1, X11Compliance },
574 { "MediumAquamarine", 102, 205, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
575 { "MediumBlue", 0, 0, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
576 { "MediumForestGreen", 50, 129, 75, 1, X11Compliance | XPMCompliance },
577 { "MediumGoldenRod", 209, 193, 102, 1, X11Compliance | XPMCompliance },
578 { "MediumOrchid", 186, 85, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
579 { "MediumOrchid1", 224, 102, 255, 1, X11Compliance },
580 { "MediumOrchid2", 209, 95, 238, 1, X11Compliance },
581 { "MediumOrchid3", 180, 82, 205, 1, X11Compliance },
582 { "MediumOrchid4", 122, 55, 139, 1, X11Compliance },
583 { "MediumPurple", 147, 112, 219, 1, SVGCompliance | X11Compliance | XPMCompliance },
584 { "MediumPurple1", 171, 130, 255, 1, X11Compliance },
585 { "MediumPurple2", 159, 121, 238, 1, X11Compliance },
586 { "MediumPurple3", 137, 104, 205, 1, X11Compliance },
587 { "MediumPurple4", 93, 71, 139, 1, X11Compliance },
588 { "MediumSeaGreen", 60, 179, 113, 1, SVGCompliance | X11Compliance | XPMCompliance },
589 { "MediumSlateBlue", 123, 104, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
590 { "MediumSpringGreen", 0, 250, 154, 1, SVGCompliance | X11Compliance | XPMCompliance },
591 { "MediumTurquoise", 72, 209, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
592 { "MediumVioletRed", 199, 21, 133, 1, SVGCompliance | X11Compliance | XPMCompliance },
593 { "MidnightBlue", 25, 25, 112, 1, SVGCompliance | X11Compliance | XPMCompliance },
594 { "MintCream", 245, 255, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
595 { "MistyRose", 255, 228, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
596 { "MistyRose1", 255, 228, 225, 1, X11Compliance },
597 { "MistyRose2", 238, 213, 210, 1, X11Compliance },
598 { "MistyRose3", 205, 183, 181, 1, X11Compliance },
599 { "MistyRose4", 139, 125, 123, 1, X11Compliance },
600 { "moccasin", 255, 228, 181, 1, SVGCompliance | X11Compliance | XPMCompliance },
601 { "NavajoWhite", 255, 222, 173, 1, SVGCompliance | X11Compliance | XPMCompliance },
602 { "NavajoWhite1", 255, 222, 173, 1, X11Compliance },
603 { "NavajoWhite2", 238, 207, 161, 1, X11Compliance },
604 { "NavajoWhite3", 205, 179, 139, 1, X11Compliance },
605 { "NavajoWhite4", 139, 121, 94, 1, X11Compliance },
606 { "navy", 0, 0, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
607 { "NavyBlue", 0, 0, 128, 1, X11Compliance | XPMCompliance },
608 { "matte", 0, 0, 0, 0, SVGCompliance },
609 { "OldLace", 253, 245, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
610 { "olive", 128, 128, 0, 1, SVGCompliance },
611 { "OliveDrab", 107, 142, 35, 1, SVGCompliance | X11Compliance | XPMCompliance },
612 { "OliveDrab1", 192, 255, 62, 1, X11Compliance },
613 { "OliveDrab2", 179, 238, 58, 1, X11Compliance },
614 { "OliveDrab3", 154, 205, 50, 1, X11Compliance },
615 { "OliveDrab4", 105, 139, 34, 1, X11Compliance },
616 { "opaque", 0, 0, 0, 1, SVGCompliance },
617 { "orange", 255, 165, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
618 { "orange1", 255, 165, 0, 1, X11Compliance },
619 { "orange2", 238, 154, 0, 1, X11Compliance },
620 { "orange3", 205, 133, 0, 1, X11Compliance },
621 { "orange4", 139, 90, 0, 1, X11Compliance },
622 { "OrangeRed", 255, 69, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
623 { "OrangeRed1", 255, 69, 0, 1, X11Compliance },
624 { "OrangeRed2", 238, 64, 0, 1, X11Compliance },
625 { "OrangeRed3", 205, 55, 0, 1, X11Compliance },
626 { "OrangeRed4", 139, 37, 0, 1, X11Compliance },
627 { "orchid", 218, 112, 214, 1, SVGCompliance | X11Compliance | XPMCompliance },
628 { "orchid1", 255, 131, 250, 1, X11Compliance },
629 { "orchid2", 238, 122, 233, 1, X11Compliance },
630 { "orchid3", 205, 105, 201, 1, X11Compliance },
631 { "orchid4", 139, 71, 137, 1, X11Compliance },
632 { "PaleGoldenrod", 238, 232, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
633 { "PaleGreen", 152, 251, 152, 1, SVGCompliance | X11Compliance | XPMCompliance },
634 { "PaleGreen1", 154, 255, 154, 1, X11Compliance },
635 { "PaleGreen2", 144, 238, 144, 1, X11Compliance },
636 { "PaleGreen3", 124, 205, 124, 1, X11Compliance },
637 { "PaleGreen4", 84, 139, 84, 1, X11Compliance },
638 { "PaleTurquoise", 175, 238, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
639 { "PaleTurquoise1", 187, 255, 255, 1, X11Compliance },
640 { "PaleTurquoise2", 174, 238, 238, 1, X11Compliance },
641 { "PaleTurquoise3", 150, 205, 205, 1, X11Compliance },
642 { "PaleTurquoise4", 102, 139, 139, 1, X11Compliance },
643 { "PaleVioletRed", 219, 112, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
644 { "PaleVioletRed1", 255, 130, 171, 1, X11Compliance },
645 { "PaleVioletRed2", 238, 121, 159, 1, X11Compliance },
646 { "PaleVioletRed3", 205, 104, 137, 1, X11Compliance },
647 { "PaleVioletRed4", 139, 71, 93, 1, X11Compliance },
648 { "PapayaWhip", 255, 239, 213, 1, SVGCompliance | X11Compliance | XPMCompliance },
649 { "PeachPuff", 255, 218, 185, 1, SVGCompliance | X11Compliance | XPMCompliance },
650 { "PeachPuff1", 255, 218, 185, 1, X11Compliance },
651 { "PeachPuff2", 238, 203, 173, 1, X11Compliance },
652 { "PeachPuff3", 205, 175, 149, 1, X11Compliance },
653 { "PeachPuff4", 139, 119, 101, 1, X11Compliance },
654 { "peru", 205, 133, 63, 1, SVGCompliance | X11Compliance | XPMCompliance },
655 { "pink", 255, 192, 203, 1, SVGCompliance | X11Compliance | XPMCompliance },
656 { "pink1", 255, 181, 197, 1, X11Compliance },
657 { "pink2", 238, 169, 184, 1, X11Compliance },
658 { "pink3", 205, 145, 158, 1, X11Compliance },
659 { "pink4", 139, 99, 108, 1, X11Compliance },
660 { "plum", 221, 160, 221, 1, SVGCompliance | X11Compliance | XPMCompliance },
661 { "plum1", 255, 187, 255, 1, X11Compliance },
662 { "plum2", 238, 174, 238, 1, X11Compliance },
663 { "plum3", 205, 150, 205, 1, X11Compliance },
664 { "plum4", 139, 102, 139, 1, X11Compliance },
665 { "PowderBlue", 176, 224, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
666 { "purple", 128, 0, 128, 1, SVGCompliance },
667 { "purple", 160, 32, 240, 1, X11Compliance | XPMCompliance },
668 { "purple1", 155, 48, 255, 1, X11Compliance },
669 { "purple2", 145, 44, 238, 1, X11Compliance },
670 { "purple3", 125, 38, 205, 1, X11Compliance },
671 { "purple4", 85, 26, 139, 1, X11Compliance },
672 { "red1", 255, 0, 0, 1, X11Compliance },
673 { "red2", 238, 0, 0, 1, X11Compliance },
674 { "red3", 205, 0, 0, 1, X11Compliance },
675 { "red4", 139, 0, 0, 1, X11Compliance },
676 { "RosyBrown", 188, 143, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
677 { "RosyBrown1", 255, 193, 193, 1, X11Compliance },
678 { "RosyBrown2", 238, 180, 180, 1, X11Compliance },
679 { "RosyBrown3", 205, 155, 155, 1, X11Compliance },
680 { "RosyBrown4", 139, 105, 105, 1, X11Compliance },
681 { "RoyalBlue", 65, 105, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
682 { "RoyalBlue1", 72, 118, 255, 1, X11Compliance },
683 { "RoyalBlue2", 67, 110, 238, 1, X11Compliance },
684 { "RoyalBlue3", 58, 95, 205, 1, X11Compliance },
685 { "RoyalBlue4", 39, 64, 139, 1, X11Compliance },
686 { "SaddleBrown", 139, 69, 19, 1, SVGCompliance | X11Compliance | XPMCompliance },
687 { "salmon", 250, 128, 114, 1, SVGCompliance | X11Compliance | XPMCompliance },
688 { "salmon1", 255, 140, 105, 1, X11Compliance },
689 { "salmon2", 238, 130, 98, 1, X11Compliance },
690 { "salmon3", 205, 112, 84, 1, X11Compliance },
691 { "salmon4", 139, 76, 57, 1, X11Compliance },
692 { "SandyBrown", 244, 164, 96, 1, SVGCompliance | X11Compliance | XPMCompliance },
693 { "SeaGreen", 46, 139, 87, 1, SVGCompliance | X11Compliance | XPMCompliance },
694 { "SeaGreen1", 84, 255, 159, 1, X11Compliance },
695 { "SeaGreen2", 78, 238, 148, 1, X11Compliance },
696 { "SeaGreen3", 67, 205, 128, 1, X11Compliance },
697 { "SeaGreen4", 46, 139, 87, 1, X11Compliance },
698 { "seashell", 255, 245, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
699 { "seashell1", 255, 245, 238, 1, X11Compliance },
700 { "seashell2", 238, 229, 222, 1, X11Compliance },
701 { "seashell3", 205, 197, 191, 1, X11Compliance },
702 { "seashell4", 139, 134, 130, 1, X11Compliance },
703 { "sienna", 160, 82, 45, 1, SVGCompliance | X11Compliance | XPMCompliance },
704 { "sienna1", 255, 130, 71, 1, X11Compliance },
705 { "sienna2", 238, 121, 66, 1, X11Compliance },
706 { "sienna3", 205, 104, 57, 1, X11Compliance },
707 { "sienna4", 139, 71, 38, 1, X11Compliance },
708 { "silver", 192, 192, 192, 1, SVGCompliance },
709 { "SkyBlue", 135, 206, 235, 1, SVGCompliance | X11Compliance | XPMCompliance },
710 { "SkyBlue1", 135, 206, 255, 1, X11Compliance },
711 { "SkyBlue2", 126, 192, 238, 1, X11Compliance },
712 { "SkyBlue3", 108, 166, 205, 1, X11Compliance },
713 { "SkyBlue4", 74, 112, 139, 1, X11Compliance },
714 { "SlateBlue", 106, 90, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
715 { "SlateBlue1", 131, 111, 255, 1, X11Compliance },
716 { "SlateBlue2", 122, 103, 238, 1, X11Compliance },
717 { "SlateBlue3", 105, 89, 205, 1, X11Compliance },
718 { "SlateBlue4", 71, 60, 139, 1, X11Compliance },
719 { "SlateGray", 112, 128, 144, 1, SVGCompliance | X11Compliance | XPMCompliance },
720 { "SlateGray1", 198, 226, 255, 1, X11Compliance },
721 { "SlateGray2", 185, 211, 238, 1, X11Compliance },
722 { "SlateGray3", 159, 182, 205, 1, X11Compliance },
723 { "SlateGray4", 108, 123, 139, 1, X11Compliance },
724 { "SlateGrey", 112, 128, 144, 1, SVGCompliance | X11Compliance },
725 { "snow", 255, 250, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
726 { "snow1", 255, 250, 250, 1, X11Compliance },
727 { "snow2", 238, 233, 233, 1, X11Compliance },
728 { "snow3", 205, 201, 201, 1, X11Compliance },
729 { "snow4", 139, 137, 137, 1, X11Compliance },
730 { "SpringGreen", 0, 255, 127, 1, SVGCompliance | X11Compliance | XPMCompliance },
731 { "SpringGreen1", 0, 255, 127, 1, X11Compliance },
732 { "SpringGreen2", 0, 238, 118, 1, X11Compliance },
733 { "SpringGreen3", 0, 205, 102, 1, X11Compliance },
734 { "SpringGreen4", 0, 139, 69, 1, X11Compliance },
735 { "SteelBlue", 70, 130, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
736 { "SteelBlue1", 99, 184, 255, 1, X11Compliance },
737 { "SteelBlue2", 92, 172, 238, 1, X11Compliance },
738 { "SteelBlue3", 79, 148, 205, 1, X11Compliance },
739 { "SteelBlue4", 54, 100, 139, 1, X11Compliance },
740 { "tan", 210, 180, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
741 { "tan1", 255, 165, 79, 1, X11Compliance },
742 { "tan2", 238, 154, 73, 1, X11Compliance },
743 { "tan3", 205, 133, 63, 1, X11Compliance },
744 { "tan4", 139, 90, 43, 1, X11Compliance },
745 { "teal", 0, 128, 128, 1, SVGCompliance },
746 { "thistle", 216, 191, 216, 1, SVGCompliance | X11Compliance | XPMCompliance },
747 { "thistle1", 255, 225, 255, 1, X11Compliance },
748 { "thistle2", 238, 210, 238, 1, X11Compliance },
749 { "thistle3", 205, 181, 205, 1, X11Compliance },
750 { "thistle4", 139, 123, 139, 1, X11Compliance },
751 { "tomato", 255, 99, 71, 1, SVGCompliance | X11Compliance | XPMCompliance },
752 { "tomato1", 255, 99, 71, 1, X11Compliance },
753 { "tomato2", 238, 92, 66, 1, X11Compliance },
754 { "tomato3", 205, 79, 57, 1, X11Compliance },
755 { "tomato4", 139, 54, 38, 1, X11Compliance },
756 { "transparent", 0, 0, 0, 0, SVGCompliance },
757 { "turquoise", 64, 224, 208, 1, SVGCompliance | X11Compliance | XPMCompliance },
758 { "turquoise1", 0, 245, 255, 1, X11Compliance },
759 { "turquoise2", 0, 229, 238, 1, X11Compliance },
760 { "turquoise3", 0, 197, 205, 1, X11Compliance },
761 { "turquoise4", 0, 134, 139, 1, X11Compliance },
762 { "violet", 238, 130, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
763 { "VioletRed", 208, 32, 144, 1, X11Compliance | XPMCompliance },
764 { "VioletRed1", 255, 62, 150, 1, X11Compliance },
765 { "VioletRed2", 238, 58, 140, 1, X11Compliance },
766 { "VioletRed3", 205, 50, 120, 1, X11Compliance },
767 { "VioletRed4", 139, 34, 82, 1, X11Compliance },
768 { "wheat", 245, 222, 179, 1, SVGCompliance | X11Compliance | XPMCompliance },
769 { "wheat1", 255, 231, 186, 1, X11Compliance },
770 { "wheat2", 238, 216, 174, 1, X11Compliance },
771 { "wheat3", 205, 186, 150, 1, X11Compliance },
772 { "wheat4", 139, 126, 102, 1, X11Compliance },
773 { "WhiteSmoke", 245, 245, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
774 { "yellow1", 255, 255, 0, 1, X11Compliance },
775 { "yellow2", 238, 238, 0, 1, X11Compliance },
776 { "yellow3", 205, 205, 0, 1, X11Compliance },
777 { "yellow4", 139, 139, 0, 1, X11Compliance },
778 { "YellowGreen", 154, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance }
784 static LinkedListInfo
785 *color_list = (LinkedListInfo *) NULL;
788 *color_semaphore = (SemaphoreInfo *) NULL;
790 static volatile MagickBooleanType
791 instantiate_color = MagickFalse;
794 Forward declarations.
796 static MagickBooleanType
797 InitializeColorList(ExceptionInfo *),
798 LoadColorLists(const char *,ExceptionInfo *);
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805 + C o l o r C o m p o n e n t G e n e s i s %
809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
811 % ColorComponentGenesis() instantiates the color component.
813 % The format of the ColorComponentGenesis method is:
815 % MagickBooleanType ColorComponentGenesis(void)
818 MagickExport MagickBooleanType ColorComponentGenesis(void)
820 AcquireSemaphoreInfo(&color_semaphore);
825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 + C o l o r C o m p o n e n t T e r m i n u s %
833 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 % ColorComponentTerminus() destroys the color component.
837 % The format of the ColorComponentTerminus method is:
839 % ColorComponentTerminus(void)
843 static void *DestroyColorElement(void *color_info)
848 p=(ColorInfo *) color_info;
849 if (p->exempt == MagickFalse)
851 if (p->path != (char *) NULL)
852 p->path=DestroyString(p->path);
853 if (p->name != (char *) NULL)
854 p->name=DestroyString(p->name);
856 p=(ColorInfo *) RelinquishMagickMemory(p);
857 return((void *) NULL);
860 MagickExport void ColorComponentTerminus(void)
862 if (color_semaphore == (SemaphoreInfo *) NULL)
863 AcquireSemaphoreInfo(&color_semaphore);
864 LockSemaphoreInfo(color_semaphore);
865 if (color_list != (LinkedListInfo *) NULL)
866 color_list=DestroyLinkedList(color_list,DestroyColorElement);
867 instantiate_color=MagickFalse;
868 UnlockSemaphoreInfo(color_semaphore);
869 DestroySemaphoreInfo(&color_semaphore);
873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
877 + G e t C o l o r C o m p l i a n c e %
881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
883 % GetColorInfo() searches the color list for the specified name and standards
884 % compliance and if found returns attributes for that color.
886 % The format of the GetColorInfo method is:
888 % const PixelPacket *GetColorInfo(const char *name,
889 % const ComplianceType compliance,ExceptionInfo *exception)
891 % A description of each parameter follows:
893 % o name: the color name.
895 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
897 % o exception: return any errors or warnings in this structure.
900 MagickExport const ColorInfo *GetColorCompliance(const char *name,
901 const ComplianceType compliance,ExceptionInfo *exception)
904 colorname[MaxTextExtent];
906 register const ColorInfo
912 assert(exception != (ExceptionInfo *) NULL);
913 if ((color_list == (LinkedListInfo *) NULL) ||
914 (instantiate_color == MagickFalse))
915 if (InitializeColorList(exception) == MagickFalse)
916 return((const ColorInfo *) NULL);
917 if ((color_list == (LinkedListInfo *) NULL) ||
918 (IsLinkedListEmpty(color_list) != MagickFalse))
919 return((const ColorInfo *) NULL);
920 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
921 return((const ColorInfo *) GetValueFromLinkedList(color_list,0));
923 Strip names of whitespace.
925 (void) CopyMagickString(colorname,name,MaxTextExtent);
926 for (q=colorname; *q != '\0'; q++)
928 if (isspace((int) ((unsigned char) *q)) == 0)
930 (void) CopyMagickString(q,q+1,MaxTextExtent);
934 Search for color tag.
936 LockSemaphoreInfo(color_semaphore);
937 ResetLinkedListIterator(color_list);
938 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
939 while (p != (const ColorInfo *) NULL)
941 if (((p->compliance & compliance) != 0) &&
942 (LocaleCompare(colorname,p->name) == 0))
944 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
946 if (p == (ColorInfo *) NULL)
947 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
948 "UnrecognizedColor","`%s'",name);
950 (void) InsertValueInLinkedList(color_list,0,
951 RemoveElementByValueFromLinkedList(color_list,p));
952 UnlockSemaphoreInfo(color_semaphore);
957 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
961 + G e t C o l o r I n f o %
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
967 % GetColorInfo() searches the color list for the specified name and if found
968 % returns attributes for that color.
970 % The format of the GetColorInfo method is:
972 % const PixelPacket *GetColorInfo(const char *name,
973 % ExceptionInfo *exception)
975 % A description of each parameter follows:
977 % o color_info: search the color list for the specified name and if found
978 % return attributes for that color.
980 % o name: the color name.
982 % o exception: return any errors or warnings in this structure.
985 MagickExport const ColorInfo *GetColorInfo(const char *name,
986 ExceptionInfo *exception)
988 return(GetColorCompliance(name,AllCompliance,exception));
992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
996 + 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 %
1000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 % ConcatenateColorComponent() returns the pixel as a canonical string.
1004 % The format of the ConcatenateColorComponent() method is:
1006 % void ConcatenateColorComponent(const PixelInfo *pixel,
1007 % const ChannelType channel,const ComplianceType compliance,char *tuple)
1009 % A description of each parameter follows.
1011 % o pixel: The pixel.
1013 % channel: The channel.
1015 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
1017 % tuple: The color tuple.
1020 MagickExport void ConcatenateColorComponent(const PixelInfo *pixel,
1021 const ChannelType channel,const ComplianceType compliance,char *tuple)
1024 component[MaxTextExtent];
1060 if (compliance != SVGCompliance)
1062 if (pixel->depth > 16)
1064 (void) FormatLocaleString(component,MaxTextExtent,"%10lu",
1065 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1066 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1069 if (pixel->depth > 8)
1071 (void) FormatLocaleString(component,MaxTextExtent,"%5d",
1072 ScaleQuantumToShort(ClampToQuantum(color)));
1073 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1076 (void) FormatLocaleString(component,MaxTextExtent,"%3d",
1077 ScaleQuantumToChar(ClampToQuantum(color)));
1078 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1081 if (channel == AlphaChannel)
1083 (void) FormatLocaleString(component,MaxTextExtent,"%g",
1084 (double) (QuantumScale*color));
1085 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1088 if ((pixel->colorspace == HSLColorspace) ||
1089 (pixel->colorspace == HSBColorspace))
1091 (void) FormatLocaleString(component,MaxTextExtent,"%g%%",
1092 (double) (100.0*QuantumScale*color));
1093 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1096 if (pixel->depth > 8)
1098 (void) FormatLocaleString(component,MaxTextExtent,"%g%%",
1099 (double) (100.0*QuantumScale*color));
1100 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1103 (void) FormatLocaleString(component,MaxTextExtent,"%d",
1104 ScaleQuantumToChar(ClampToQuantum(color)));
1105 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1113 % G e t C o l o r I n f o L i s t %
1117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1119 % GetColorInfoList() returns any colors that match the specified pattern.
1121 % The format of the GetColorInfoList function is:
1123 % const ColorInfo **GetColorInfoList(const char *pattern,
1124 % size_t *number_colors,ExceptionInfo *exception)
1126 % A description of each parameter follows:
1128 % o pattern: Specifies a pointer to a text string containing a pattern.
1130 % o number_colors: This integer returns the number of colors in the list.
1132 % o exception: return any errors or warnings in this structure.
1136 #if defined(__cplusplus) || defined(c_plusplus)
1140 static int ColorInfoCompare(const void *x,const void *y)
1146 p=(const ColorInfo **) x,
1147 q=(const ColorInfo **) y;
1148 if (LocaleCompare((*p)->path,(*q)->path) == 0)
1149 return(LocaleCompare((*p)->name,(*q)->name));
1150 return(LocaleCompare((*p)->path,(*q)->path));
1153 #if defined(__cplusplus) || defined(c_plusplus)
1157 MagickExport const ColorInfo **GetColorInfoList(const char *pattern,
1158 size_t *number_colors,ExceptionInfo *exception)
1163 register const ColorInfo
1170 Allocate color list.
1172 assert(pattern != (char *) NULL);
1173 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1174 assert(number_colors != (size_t *) NULL);
1176 p=GetColorInfo("*",exception);
1177 if (p == (const ColorInfo *) NULL)
1178 return((const ColorInfo **) NULL);
1179 colors=(const ColorInfo **) AcquireQuantumMemory((size_t)
1180 GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
1181 if (colors == (const ColorInfo **) NULL)
1182 return((const ColorInfo **) NULL);
1184 Generate color list.
1186 LockSemaphoreInfo(color_semaphore);
1187 ResetLinkedListIterator(color_list);
1188 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1189 for (i=0; p != (const ColorInfo *) NULL; )
1191 if ((p->stealth == MagickFalse) &&
1192 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1194 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1196 UnlockSemaphoreInfo(color_semaphore);
1197 qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
1198 colors[i]=(ColorInfo *) NULL;
1199 *number_colors=(size_t) i;
1204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1208 % G e t C o l o r L i s t %
1212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 % GetColorList() returns any colors that match the specified pattern.
1216 % The format of the GetColorList function is:
1218 % char **GetColorList(const char *pattern,size_t *number_colors,
1219 % ExceptionInfo *exception)
1221 % A description of each parameter follows:
1223 % o pattern: Specifies a pointer to a text string containing a pattern.
1225 % o number_colors: This integer returns the number of colors in the list.
1227 % o exception: return any errors or warnings in this structure.
1231 #if defined(__cplusplus) || defined(c_plusplus)
1235 static int ColorCompare(const void *x,const void *y)
1241 p=(const char **) x;
1242 q=(const char **) y;
1243 return(LocaleCompare(*p,*q));
1246 #if defined(__cplusplus) || defined(c_plusplus)
1250 MagickExport char **GetColorList(const char *pattern,
1251 size_t *number_colors,ExceptionInfo *exception)
1256 register const ColorInfo
1263 Allocate color list.
1265 assert(pattern != (char *) NULL);
1266 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1267 assert(number_colors != (size_t *) NULL);
1269 p=GetColorInfo("*",exception);
1270 if (p == (const ColorInfo *) NULL)
1271 return((char **) NULL);
1272 colors=(char **) AcquireQuantumMemory((size_t)
1273 GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
1274 if (colors == (char **) NULL)
1275 return((char **) NULL);
1277 Generate color list.
1279 LockSemaphoreInfo(color_semaphore);
1280 ResetLinkedListIterator(color_list);
1281 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1282 for (i=0; p != (const ColorInfo *) NULL; )
1284 if ((p->stealth == MagickFalse) &&
1285 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1286 colors[i++]=ConstantString(p->name);
1287 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1289 UnlockSemaphoreInfo(color_semaphore);
1290 qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
1291 colors[i]=(char *) NULL;
1292 *number_colors=(size_t) i;
1297 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301 + G e t C o l o r T u p l e %
1305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1307 % GetColorTuple() returns a color as a color tuple string (e.g. rgba(255,0,0))
1308 % or hex string (e.g. #FF0000).
1310 % The format of the GetColorTuple method is:
1312 % GetColorTuple(const PixelInfo *pixel,const MagickBooleanType hex,
1315 % A description of each parameter follows.
1317 % o pixel: the pixel.
1319 % o hex: A value other than zero returns the tuple in a hexidecimal format.
1321 % o tuple: Return the color tuple as this string.
1325 static void ConcatentateHexColorComponent(const PixelInfo *pixel,
1326 const ChannelType channel,char *tuple)
1329 component[MaxTextExtent];
1365 if (pixel->depth > 32)
1367 (void) FormatLocaleString(component,MaxTextExtent,"%08lX%08lX",
1368 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)),
1369 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1370 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1373 if (pixel->depth > 16)
1375 (void) FormatLocaleString(component,MaxTextExtent,"%08X",
1376 (unsigned int) ScaleQuantumToLong(ClampToQuantum(color)));
1377 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1380 if (pixel->depth > 8)
1382 (void) FormatLocaleString(component,MaxTextExtent,"%04X",
1383 ScaleQuantumToShort(ClampToQuantum(color)));
1384 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1387 (void) FormatLocaleString(component,MaxTextExtent,"%02X",
1388 ScaleQuantumToChar(ClampToQuantum(color)));
1389 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1393 MagickExport void GetColorTuple(const PixelInfo *pixel,
1394 const MagickBooleanType hex,char *tuple)
1399 assert(pixel != (const PixelInfo *) NULL);
1400 assert(tuple != (char *) NULL);
1401 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tuple);
1403 if (hex != MagickFalse)
1406 Convert pixel to hex color.
1408 (void) ConcatenateMagickString(tuple,"#",MaxTextExtent);
1409 ConcatentateHexColorComponent(pixel,RedChannel,tuple);
1410 ConcatentateHexColorComponent(pixel,GreenChannel,tuple);
1411 ConcatentateHexColorComponent(pixel,BlueChannel,tuple);
1412 if (pixel->colorspace == CMYKColorspace)
1413 ConcatentateHexColorComponent(pixel,BlackChannel,tuple);
1414 if ((pixel->matte != MagickFalse) && (pixel->alpha != OpaqueAlpha))
1415 ConcatentateHexColorComponent(pixel,AlphaChannel,tuple);
1419 Convert pixel to rgb() or cmyk() color.
1422 if (color.depth > 8)
1424 #define SVGCompliant(component) ((MagickRealType) \
1425 ScaleCharToQuantum(ScaleQuantumToChar(ClampToQuantum(component))));
1431 SVG requires color depths > 8 expressed as percentages.
1433 status=color.red == SVGCompliant(color.red);
1434 status&=color.green == SVGCompliant(color.green);
1435 status&=color.blue == SVGCompliant(color.blue);
1436 if (color.colorspace == CMYKColorspace)
1437 status&=color.black == SVGCompliant(color.black);
1438 if (color.matte != MagickFalse)
1439 status&=color.alpha == SVGCompliant(color.alpha);
1440 if (status != MagickFalse)
1443 (void) ConcatenateMagickString(tuple,CommandOptionToMnemonic(
1444 MagickColorspaceOptions,(ssize_t) color.colorspace),MaxTextExtent);
1445 if (color.matte != MagickFalse)
1446 (void) ConcatenateMagickString(tuple,"a",MaxTextExtent);
1447 (void) ConcatenateMagickString(tuple,"(",MaxTextExtent);
1448 ConcatenateColorComponent(&color,RedChannel,SVGCompliance,tuple);
1449 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1450 ConcatenateColorComponent(&color,GreenChannel,SVGCompliance,tuple);
1451 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1452 ConcatenateColorComponent(&color,BlueChannel,SVGCompliance,tuple);
1453 if (color.colorspace == CMYKColorspace)
1455 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1456 ConcatenateColorComponent(&color,BlackChannel,SVGCompliance,tuple);
1458 if (color.matte != MagickFalse)
1460 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1461 ConcatenateColorComponent(&color,AlphaChannel,SVGCompliance,tuple);
1463 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
1469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1473 + I n i t i a l i z e C o l o r L i s t %
1477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1479 % InitializeColorList() initializes the color list.
1481 % The format of the InitializeColorList method is:
1483 % MagickBooleanType InitializeColorList(ExceptionInfo *exception)
1485 % A description of each parameter follows.
1487 % o exception: return any errors or warnings in this structure.
1490 static MagickBooleanType InitializeColorList(ExceptionInfo *exception)
1492 if ((color_list == (LinkedListInfo *) NULL) &&
1493 (instantiate_color == MagickFalse))
1495 if (color_semaphore == (SemaphoreInfo *) NULL)
1496 AcquireSemaphoreInfo(&color_semaphore);
1497 LockSemaphoreInfo(color_semaphore);
1498 if ((color_list == (LinkedListInfo *) NULL) &&
1499 (instantiate_color == MagickFalse))
1501 (void) LoadColorLists(ColorFilename,exception);
1502 instantiate_color=MagickTrue;
1504 UnlockSemaphoreInfo(color_semaphore);
1506 return(color_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1514 + I s A l p h a S i m i l a r %
1518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1520 % IsEquivalentAlpha() returns true if the distance between two alpha values is
1521 % less than the specified distance in a linear color space. This method is
1522 % used by MatteFloodFill() and other algorithms which compare two alpha values.
1524 % The format of the IsEquivalentAlpha method is:
1526 % void IsEquivalentAlpha(const Image *image,const PixelPacket *p,
1527 % const PixelPacket *q)
1529 % A description of each parameter follows:
1531 % o image: the image.
1539 static inline double MagickMax(const double x,const double y)
1546 MagickExport MagickBooleanType IsEquivalentAlpha(const Image *image,
1547 const PixelPacket *p,const PixelPacket *q)
1553 register MagickRealType
1556 if (image->matte == MagickFalse)
1558 if (p->alpha == q->alpha)
1560 fuzz=MagickMax(image->fuzz,MagickSQ1_2)*MagickMax(image->fuzz,MagickSQ1_2);
1561 pixel=(MagickRealType) p->alpha-(MagickRealType) q->alpha;
1562 distance=pixel*pixel;
1563 if (distance > fuzz)
1564 return(MagickFalse);
1569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1573 + I s I m a g e S i m i l a r %
1577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1579 % IsEquivalentImage() returns true if the target is similar to a region of the
1582 % The format of the IsEquivalentImage method is:
1584 % MagickBooleanType IsEquivalentImage(const Image *image,
1585 % const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1586 % ExceptionInfo *exception)
1588 % A description of each parameter follows:
1590 % o image: the image.
1592 % o target_image: the target image.
1594 % o x_offset: On input the starting x position to search for a match;
1595 % on output the x position of the first match found.
1597 % o y_offset: On input the starting y position to search for a match;
1598 % on output the y position of the first match found.
1600 % o exception: return any errors or warnings in this structure.
1603 MagickExport MagickBooleanType IsEquivalentImage(const Image *image,
1604 const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1605 ExceptionInfo *exception)
1607 #define SearchImageText " Searching image... "
1620 register const Quantum
1632 assert(image != (Image *) NULL);
1633 assert(image->signature == MagickSignature);
1634 if (image->debug != MagickFalse)
1635 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1636 assert(target_image != (Image *) NULL);
1637 assert(target_image->signature == MagickSignature);
1638 assert(x_offset != (ssize_t *) NULL);
1639 assert(y_offset != (ssize_t *) NULL);
1640 assert(exception != (ExceptionInfo *) NULL);
1643 GetPixelInfo(image,&pixel);
1644 GetPixelInfo(image,&target);
1645 image_view=AcquireCacheView(image);
1646 target_view=AcquireCacheView(target_image);
1647 for (y=(*y_offset); y < (ssize_t) image->rows; y++)
1649 for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
1651 for (j=0; j < (ssize_t) target_image->rows; j++)
1653 for (i=0; i < (ssize_t) target_image->columns; i++)
1655 p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
1656 SetPixelInfo(image,p,&pixel);
1657 q=GetCacheViewVirtualPixels(target_view,i,j,1,1,exception);
1658 SetPixelInfo(image,q,&target);
1659 if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)
1662 if (i < (ssize_t) target_image->columns)
1665 if (j == (ssize_t) target_image->rows)
1668 if (x < (ssize_t) image->columns)
1670 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1675 proceed=SetImageProgress(image,SearchImageText,(MagickOffsetType) y,
1677 if (proceed == MagickFalse)
1681 target_view=DestroyCacheView(target_view);
1682 image_view=DestroyCacheView(image_view);
1685 if (status == MagickFalse)
1687 return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
1691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1695 % L i s t C o l o r I n f o %
1699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1701 % ListColorInfo() lists color names to the specified file. Color names
1702 % are a convenience. Rather than defining a color by its red, green, and
1703 % blue intensities just use a color name such as white, blue, or yellow.
1705 % The format of the ListColorInfo method is:
1707 % MagickBooleanType ListColorInfo(FILE *file,ExceptionInfo *exception)
1709 % A description of each parameter follows.
1711 % o file: List color names to this file handle.
1713 % o exception: return any errors or warnings in this structure.
1716 MagickExport MagickBooleanType ListColorInfo(FILE *file,
1717 ExceptionInfo *exception)
1720 tuple[MaxTextExtent];
1735 List name and attributes of each color in the list.
1737 if (file == (const FILE *) NULL)
1739 color_info=GetColorInfoList("*",&number_colors,exception);
1740 if (color_info == (const ColorInfo **) NULL)
1741 return(MagickFalse);
1742 path=(const char *) NULL;
1743 for (i=0; i < (ssize_t) number_colors; i++)
1745 if (color_info[i]->stealth != MagickFalse)
1747 if ((path == (const char *) NULL) ||
1748 (LocaleCompare(path,color_info[i]->path) != 0))
1750 if (color_info[i]->path != (char *) NULL)
1751 (void) FormatLocaleFile(file,"\nPath: %s\n\n",color_info[i]->path);
1752 (void) FormatLocaleFile(file,
1755 (void) FormatLocaleFile(file,
1756 "-------------------------------------------------"
1757 "------------------------------\n");
1759 path=color_info[i]->path;
1760 (void) FormatLocaleFile(file,"%-21.21s ",color_info[i]->name);
1761 GetColorTuple(&color_info[i]->color,MagickFalse,tuple);
1762 (void) FormatLocaleFile(file,"%-45.45s ",tuple);
1763 if ((color_info[i]->compliance & SVGCompliance) != 0)
1764 (void) FormatLocaleFile(file,"SVG ");
1765 if ((color_info[i]->compliance & X11Compliance) != 0)
1766 (void) FormatLocaleFile(file,"X11 ");
1767 if ((color_info[i]->compliance & XPMCompliance) != 0)
1768 (void) FormatLocaleFile(file,"XPM ");
1769 (void) FormatLocaleFile(file,"\n");
1771 color_info=(const ColorInfo **) RelinquishMagickMemory((void *) color_info);
1772 (void) fflush(file);
1777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1781 + L o a d C o l o r L i s t %
1785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1787 % LoadColorList() loads the color configuration file which provides a mapping
1788 % between color attributes and a color name.
1790 % The format of the LoadColorList method is:
1792 % MagickBooleanType LoadColorList(const char *xml,const char *filename,
1793 % const size_t depth,ExceptionInfo *exception)
1795 % A description of each parameter follows:
1797 % o xml: The color list in XML format.
1799 % o filename: The color list filename.
1801 % o depth: depth of <include /> statements.
1803 % o exception: return any errors or warnings in this structure.
1806 static MagickBooleanType LoadColorList(const char *xml,const char *filename,
1807 const size_t depth,ExceptionInfo *exception)
1810 keyword[MaxTextExtent],
1823 Load the color map file.
1825 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1826 "Loading color file \"%s\" ...",filename);
1827 if (xml == (char *) NULL)
1828 return(MagickFalse);
1829 if (color_list == (LinkedListInfo *) NULL)
1831 color_list=NewLinkedList(0);
1832 if (color_list == (LinkedListInfo *) NULL)
1834 ThrowFileException(exception,ResourceLimitError,
1835 "MemoryAllocationFailed",filename);
1836 return(MagickFalse);
1840 color_info=(ColorInfo *) NULL;
1841 token=AcquireString(xml);
1842 for (q=(char *) xml; *q != '\0'; )
1847 GetMagickToken(q,&q,token);
1850 (void) CopyMagickString(keyword,token,MaxTextExtent);
1851 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
1856 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
1857 GetMagickToken(q,&q,token);
1860 if (LocaleNCompare(keyword,"<!--",4) == 0)
1865 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
1866 GetMagickToken(q,&q,token);
1869 if (LocaleCompare(keyword,"<include") == 0)
1874 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
1876 (void) CopyMagickString(keyword,token,MaxTextExtent);
1877 GetMagickToken(q,&q,token);
1880 GetMagickToken(q,&q,token);
1881 if (LocaleCompare(keyword,"file") == 0)
1884 (void) ThrowMagickException(exception,GetMagickModule(),
1885 ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
1889 path[MaxTextExtent],
1892 GetPathComponent(filename,HeadPath,path);
1894 (void) ConcatenateMagickString(path,DirectorySeparator,
1896 if (*token == *DirectorySeparator)
1897 (void) CopyMagickString(path,token,MaxTextExtent);
1899 (void) ConcatenateMagickString(path,token,MaxTextExtent);
1900 xml=FileToString(path,~0,exception);
1901 if (xml != (char *) NULL)
1903 status=LoadColorList(xml,path,depth+1,exception);
1904 xml=(char *) RelinquishMagickMemory(xml);
1911 if (LocaleCompare(keyword,"<color") == 0)
1916 color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
1917 if (color_info == (ColorInfo *) NULL)
1918 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1919 (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
1920 color_info->path=ConstantString(filename);
1921 color_info->exempt=MagickFalse;
1922 color_info->signature=MagickSignature;
1925 if (color_info == (ColorInfo *) NULL)
1927 if (LocaleCompare(keyword,"/>") == 0)
1929 status=AppendValueToLinkedList(color_list,color_info);
1930 if (status == MagickFalse)
1931 (void) ThrowMagickException(exception,GetMagickModule(),
1932 ResourceLimitError,"MemoryAllocationFailed","`%s'",
1934 color_info=(ColorInfo *) NULL;
1936 GetMagickToken(q,(const char **) NULL,token);
1939 GetMagickToken(q,&q,token);
1940 GetMagickToken(q,&q,token);
1946 if (LocaleCompare((char *) keyword,"color") == 0)
1948 (void) QueryMagickColor(token,&color_info->color,exception);
1951 if (LocaleCompare((char *) keyword,"compliance") == 0)
1956 compliance=color_info->compliance;
1957 if (GlobExpression(token,"*SVG*",MagickTrue) != MagickFalse)
1958 compliance|=SVGCompliance;
1959 if (GlobExpression(token,"*X11*",MagickTrue) != MagickFalse)
1960 compliance|=X11Compliance;
1961 if (GlobExpression(token,"*XPM*",MagickTrue) != MagickFalse)
1962 compliance|=XPMCompliance;
1963 color_info->compliance=(ComplianceType) compliance;
1971 if (LocaleCompare((char *) keyword,"name") == 0)
1973 color_info->name=ConstantString(token);
1981 if (LocaleCompare((char *) keyword,"stealth") == 0)
1983 color_info->stealth=IsMagickTrue(token);
1992 token=(char *) RelinquishMagickMemory(token);
1997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2001 % L o a d C o l o r L i s t s %
2005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2007 % LoadColorList() loads one or more color configuration file which provides a
2008 % mapping between color attributes and a color name.
2010 % The format of the LoadColorLists method is:
2012 % MagickBooleanType LoadColorLists(const char *filename,
2013 % ExceptionInfo *exception)
2015 % A description of each parameter follows:
2017 % o filename: the font file name.
2019 % o exception: return any errors or warnings in this structure.
2022 static MagickBooleanType LoadColorLists(const char *filename,
2023 ExceptionInfo *exception)
2038 Load built-in color map.
2041 if (color_list == (LinkedListInfo *) NULL)
2043 color_list=NewLinkedList(0);
2044 if (color_list == (LinkedListInfo *) NULL)
2046 ThrowFileException(exception,ResourceLimitError,
2047 "MemoryAllocationFailed",filename);
2048 return(MagickFalse);
2051 for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
2056 register const ColorMapInfo
2060 color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
2061 if (color_info == (ColorInfo *) NULL)
2063 (void) ThrowMagickException(exception,GetMagickModule(),
2064 ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
2067 (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
2068 color_info->path=(char *) "[built-in]";
2069 color_info->name=(char *) p->name;
2070 GetPixelInfo((Image *) NULL,&color_info->color);
2071 color_info->color.red=(MagickRealType) ScaleCharToQuantum(p->red);
2072 color_info->color.green=(MagickRealType) ScaleCharToQuantum(p->green);
2073 color_info->color.blue=(MagickRealType) ScaleCharToQuantum(p->blue);
2074 color_info->color.alpha=(MagickRealType) (QuantumRange*p->alpha);
2075 color_info->compliance=(ComplianceType) p->compliance;
2076 color_info->exempt=MagickTrue;
2077 color_info->signature=MagickSignature;
2078 status=AppendValueToLinkedList(color_list,color_info);
2079 if (status == MagickFalse)
2080 (void) ThrowMagickException(exception,GetMagickModule(),
2081 ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
2084 Load external color map.
2086 options=GetConfigureOptions(filename,exception);
2087 option=(const StringInfo *) GetNextValueInLinkedList(options);
2088 while (option != (const StringInfo *) NULL)
2090 status|=LoadColorList((const char *) GetStringInfoDatum(option),
2091 GetStringInfoPath(option),0,exception);
2092 option=(const StringInfo *) GetNextValueInLinkedList(options);
2094 options=DestroyConfigureOptions(options);
2095 return(status != 0 ? MagickTrue : MagickFalse);
2099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2103 % Q u e r y C o l o r D a t a b a s e %
2107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2109 % QueryColorDatabase() returns the red, green, blue, and opacity intensities
2110 % for a given color name.
2112 % The format of the QueryColorDatabase method is:
2114 % MagickBooleanType QueryColorDatabase(const char *name,
2115 % const ComplianceType compliance,PixelPacket *color,
2116 % ExceptionInfo *exception)
2118 % A description of each parameter follows:
2120 % o name: the color name (e.g. white, blue, yellow).
2122 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2124 % o color: the red, green, blue, and opacity intensities values of the
2125 % named color in this structure.
2127 % o exception: return any errors or warnings in this structure.
2131 static inline double MagickMin(const double x,const double y)
2138 MagickExport MagickBooleanType QueryColorCompliance(const char *name,
2139 const ComplianceType compliance,PixelPacket *color,ExceptionInfo *exception)
2147 status=QueryMagickColorCompliance(name,compliance,&pixel,exception);
2148 color->alpha=ClampToQuantum(pixel.alpha);
2149 if (pixel.colorspace == CMYKColorspace)
2151 color->red=ClampToQuantum((MagickRealType)
2152 (QuantumRange-MagickMin(QuantumRange,(MagickRealType) (QuantumScale*
2153 pixel.red*(QuantumRange-pixel.black)+pixel.black))));
2154 color->green=ClampToQuantum((MagickRealType)
2155 (QuantumRange-MagickMin(QuantumRange,(MagickRealType) (QuantumScale*
2156 pixel.green*(QuantumRange-pixel.black)+pixel.black))));
2157 color->blue=ClampToQuantum((MagickRealType)
2158 (QuantumRange-MagickMin(QuantumRange,(MagickRealType) (QuantumScale*
2159 pixel.blue*(QuantumRange-pixel.black)+pixel.black))));
2160 color->black=ClampToQuantum((MagickRealType)
2161 (QuantumRange-MagickMin(QuantumRange,(MagickRealType) (QuantumScale*
2162 pixel.black*(QuantumRange-pixel.black)+pixel.black))));
2165 color->red=ClampToQuantum(pixel.red);
2166 color->green=ClampToQuantum(pixel.green);
2167 color->blue=ClampToQuantum(pixel.blue);
2172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2176 % Q u e r y C o l o r D a t a b a s e %
2180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2182 % QueryColorDatabase() returns the red, green, blue, and opacity intensities
2183 % for a given color name.
2185 % The format of the QueryColorDatabase method is:
2187 % MagickBooleanType QueryColorDatabase(const char *name,PixelPacket *color,
2188 % ExceptionInfo *exception)
2190 % A description of each parameter follows:
2192 % o name: the color name (e.g. white, blue, yellow).
2194 % o color: the red, green, blue, and opacity intensities values of the
2195 % named color in this structure.
2197 % o exception: return any errors or warnings in this structure.
2200 MagickExport MagickBooleanType QueryColorDatabase(const char *name,
2201 PixelPacket *color,ExceptionInfo *exception)
2203 return(QueryColorCompliance(name,AllCompliance,color,exception));
2207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2211 % Q u e r y C o l o r n a m e %
2215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2217 % QueryColorname() returns a named color for the given color intensity. If
2218 % an exact match is not found, a rgb() color is returned instead.
2220 % The format of the QueryColorname method is:
2222 % MagickBooleanType QueryColorname(const Image *image,
2223 % const PixelPacket *color,const ComplianceType compliance,char *name,
2224 % ExceptionInfo *exception)
2226 % A description of each parameter follows.
2228 % o image: the image.
2230 % o color: the color intensities.
2232 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2234 % o name: Return the color name or hex value.
2236 % o exception: return any errors or warnings in this structure.
2239 MagickExport MagickBooleanType QueryColorname(const Image *image,
2240 const PixelPacket *color,const ComplianceType compliance,char *name,
2241 ExceptionInfo *exception)
2246 GetPixelInfo(image,&pixel);
2247 SetPixelInfoPacket(image,color,&pixel);
2248 return(QueryMagickColorname(image,&pixel,compliance,name,exception));
2252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2256 % Q u e r y M a g i c k C o l o r C o m p l i a n c e %
2260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2262 % QueryMagickColorCompliance() returns the red, green, blue, and alpha
2263 % intensities for a given color name and standards compliance.
2265 % The format of the QueryMagickColor method is:
2267 % MagickBooleanType QueryMagickColor(const char *name,
2268 % const ComplianceType compliance,PixelInfo *color,
2269 % ExceptionInfo *exception)
2271 % A description of each parameter follows:
2273 % o name: the color name (e.g. white, blue, yellow).
2275 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2277 % o color: the red, green, blue, and opacity intensities values of the
2278 % named color in this structure.
2280 % o exception: return any errors or warnings in this structure.
2283 MagickExport MagickBooleanType QueryMagickColorCompliance(const char *name,
2284 const ComplianceType compliance,PixelInfo *color,
2285 ExceptionInfo *exception)
2296 register const ColorInfo
2306 Initialize color return value.
2308 assert(name != (const char *) NULL);
2309 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
2310 assert(color != (PixelInfo *) NULL);
2311 GetPixelInfo((Image *) NULL,color);
2312 if ((name == (char *) NULL) || (*name == '\0'))
2313 name=BackgroundColor;
2314 while (isspace((int) ((unsigned char) *name)) != 0)
2334 (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
2336 for (n=0; isxdigit((int) ((unsigned char) name[n])) != MagickFalse; n++) ;
2341 pixel.red=pixel.green;
2342 pixel.green=pixel.blue;
2344 for (i=(ssize_t) (n/3-1); i >= 0; i--)
2348 if ((c >= '0') && (c <= '9'))
2349 pixel.blue|=(int) (c-'0');
2351 if ((c >= 'A') && (c <= 'F'))
2352 pixel.blue|=(int) c-((int) 'A'-10);
2354 if ((c >= 'a') && (c <= 'f'))
2355 pixel.blue|=(int) c-((int) 'a'-10);
2357 return(MagickFalse);
2359 } while (isxdigit((int) ((unsigned char) *name)) != MagickFalse);
2366 (void) ThrowMagickException(exception,GetMagickModule(),
2367 OptionWarning,"UnrecognizedColor","`%s'",name);
2368 return(MagickFalse);
2372 pixel.red=pixel.green;
2373 pixel.green=pixel.blue;
2374 pixel.blue=pixel.alpha;
2376 for (i=(ssize_t) (n/4-1); i >= 0; i--)
2380 if ((c >= '0') && (c <= '9'))
2381 pixel.alpha|=(int) (c-'0');
2383 if ((c >= 'A') && (c <= 'F'))
2384 pixel.alpha|=(int) c-((int) 'A'-10);
2386 if ((c >= 'a') && (c <= 'f'))
2387 pixel.alpha|=(int) c-((int) 'a'-10);
2389 return(MagickFalse);
2391 } while (isxdigit((int) ((unsigned char) *name)) != MagickFalse);
2394 color->colorspace=RGBColorspace;
2395 color->matte=MagickFalse;
2396 range=GetQuantumRange(depth);
2397 color->red=(MagickRealType) ScaleAnyToQuantum(pixel.red,range);
2398 color->green=(MagickRealType) ScaleAnyToQuantum(pixel.green,range);
2399 color->blue=(MagickRealType) ScaleAnyToQuantum(pixel.blue,range);
2400 color->alpha=(MagickRealType) OpaqueAlpha;
2403 color->matte=MagickTrue;
2404 color->alpha=(MagickRealType) ScaleAnyToQuantum(pixel.alpha,range);
2409 if (strchr(name,'(') != (char *) NULL)
2412 colorspace[MaxTextExtent];
2415 Parse color of the form rgb(100,255,0).
2417 (void) CopyMagickString(colorspace,name,MaxTextExtent);
2418 for (i=0; colorspace[i] != '\0'; i++)
2419 if (colorspace[i] == '(')
2421 colorspace[i--]='\0';
2422 LocaleLower(colorspace);
2423 color->matte=MagickFalse;
2424 if ((i > 0) && (colorspace[i] == 'a'))
2427 color->matte=MagickTrue;
2429 type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace);
2432 (void) ThrowMagickException(exception,GetMagickModule(),
2433 OptionWarning,"UnrecognizedColor","`%s'",name);
2434 return(MagickFalse);
2436 color->colorspace=(ColorspaceType) type;
2437 SetGeometryInfo(&geometry_info);
2438 flags=ParseGeometry(name+i+1,&geometry_info);
2439 scale=(MagickRealType) ScaleCharToQuantum(1);
2440 if ((flags & PercentValue) != 0)
2441 scale=(MagickRealType) (QuantumRange/100.0);
2442 if ((flags & RhoValue) != 0)
2443 color->red=(MagickRealType) ClampToQuantum(scale*geometry_info.rho);
2444 if ((flags & SigmaValue) != 0)
2445 color->green=(MagickRealType) ClampToQuantum(scale*geometry_info.sigma);
2446 if ((flags & XiValue) != 0)
2447 color->blue=(MagickRealType) ClampToQuantum(scale*geometry_info.xi);
2448 color->alpha=(MagickRealType) OpaqueAlpha;
2449 if ((flags & PsiValue) != 0)
2451 if (color->colorspace == CMYKColorspace)
2452 color->black=(MagickRealType) ClampToQuantum(scale*
2455 if (color->matte != MagickFalse)
2456 color->alpha=(MagickRealType) ClampToQuantum((MagickRealType)
2457 QuantumRange*geometry_info.psi);
2459 if (((flags & ChiValue) != 0) && (color->matte != MagickFalse))
2460 color->alpha=(MagickRealType) ClampToQuantum((MagickRealType)
2461 QuantumRange*geometry_info.chi);
2462 if (LocaleCompare(colorspace,"gray") == 0)
2464 color->green=color->red;
2465 color->blue=color->red;
2466 if (((flags & SigmaValue) != 0) && (color->matte != MagickFalse))
2467 color->alpha=(MagickRealType) ClampToQuantum((MagickRealType)
2468 QuantumRange*geometry_info.sigma);
2470 if ((LocaleCompare(colorspace,"HSB") == 0) ||
2471 (LocaleCompare(colorspace,"HSL") == 0) ||
2472 (LocaleCompare(colorspace,"HWB") == 0))
2478 if ((flags & PercentValue) != 0)
2480 geometry_info.rho*=360.0*scale;
2482 if ((flags & PercentValue) != 0)
2484 geometry_info.sigma*=scale;
2485 geometry_info.xi*=scale;
2486 if (LocaleCompare(colorspace,"HSB") == 0)
2487 ConvertHSBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2488 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2489 &pixel.green,&pixel.blue);
2491 if (LocaleCompare(colorspace,"HSL") == 0)
2492 ConvertHSLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2493 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2494 &pixel.green,&pixel.blue);
2496 ConvertHWBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2497 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2498 &pixel.green,&pixel.blue);
2499 color->colorspace=RGBColorspace;
2500 color->red=(MagickRealType) pixel.red;
2501 color->green=(MagickRealType) pixel.green;
2502 color->blue=(MagickRealType) pixel.blue;
2509 p=GetColorCompliance(name,compliance,exception);
2510 if (p == (const ColorInfo *) NULL)
2511 return(MagickFalse);
2512 color->colorspace=RGBColorspace;
2513 color->matte=p->color.alpha != OpaqueAlpha ? MagickTrue : MagickFalse;
2514 color->red=(MagickRealType) p->color.red;
2515 color->green=(MagickRealType) p->color.green;
2516 color->blue=(MagickRealType) p->color.blue;
2517 color->alpha=(MagickRealType) p->color.alpha;
2523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2527 % Q u e r y M a g i c k C o l o r %
2531 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2533 % QueryMagickColor() returns the red, green, blue, and opacity intensities
2534 % for a given color name.
2536 % The format of the QueryMagickColor method is:
2538 % MagickBooleanType QueryMagickColor(const char *name,
2539 % PixelInfo *color,ExceptionInfo *exception)
2541 % A description of each parameter follows:
2543 % o name: the color name (e.g. white, blue, yellow).
2545 % o color: the red, green, blue, and opacity intensities values of the
2546 % named color in this structure.
2548 % o exception: return any errors or warnings in this structure.
2551 MagickExport MagickBooleanType QueryMagickColor(const char *name,
2552 PixelInfo *color,ExceptionInfo *exception)
2554 return(QueryMagickColorCompliance(name,AllCompliance,color,exception));
2558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2562 % Q u e r y M a g i c k C o l o r n a m e %
2566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2568 % QueryMagickColorname() returns a named color for the given color intensity.
2569 % If an exact match is not found, a hex value is returned instead. For
2570 % example an intensity of rgb:(0,0,0) returns black whereas rgb:(223,223,223)
2573 % The format of the QueryMagickColorname method is:
2575 % MagickBooleanType QueryMagickColorname(const Image *image,
2576 % const PixelPacket *color,const ComplianceType compliance,char *name,
2577 % ExceptionInfo *exception)
2579 % A description of each parameter follows.
2581 % o image: the image.
2583 % o color: the color intensities.
2585 % o Compliance: Adhere to this color standard: SVG, X11, or XPM.
2587 % o name: Return the color name or hex value.
2589 % o exception: return any errors or warnings in this structure.
2592 MagickExport MagickBooleanType QueryMagickColorname(const Image *image,
2593 const PixelInfo *color,const ComplianceType compliance,
2594 char *name,ExceptionInfo *exception)
2602 register const ColorInfo
2607 if (compliance == XPMCompliance)
2609 pixel.matte=MagickFalse;
2610 pixel.depth=(size_t) MagickMin(1.0*image->depth,16.0);
2612 GetColorTuple(&pixel,compliance != SVGCompliance ? MagickTrue : MagickFalse,
2614 (void) GetColorInfo("*",exception);
2615 ResetLinkedListIterator(color_list);
2616 opacity=image->matte != MagickFalse ? color->alpha : OpaqueAlpha;
2617 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
2618 while (p != (const ColorInfo *) NULL)
2620 if (((p->compliance & compliance) != 0) && ((p->color.red == color->red)) &&
2621 (p->color.green == color->green) && (p->color.blue == color->blue) &&
2622 (p->color.alpha == opacity))
2624 (void) CopyMagickString(name,p->name,MaxTextExtent);
2627 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);