2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 % CCCC OOO L OOO RRRR %
9 % CCCC OOO LLLLL OOO R R %
12 % MagickCore Color Methods %
19 % Copyright 1999-2010 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 "magick/studio.h"
44 #include "magick/blob.h"
45 #include "magick/cache-view.h"
46 #include "magick/cache.h"
47 #include "magick/color.h"
48 #include "magick/color-private.h"
49 #include "magick/client.h"
50 #include "magick/configure.h"
51 #include "magick/exception.h"
52 #include "magick/exception-private.h"
53 #include "magick/gem.h"
54 #include "magick/geometry.h"
55 #include "magick/image-private.h"
56 #include "magick/memory_.h"
57 #include "magick/monitor.h"
58 #include "magick/monitor-private.h"
59 #include "magick/option.h"
60 #include "magick/pixel-private.h"
61 #include "magick/quantize.h"
62 #include "magick/quantum.h"
63 #include "magick/semaphore.h"
64 #include "magick/string_.h"
65 #include "magick/token.h"
66 #include "magick/utility.h"
67 #include "magick/xml-tree.h"
72 #define ColorFilename "colors.xml"
77 typedef struct _ColorMapInfo
97 static const ColorMapInfo
100 { "none", 0, 0, 0, 0, SVGCompliance | XPMCompliance },
101 { "black", 0, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
102 { "red", 255, 0, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
103 { "magenta", 255, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
104 { "green", 0, 128, 0, 1, SVGCompliance },
105 { "cyan", 0, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
106 { "blue", 0, 0, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
107 { "yellow", 255, 255, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
108 { "white", 255, 255, 255, 1, SVGCompliance | X11Compliance },
109 { "AliceBlue", 240, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
110 { "AntiqueWhite", 250, 235, 215, 1, SVGCompliance | X11Compliance | XPMCompliance },
111 { "AntiqueWhite1", 255, 239, 219, 1, X11Compliance },
112 { "AntiqueWhite2", 238, 223, 204, 1, X11Compliance },
113 { "AntiqueWhite3", 205, 192, 176, 1, X11Compliance },
114 { "AntiqueWhite4", 139, 131, 120, 1, X11Compliance },
115 { "aqua", 0, 255, 255, 1, SVGCompliance },
116 { "aquamarine", 127, 255, 212, 1, SVGCompliance | X11Compliance | XPMCompliance },
117 { "aquamarine1", 127, 255, 212, 1, X11Compliance },
118 { "aquamarine2", 118, 238, 198, 1, X11Compliance },
119 { "aquamarine3", 102, 205, 170, 1, X11Compliance },
120 { "aquamarine4", 69, 139, 116, 1, X11Compliance },
121 { "azure", 240, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
122 { "azure1", 240, 255, 255, 1, X11Compliance },
123 { "azure2", 224, 238, 238, 1, X11Compliance },
124 { "azure3", 193, 205, 205, 1, X11Compliance },
125 { "azure4", 131, 139, 139, 1, X11Compliance },
126 { "beige", 245, 245, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
127 { "bisque", 255, 228, 196, 1, SVGCompliance | X11Compliance | XPMCompliance },
128 { "bisque1", 255, 228, 196, 1, X11Compliance },
129 { "bisque2", 238, 213, 183, 1, X11Compliance },
130 { "bisque3", 205, 183, 158, 1, X11Compliance },
131 { "bisque4", 139, 125, 107, 1, X11Compliance },
132 { "BlanchedAlmond", 255, 235, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
133 { "blue1", 0, 0, 255, 1, X11Compliance },
134 { "blue2", 0, 0, 238, 1, X11Compliance },
135 { "blue3", 0, 0, 205, 1, X11Compliance },
136 { "blue4", 0, 0, 139, 1, X11Compliance },
137 { "BlueViolet", 138, 43, 226, 1, SVGCompliance | X11Compliance | XPMCompliance },
138 { "brown", 165, 42, 42, 1, SVGCompliance | X11Compliance | XPMCompliance },
139 { "brown1", 255, 64, 64, 1, X11Compliance },
140 { "brown2", 238, 59, 59, 1, X11Compliance },
141 { "brown3", 205, 51, 51, 1, X11Compliance },
142 { "brown4", 139, 35, 35, 1, X11Compliance },
143 { "burlywood", 222, 184, 135, 1, SVGCompliance | X11Compliance | XPMCompliance },
144 { "burlywood1", 255, 211, 155, 1, X11Compliance },
145 { "burlywood2", 238, 197, 145, 1, X11Compliance },
146 { "burlywood3", 205, 170, 125, 1, X11Compliance },
147 { "burlywood4", 139, 115, 85, 1, X11Compliance },
148 { "cadet blue", 95, 158, 160, 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 { "dark violet", 148, 0, 211, 1, X11Compliance },
181 { "DarkBlue", 0, 0, 139, 1, SVGCompliance | X11Compliance },
182 { "DarkCyan", 0, 139, 139, 1, SVGCompliance | X11Compliance },
183 { "DarkGoldenrod", 184, 134, 11, 1, SVGCompliance | X11Compliance | XPMCompliance },
184 { "DarkGoldenrod1", 255, 185, 15, 1, X11Compliance },
185 { "DarkGoldenrod2", 238, 173, 14, 1, X11Compliance },
186 { "DarkGoldenrod3", 205, 149, 12, 1, X11Compliance },
187 { "DarkGoldenrod4", 139, 101, 8, 1, X11Compliance },
188 { "DarkGray", 169, 169, 169, 1, SVGCompliance | X11Compliance },
189 { "DarkGreen", 0, 100, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
190 { "DarkGrey", 169, 169, 169, 1, SVGCompliance | X11Compliance },
191 { "DarkKhaki", 189, 183, 107, 1, SVGCompliance | X11Compliance | XPMCompliance },
192 { "DarkMagenta", 139, 0, 139, 1, SVGCompliance | X11Compliance },
193 { "DarkOliveGreen", 85, 107, 47, 1, SVGCompliance | X11Compliance | XPMCompliance },
194 { "DarkOliveGreen1", 202, 255, 112, 1, X11Compliance },
195 { "DarkOliveGreen2", 188, 238, 104, 1, X11Compliance },
196 { "DarkOliveGreen3", 162, 205, 90, 1, X11Compliance },
197 { "DarkOliveGreen4", 110, 139, 61, 1, X11Compliance },
198 { "DarkOrange", 255, 140, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
199 { "DarkOrange1", 255, 127, 0, 1, X11Compliance },
200 { "DarkOrange2", 238, 118, 0, 1, X11Compliance },
201 { "DarkOrange3", 205, 102, 0, 1, X11Compliance },
202 { "DarkOrange4", 139, 69, 0, 1, X11Compliance },
203 { "DarkOrchid", 153, 50, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
204 { "DarkOrchid1", 191, 62, 255, 1, X11Compliance },
205 { "DarkOrchid2", 178, 58, 238, 1, X11Compliance },
206 { "DarkOrchid3", 154, 50, 205, 1, X11Compliance },
207 { "DarkOrchid4", 104, 34, 139, 1, X11Compliance },
208 { "DarkRed", 139, 0, 0, 1, SVGCompliance | X11Compliance },
209 { "DarkSalmon", 233, 150, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
210 { "DarkSeaGreen", 143, 188, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
211 { "DarkSeaGreen1", 193, 255, 193, 1, X11Compliance },
212 { "DarkSeaGreen2", 180, 238, 180, 1, X11Compliance },
213 { "DarkSeaGreen3", 155, 205, 155, 1, X11Compliance },
214 { "DarkSeaGreen4", 105, 139, 105, 1, X11Compliance },
215 { "DarkSlateBlue", 72, 61, 139, 1, SVGCompliance | X11Compliance | XPMCompliance },
216 { "DarkSlateGray", 47, 79, 79, 1, SVGCompliance | X11Compliance | XPMCompliance },
217 { "DarkSlateGray1", 151, 255, 255, 1, X11Compliance },
218 { "DarkSlateGray2", 141, 238, 238, 1, X11Compliance },
219 { "DarkSlateGray3", 121, 205, 205, 1, X11Compliance },
220 { "DarkSlateGray4", 82, 139, 139, 1, X11Compliance },
221 { "DarkSlateGrey", 47, 79, 79, 1, SVGCompliance | X11Compliance },
222 { "DarkTurquoise", 0, 206, 209, 1, SVGCompliance | X11Compliance | XPMCompliance },
223 { "DarkViolet", 148, 0, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
224 { "DeepPink", 255, 20, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
225 { "DeepPink1", 255, 20, 147, 1, X11Compliance },
226 { "DeepPink2", 238, 18, 137, 1, X11Compliance },
227 { "DeepPink3", 205, 16, 118, 1, X11Compliance },
228 { "DeepPink4", 139, 10, 80, 1, X11Compliance },
229 { "DeepSkyBlue", 0, 191, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
230 { "DeepSkyBlue1", 0, 191, 255, 1, X11Compliance },
231 { "DeepSkyBlue2", 0, 178, 238, 1, X11Compliance },
232 { "DeepSkyBlue3", 0, 154, 205, 1, X11Compliance },
233 { "DeepSkyBlue4", 0, 104, 139, 1, X11Compliance },
234 { "DimGray", 105, 105, 105, 1, SVGCompliance | X11Compliance | XPMCompliance },
235 { "DimGrey", 105, 105, 105, 1, SVGCompliance | X11Compliance },
236 { "DodgerBlue", 30, 144, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
237 { "DodgerBlue1", 30, 144, 255, 1, X11Compliance },
238 { "DodgerBlue2", 28, 134, 238, 1, X11Compliance },
239 { "DodgerBlue3", 24, 116, 205, 1, X11Compliance },
240 { "DodgerBlue4", 16, 78, 139, 1, X11Compliance },
241 { "firebrick", 178, 34, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
242 { "firebrick1", 255, 48, 48, 1, X11Compliance },
243 { "firebrick2", 238, 44, 44, 1, X11Compliance },
244 { "firebrick3", 205, 38, 38, 1, X11Compliance },
245 { "firebrick4", 139, 26, 26, 1, X11Compliance },
246 { "FloralWhite", 255, 250, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
247 { "ForestGreen", 34, 139, 34, 1, SVGCompliance | X11Compliance | XPMCompliance },
248 { "fractal", 128, 128, 128, 1, SVGCompliance },
249 { "freeze", 0, 0, 0, 0, SVGCompliance },
250 { "fuchsia", 255, 0, 255, 1, SVGCompliance },
251 { "gainsboro", 220, 220, 220, 1, SVGCompliance | X11Compliance | XPMCompliance },
252 { "GhostWhite", 248, 248, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
253 { "gold", 255, 215, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
254 { "gold1", 255, 215, 0, 1, X11Compliance },
255 { "gold2", 238, 201, 0, 1, X11Compliance },
256 { "gold3", 205, 173, 0, 1, X11Compliance },
257 { "gold4", 139, 117, 0, 1, X11Compliance },
258 { "goldenrod", 218, 165, 32, 1, SVGCompliance | X11Compliance | XPMCompliance },
259 { "goldenrod1", 255, 193, 37, 1, X11Compliance },
260 { "goldenrod2", 238, 180, 34, 1, X11Compliance },
261 { "goldenrod3", 205, 155, 29, 1, X11Compliance },
262 { "goldenrod4", 139, 105, 20, 1, X11Compliance },
263 { "gray", 126, 126, 126, 1, SVGCompliance },
264 { "gray", 190, 190, 190, 1, X11Compliance | XPMCompliance },
265 { "gray0", 0, 0, 0, 1, X11Compliance | XPMCompliance },
266 { "gray1", 3, 3, 3, 1, X11Compliance | XPMCompliance },
267 { "gray10", 26, 26, 26, 1, X11Compliance | XPMCompliance },
268 { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
269 { "gray100", 255, 255, 255, 1, X11Compliance | XPMCompliance },
270 { "gray11", 28, 28, 28, 1, X11Compliance | XPMCompliance },
271 { "gray12", 31, 31, 31, 1, X11Compliance | XPMCompliance },
272 { "gray13", 33, 33, 33, 1, X11Compliance | XPMCompliance },
273 { "gray14", 36, 36, 36, 1, X11Compliance | XPMCompliance },
274 { "gray15", 38, 38, 38, 1, X11Compliance | XPMCompliance },
275 { "gray16", 41, 41, 41, 1, X11Compliance | XPMCompliance },
276 { "gray17", 43, 43, 43, 1, X11Compliance | XPMCompliance },
277 { "gray18", 46, 46, 46, 1, X11Compliance | XPMCompliance },
278 { "gray19", 48, 48, 48, 1, X11Compliance | XPMCompliance },
279 { "gray2", 5, 5, 5, 1, X11Compliance | XPMCompliance },
280 { "gray20", 51, 51, 51, 1, X11Compliance | XPMCompliance },
281 { "gray21", 54, 54, 54, 1, X11Compliance | XPMCompliance },
282 { "gray22", 56, 56, 56, 1, X11Compliance | XPMCompliance },
283 { "gray23", 59, 59, 59, 1, X11Compliance | XPMCompliance },
284 { "gray24", 61, 61, 61, 1, X11Compliance | XPMCompliance },
285 { "gray25", 64, 64, 64, 1, X11Compliance | XPMCompliance },
286 { "gray26", 66, 66, 66, 1, X11Compliance | XPMCompliance },
287 { "gray27", 69, 69, 69, 1, X11Compliance | XPMCompliance },
288 { "gray28", 71, 71, 71, 1, X11Compliance | XPMCompliance },
289 { "gray29", 74, 74, 74, 1, X11Compliance | XPMCompliance },
290 { "gray3", 8, 8, 8, 1, X11Compliance | XPMCompliance },
291 { "gray30", 77, 77, 77, 1, X11Compliance | XPMCompliance },
292 { "gray31", 79, 79, 79, 1, X11Compliance | XPMCompliance },
293 { "gray32", 82, 82, 82, 1, X11Compliance | XPMCompliance },
294 { "gray33", 84, 84, 84, 1, X11Compliance | XPMCompliance },
295 { "gray34", 87, 87, 87, 1, X11Compliance | XPMCompliance },
296 { "gray35", 89, 89, 89, 1, X11Compliance | XPMCompliance },
297 { "gray36", 92, 92, 92, 1, X11Compliance | XPMCompliance },
298 { "gray37", 94, 94, 94, 1, X11Compliance | XPMCompliance },
299 { "gray38", 97, 97, 97, 1, X11Compliance | XPMCompliance },
300 { "gray39", 99, 99, 99, 1, X11Compliance | XPMCompliance },
301 { "gray4", 10, 10, 10, 1, X11Compliance | XPMCompliance },
302 { "gray40", 102, 102, 102, 1, X11Compliance | XPMCompliance },
303 { "gray41", 105, 105, 105, 1, X11Compliance | XPMCompliance },
304 { "gray42", 107, 107, 107, 1, X11Compliance | XPMCompliance },
305 { "gray43", 110, 110, 110, 1, X11Compliance | XPMCompliance },
306 { "gray44", 112, 112, 112, 1, X11Compliance | XPMCompliance },
307 { "gray45", 115, 115, 115, 1, X11Compliance | XPMCompliance },
308 { "gray46", 117, 117, 117, 1, X11Compliance | XPMCompliance },
309 { "gray47", 120, 120, 120, 1, X11Compliance | XPMCompliance },
310 { "gray48", 122, 122, 122, 1, X11Compliance | XPMCompliance },
311 { "gray49", 125, 125, 125, 1, X11Compliance | XPMCompliance },
312 { "gray5", 13, 13, 13, 1, X11Compliance | XPMCompliance },
313 { "gray50", 127, 127, 127, 1, X11Compliance | XPMCompliance },
314 { "gray51", 130, 130, 130, 1, X11Compliance | XPMCompliance },
315 { "gray52", 133, 133, 133, 1, X11Compliance | XPMCompliance },
316 { "gray53", 135, 135, 135, 1, X11Compliance | XPMCompliance },
317 { "gray54", 138, 138, 138, 1, X11Compliance | XPMCompliance },
318 { "gray55", 140, 140, 140, 1, X11Compliance | XPMCompliance },
319 { "gray56", 143, 143, 143, 1, X11Compliance | XPMCompliance },
320 { "gray57", 145, 145, 145, 1, X11Compliance | XPMCompliance },
321 { "gray58", 148, 148, 148, 1, X11Compliance | XPMCompliance },
322 { "gray59", 150, 150, 150, 1, X11Compliance | XPMCompliance },
323 { "gray6", 15, 15, 15, 1, X11Compliance | XPMCompliance },
324 { "gray60", 153, 153, 153, 1, X11Compliance | XPMCompliance },
325 { "gray61", 156, 156, 156, 1, X11Compliance | XPMCompliance },
326 { "gray62", 158, 158, 158, 1, X11Compliance | XPMCompliance },
327 { "gray63", 161, 161, 161, 1, X11Compliance | XPMCompliance },
328 { "gray64", 163, 163, 163, 1, X11Compliance | XPMCompliance },
329 { "gray65", 166, 166, 166, 1, X11Compliance | XPMCompliance },
330 { "gray66", 168, 168, 168, 1, X11Compliance | XPMCompliance },
331 { "gray67", 171, 171, 171, 1, X11Compliance | XPMCompliance },
332 { "gray68", 173, 173, 173, 1, X11Compliance | XPMCompliance },
333 { "gray69", 176, 176, 176, 1, X11Compliance | XPMCompliance },
334 { "gray7", 18, 18, 18, 1, X11Compliance | XPMCompliance },
335 { "gray70", 179, 179, 179, 1, X11Compliance | XPMCompliance },
336 { "gray71", 181, 181, 181, 1, X11Compliance | XPMCompliance },
337 { "gray72", 184, 184, 184, 1, X11Compliance | XPMCompliance },
338 { "gray73", 186, 186, 186, 1, X11Compliance | XPMCompliance },
339 { "gray74", 189, 189, 189, 1, X11Compliance | XPMCompliance },
340 { "gray75", 191, 191, 191, 1, X11Compliance | XPMCompliance },
341 { "gray76", 194, 194, 194, 1, X11Compliance | XPMCompliance },
342 { "gray77", 196, 196, 196, 1, X11Compliance | XPMCompliance },
343 { "gray78", 199, 199, 199, 1, X11Compliance | XPMCompliance },
344 { "gray79", 201, 201, 201, 1, X11Compliance | XPMCompliance },
345 { "gray8", 20, 20, 20, 1, X11Compliance | XPMCompliance },
346 { "gray80", 204, 204, 204, 1, X11Compliance | XPMCompliance },
347 { "gray81", 207, 207, 207, 1, X11Compliance | XPMCompliance },
348 { "gray82", 209, 209, 209, 1, X11Compliance | XPMCompliance },
349 { "gray83", 212, 212, 212, 1, X11Compliance | XPMCompliance },
350 { "gray84", 214, 214, 214, 1, X11Compliance | XPMCompliance },
351 { "gray85", 217, 217, 217, 1, X11Compliance | XPMCompliance },
352 { "gray86", 219, 219, 219, 1, X11Compliance | XPMCompliance },
353 { "gray87", 222, 222, 222, 1, X11Compliance | XPMCompliance },
354 { "gray88", 224, 224, 224, 1, X11Compliance | XPMCompliance },
355 { "gray89", 227, 227, 227, 1, X11Compliance | XPMCompliance },
356 { "gray9", 23, 23, 23, 1, X11Compliance | XPMCompliance },
357 { "gray90", 229, 229, 229, 1, X11Compliance | XPMCompliance },
358 { "gray91", 232, 232, 232, 1, X11Compliance | XPMCompliance },
359 { "gray92", 235, 235, 235, 1, X11Compliance | XPMCompliance },
360 { "gray93", 237, 237, 237, 1, X11Compliance | XPMCompliance },
361 { "gray94", 240, 240, 240, 1, X11Compliance | XPMCompliance },
362 { "gray95", 242, 242, 242, 1, X11Compliance | XPMCompliance },
363 { "gray96", 245, 245, 245, 1, X11Compliance | XPMCompliance },
364 { "gray97", 247, 247, 247, 1, X11Compliance | XPMCompliance },
365 { "gray98", 250, 250, 250, 1, X11Compliance | XPMCompliance },
366 { "gray99", 252, 252, 252, 1, X11Compliance | XPMCompliance },
367 { "green", 0, 255, 0, 1, X11Compliance | XPMCompliance },
368 { "green1", 0, 255, 0, 1, X11Compliance },
369 { "green2", 0, 238, 0, 1, X11Compliance },
370 { "green3", 0, 205, 0, 1, X11Compliance },
371 { "green4", 0, 139, 0, 1, X11Compliance },
372 { "GreenYellow", 173, 255, 47, 1, X11Compliance | XPMCompliance },
373 { "grey", 190, 190, 190, 1, SVGCompliance | X11Compliance },
374 { "grey0", 0, 0, 0, 1, SVGCompliance | X11Compliance },
375 { "grey1", 3, 3, 3, 1, SVGCompliance | X11Compliance },
376 { "grey10", 26, 26, 26, 1, SVGCompliance | X11Compliance },
377 { "grey100", 255, 255, 255, 1, SVGCompliance | X11Compliance },
378 { "grey11", 28, 28, 28, 1, SVGCompliance | X11Compliance },
379 { "grey12", 31, 31, 31, 1, SVGCompliance | X11Compliance },
380 { "grey13", 33, 33, 33, 1, SVGCompliance | X11Compliance },
381 { "grey14", 36, 36, 36, 1, SVGCompliance | X11Compliance },
382 { "grey15", 38, 38, 38, 1, SVGCompliance | X11Compliance },
383 { "grey16", 41, 41, 41, 1, SVGCompliance | X11Compliance },
384 { "grey17", 43, 43, 43, 1, SVGCompliance | X11Compliance },
385 { "grey18", 46, 46, 46, 1, SVGCompliance | X11Compliance },
386 { "grey19", 48, 48, 48, 1, SVGCompliance | X11Compliance },
387 { "grey2", 5, 5, 5, 1, SVGCompliance | X11Compliance },
388 { "grey20", 51, 51, 51, 1, SVGCompliance | X11Compliance },
389 { "grey21", 54, 54, 54, 1, SVGCompliance | X11Compliance },
390 { "grey22", 56, 56, 56, 1, SVGCompliance | X11Compliance },
391 { "grey23", 59, 59, 59, 1, SVGCompliance | X11Compliance },
392 { "grey24", 61, 61, 61, 1, SVGCompliance | X11Compliance },
393 { "grey25", 64, 64, 64, 1, SVGCompliance | X11Compliance },
394 { "grey26", 66, 66, 66, 1, SVGCompliance | X11Compliance },
395 { "grey27", 69, 69, 69, 1, SVGCompliance | X11Compliance },
396 { "grey28", 71, 71, 71, 1, SVGCompliance | X11Compliance },
397 { "grey29", 74, 74, 74, 1, SVGCompliance | X11Compliance },
398 { "grey3", 8, 8, 8, 1, SVGCompliance | X11Compliance },
399 { "grey30", 77, 77, 77, 1, SVGCompliance | X11Compliance },
400 { "grey31", 79, 79, 79, 1, SVGCompliance | X11Compliance },
401 { "grey32", 82, 82, 82, 1, SVGCompliance | X11Compliance },
402 { "grey33", 84, 84, 84, 1, SVGCompliance | X11Compliance },
403 { "grey34", 87, 87, 87, 1, SVGCompliance | X11Compliance },
404 { "grey35", 89, 89, 89, 1, SVGCompliance | X11Compliance },
405 { "grey36", 92, 92, 92, 1, SVGCompliance | X11Compliance },
406 { "grey37", 94, 94, 94, 1, SVGCompliance | X11Compliance },
407 { "grey38", 97, 97, 97, 1, SVGCompliance | X11Compliance },
408 { "grey39", 99, 99, 99, 1, SVGCompliance | X11Compliance },
409 { "grey4", 10, 10, 10, 1, SVGCompliance | X11Compliance },
410 { "grey40", 102, 102, 102, 1, SVGCompliance | X11Compliance },
411 { "grey41", 105, 105, 105, 1, SVGCompliance | X11Compliance },
412 { "grey42", 107, 107, 107, 1, SVGCompliance | X11Compliance },
413 { "grey43", 110, 110, 110, 1, SVGCompliance | X11Compliance },
414 { "grey44", 112, 112, 112, 1, SVGCompliance | X11Compliance },
415 { "grey45", 115, 115, 115, 1, SVGCompliance | X11Compliance },
416 { "grey46", 117, 117, 117, 1, SVGCompliance | X11Compliance },
417 { "grey47", 120, 120, 120, 1, SVGCompliance | X11Compliance },
418 { "grey48", 122, 122, 122, 1, SVGCompliance | X11Compliance },
419 { "grey49", 125, 125, 125, 1, SVGCompliance | X11Compliance },
420 { "grey5", 13, 13, 13, 1, SVGCompliance | X11Compliance },
421 { "grey50", 127, 127, 127, 1, SVGCompliance | X11Compliance },
422 { "grey51", 130, 130, 130, 1, SVGCompliance | X11Compliance },
423 { "grey52", 133, 133, 133, 1, SVGCompliance | X11Compliance },
424 { "grey53", 135, 135, 135, 1, SVGCompliance | X11Compliance },
425 { "grey54", 138, 138, 138, 1, SVGCompliance | X11Compliance },
426 { "grey55", 140, 140, 140, 1, SVGCompliance | X11Compliance },
427 { "grey56", 143, 143, 143, 1, SVGCompliance | X11Compliance },
428 { "grey57", 145, 145, 145, 1, SVGCompliance | X11Compliance },
429 { "grey58", 148, 148, 148, 1, SVGCompliance | X11Compliance },
430 { "grey59", 150, 150, 150, 1, SVGCompliance | X11Compliance },
431 { "grey6", 15, 15, 15, 1, SVGCompliance | X11Compliance },
432 { "grey60", 153, 153, 153, 1, SVGCompliance | X11Compliance },
433 { "grey61", 156, 156, 156, 1, SVGCompliance | X11Compliance },
434 { "grey62", 158, 158, 158, 1, SVGCompliance | X11Compliance },
435 { "grey63", 161, 161, 161, 1, SVGCompliance | X11Compliance },
436 { "grey64", 163, 163, 163, 1, SVGCompliance | X11Compliance },
437 { "grey65", 166, 166, 166, 1, SVGCompliance | X11Compliance },
438 { "grey66", 168, 168, 168, 1, SVGCompliance | X11Compliance },
439 { "grey67", 171, 171, 171, 1, SVGCompliance | X11Compliance },
440 { "grey68", 173, 173, 173, 1, SVGCompliance | X11Compliance },
441 { "grey69", 176, 176, 176, 1, SVGCompliance | X11Compliance },
442 { "grey7", 18, 18, 18, 1, SVGCompliance | X11Compliance },
443 { "grey70", 179, 179, 179, 1, SVGCompliance | X11Compliance },
444 { "grey71", 181, 181, 181, 1, SVGCompliance | X11Compliance },
445 { "grey72", 184, 184, 184, 1, SVGCompliance | X11Compliance },
446 { "grey73", 186, 186, 186, 1, SVGCompliance | X11Compliance },
447 { "grey74", 189, 189, 189, 1, SVGCompliance | X11Compliance },
448 { "grey75", 191, 191, 191, 1, SVGCompliance | X11Compliance },
449 { "grey76", 194, 194, 194, 1, SVGCompliance | X11Compliance },
450 { "grey77", 196, 196, 196, 1, SVGCompliance | X11Compliance },
451 { "grey78", 199, 199, 199, 1, SVGCompliance | X11Compliance },
452 { "grey79", 201, 201, 201, 1, SVGCompliance | X11Compliance },
453 { "grey8", 20, 20, 20, 1, SVGCompliance | X11Compliance },
454 { "grey80", 204, 204, 204, 1, SVGCompliance | X11Compliance },
455 { "grey81", 207, 207, 207, 1, SVGCompliance | X11Compliance },
456 { "grey82", 209, 209, 209, 1, SVGCompliance | X11Compliance },
457 { "grey83", 212, 212, 212, 1, SVGCompliance | X11Compliance },
458 { "grey84", 214, 214, 214, 1, SVGCompliance | X11Compliance },
459 { "grey85", 217, 217, 217, 1, SVGCompliance | X11Compliance },
460 { "grey86", 219, 219, 219, 1, SVGCompliance | X11Compliance },
461 { "grey87", 222, 222, 222, 1, SVGCompliance | X11Compliance },
462 { "grey88", 224, 224, 224, 1, SVGCompliance | X11Compliance },
463 { "grey89", 227, 227, 227, 1, SVGCompliance | X11Compliance },
464 { "grey9", 23, 23, 23, 1, SVGCompliance | X11Compliance },
465 { "grey90", 229, 229, 229, 1, SVGCompliance | X11Compliance },
466 { "grey91", 232, 232, 232, 1, SVGCompliance | X11Compliance },
467 { "grey92", 235, 235, 235, 1, SVGCompliance | X11Compliance },
468 { "grey93", 237, 237, 237, 1, SVGCompliance | X11Compliance },
469 { "grey94", 240, 240, 240, 1, SVGCompliance | X11Compliance },
470 { "grey95", 242, 242, 242, 1, SVGCompliance | X11Compliance },
471 { "grey96", 245, 245, 245, 1, SVGCompliance | X11Compliance },
472 { "grey97", 247, 247, 247, 1, SVGCompliance | X11Compliance },
473 { "grey98", 250, 250, 250, 1, SVGCompliance | X11Compliance },
474 { "grey99", 252, 252, 252, 1, SVGCompliance | X11Compliance },
475 { "honeydew", 240, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
476 { "honeydew1", 240, 255, 240, 1, X11Compliance },
477 { "honeydew2", 224, 238, 224, 1, X11Compliance },
478 { "honeydew3", 193, 205, 193, 1, X11Compliance },
479 { "honeydew4", 131, 139, 131, 1, X11Compliance },
480 { "HotPink", 255, 105, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
481 { "HotPink1", 255, 110, 180, 1, X11Compliance },
482 { "HotPink2", 238, 106, 167, 1, X11Compliance },
483 { "HotPink3", 205, 96, 144, 1, X11Compliance },
484 { "HotPink4", 139, 58, 98, 1, X11Compliance },
485 { "IndianRed", 205, 92, 92, 1, SVGCompliance | X11Compliance | XPMCompliance },
486 { "IndianRed1", 255, 106, 106, 1, X11Compliance },
487 { "IndianRed2", 238, 99, 99, 1, X11Compliance },
488 { "IndianRed3", 205, 85, 85, 1, X11Compliance },
489 { "IndianRed4", 139, 58, 58, 1, X11Compliance },
490 { "indigo", 75, 0, 130, 1, SVGCompliance },
491 { "ivory", 255, 255, 240, 1, SVGCompliance | X11Compliance | XPMCompliance },
492 { "ivory1", 255, 255, 240, 1, X11Compliance },
493 { "ivory2", 238, 238, 224, 1, X11Compliance },
494 { "ivory3", 205, 205, 193, 1, X11Compliance },
495 { "ivory4", 139, 139, 131, 1, X11Compliance },
496 { "khaki", 240, 230, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
497 { "khaki1", 255, 246, 143, 1, X11Compliance },
498 { "khaki2", 238, 230, 133, 1, X11Compliance },
499 { "khaki3", 205, 198, 115, 1, X11Compliance },
500 { "khaki4", 139, 134, 78, 1, X11Compliance },
501 { "lavender", 230, 230, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
502 { "LavenderBlush", 255, 240, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
503 { "LavenderBlush1", 255, 240, 245, 1, X11Compliance },
504 { "LavenderBlush2", 238, 224, 229, 1, X11Compliance },
505 { "LavenderBlush3", 205, 193, 197, 1, X11Compliance },
506 { "LavenderBlush4", 139, 131, 134, 1, X11Compliance },
507 { "LawnGreen", 124, 252, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
508 { "LemonChiffon", 255, 250, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
509 { "LemonChiffon1", 255, 250, 205, 1, X11Compliance },
510 { "LemonChiffon2", 238, 233, 191, 1, X11Compliance },
511 { "LemonChiffon3", 205, 201, 165, 1, X11Compliance },
512 { "LemonChiffon4", 139, 137, 112, 1, X11Compliance },
513 { "LightBlue", 173, 216, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
514 { "LightBlue1", 191, 239, 255, 1, X11Compliance },
515 { "LightBlue2", 178, 223, 238, 1, X11Compliance },
516 { "LightBlue3", 154, 192, 205, 1, X11Compliance },
517 { "LightBlue4", 104, 131, 139, 1, X11Compliance },
518 { "LightCoral", 240, 128, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
519 { "LightCyan", 224, 255, 255, 1, SVGCompliance | X11Compliance | XPMCompliance },
520 { "LightCyan1", 224, 255, 255, 1, X11Compliance },
521 { "LightCyan2", 209, 238, 238, 1, X11Compliance },
522 { "LightCyan3", 180, 205, 205, 1, X11Compliance },
523 { "LightCyan4", 122, 139, 139, 1, X11Compliance },
524 { "LightGoldenrod", 238, 221, 130, 1, X11Compliance | XPMCompliance },
525 { "LightGoldenrod1", 255, 236, 139, 1, X11Compliance },
526 { "LightGoldenrod2", 238, 220, 130, 1, X11Compliance },
527 { "LightGoldenrod3", 205, 190, 112, 1, X11Compliance },
528 { "LightGoldenrod4", 139, 129, 76, 1, X11Compliance },
529 { "LightGoldenrodYellow", 250, 250, 210, 1, SVGCompliance | X11Compliance | XPMCompliance },
530 { "LightGray", 211, 211, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
531 { "LightGreen", 144, 238, 144, 1, SVGCompliance | X11Compliance },
532 { "LightGrey", 211, 211, 211, 1, SVGCompliance | X11Compliance },
533 { "LightPink", 255, 182, 193, 1, SVGCompliance | X11Compliance | XPMCompliance },
534 { "LightPink1", 255, 174, 185, 1, X11Compliance },
535 { "LightPink2", 238, 162, 173, 1, X11Compliance },
536 { "LightPink3", 205, 140, 149, 1, X11Compliance },
537 { "LightPink4", 139, 95, 101, 1, X11Compliance },
538 { "LightSalmon", 255, 160, 122, 1, SVGCompliance | X11Compliance | XPMCompliance },
539 { "LightSalmon1", 255, 160, 122, 1, X11Compliance },
540 { "LightSalmon2", 238, 149, 114, 1, X11Compliance },
541 { "LightSalmon3", 205, 129, 98, 1, X11Compliance },
542 { "LightSalmon4", 139, 87, 66, 1, X11Compliance },
543 { "LightSeaGreen", 32, 178, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
544 { "LightSkyBlue", 135, 206, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
545 { "LightSkyBlue1", 176, 226, 255, 1, X11Compliance },
546 { "LightSkyBlue2", 164, 211, 238, 1, X11Compliance },
547 { "LightSkyBlue3", 141, 182, 205, 1, X11Compliance },
548 { "LightSkyBlue4", 96, 123, 139, 1, X11Compliance },
549 { "LightSlateBlue", 132, 112, 255, 1, X11Compliance | XPMCompliance },
550 { "LightSlateGray", 119, 136, 153, 1, SVGCompliance | X11Compliance | XPMCompliance },
551 { "LightSlateGrey", 119, 136, 153, 1, SVGCompliance | X11Compliance },
552 { "LightSteelBlue", 176, 196, 222, 1, SVGCompliance | X11Compliance | XPMCompliance },
553 { "LightSteelBlue1", 202, 225, 255, 1, X11Compliance },
554 { "LightSteelBlue2", 188, 210, 238, 1, X11Compliance },
555 { "LightSteelBlue3", 162, 181, 205, 1, X11Compliance },
556 { "LightSteelBlue4", 110, 123, 139, 1, X11Compliance },
557 { "LightYellow", 255, 255, 224, 1, SVGCompliance | X11Compliance | XPMCompliance },
558 { "LightYellow1", 255, 255, 224, 1, X11Compliance },
559 { "LightYellow2", 238, 238, 209, 1, X11Compliance },
560 { "LightYellow3", 205, 205, 180, 1, X11Compliance },
561 { "LightYellow4", 139, 139, 122, 1, X11Compliance },
562 { "lime", 0, 255, 0, 1, SVGCompliance },
563 { "LimeGreen", 50, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance },
564 { "linen", 250, 240, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
565 { "magenta1", 255, 0, 255, 1, X11Compliance },
566 { "magenta2", 238, 0, 238, 1, X11Compliance },
567 { "magenta3", 205, 0, 205, 1, X11Compliance },
568 { "magenta4", 139, 0, 139, 1, X11Compliance },
569 { "maroon", 128, 0, 0, 1, SVGCompliance },
570 { "maroon", 176, 48, 96, 1, X11Compliance | XPMCompliance },
571 { "maroon1", 255, 52, 179, 1, X11Compliance },
572 { "maroon2", 238, 48, 167, 1, X11Compliance },
573 { "maroon3", 205, 41, 144, 1, X11Compliance },
574 { "maroon4", 139, 28, 98, 1, X11Compliance },
575 { "MediumAquamarine", 102, 205, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
576 { "MediumBlue", 0, 0, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
577 { "MediumForestGreen", 50, 129, 75, 1, X11Compliance | XPMCompliance },
578 { "MediumGoldenRod", 209, 193, 102, 1, X11Compliance | XPMCompliance },
579 { "MediumOrchid", 186, 85, 211, 1, SVGCompliance | X11Compliance | XPMCompliance },
580 { "MediumOrchid1", 224, 102, 255, 1, X11Compliance },
581 { "MediumOrchid2", 209, 95, 238, 1, X11Compliance },
582 { "MediumOrchid3", 180, 82, 205, 1, X11Compliance },
583 { "MediumOrchid4", 122, 55, 139, 1, X11Compliance },
584 { "MediumPurple", 147, 112, 219, 1, SVGCompliance | X11Compliance | XPMCompliance },
585 { "MediumPurple1", 171, 130, 255, 1, X11Compliance },
586 { "MediumPurple2", 159, 121, 238, 1, X11Compliance },
587 { "MediumPurple3", 137, 104, 205, 1, X11Compliance },
588 { "MediumPurple4", 93, 71, 139, 1, X11Compliance },
589 { "MediumSeaGreen", 60, 179, 113, 1, SVGCompliance | X11Compliance | XPMCompliance },
590 { "MediumSlateBlue", 123, 104, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
591 { "MediumSpringGreen", 0, 250, 154, 1, SVGCompliance | X11Compliance | XPMCompliance },
592 { "MediumTurquoise", 72, 209, 204, 1, SVGCompliance | X11Compliance | XPMCompliance },
593 { "MediumVioletRed", 199, 21, 133, 1, SVGCompliance | X11Compliance | XPMCompliance },
594 { "MidnightBlue", 25, 25, 112, 1, SVGCompliance | X11Compliance | XPMCompliance },
595 { "MintCream", 245, 255, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
596 { "MistyRose", 255, 228, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
597 { "MistyRose1", 255, 228, 225, 1, X11Compliance },
598 { "MistyRose2", 238, 213, 210, 1, X11Compliance },
599 { "MistyRose3", 205, 183, 181, 1, X11Compliance },
600 { "MistyRose4", 139, 125, 123, 1, X11Compliance },
601 { "moccasin", 255, 228, 181, 1, SVGCompliance | X11Compliance | XPMCompliance },
602 { "NavajoWhite", 255, 222, 173, 1, SVGCompliance | X11Compliance | XPMCompliance },
603 { "NavajoWhite1", 255, 222, 173, 1, X11Compliance },
604 { "NavajoWhite2", 238, 207, 161, 1, X11Compliance },
605 { "NavajoWhite3", 205, 179, 139, 1, X11Compliance },
606 { "NavajoWhite4", 139, 121, 94, 1, X11Compliance },
607 { "navy", 0, 0, 128, 1, SVGCompliance | X11Compliance | XPMCompliance },
608 { "NavyBlue", 0, 0, 128, 1, X11Compliance | XPMCompliance },
609 { "matte", 0, 0, 0, 0, SVGCompliance },
610 { "OldLace", 253, 245, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
611 { "olive", 128, 128, 0, 1, SVGCompliance },
612 { "OliveDrab", 107, 142, 35, 1, SVGCompliance | X11Compliance | XPMCompliance },
613 { "OliveDrab1", 192, 255, 62, 1, X11Compliance },
614 { "OliveDrab2", 179, 238, 58, 1, X11Compliance },
615 { "OliveDrab3", 154, 205, 50, 1, X11Compliance },
616 { "OliveDrab4", 105, 139, 34, 1, X11Compliance },
617 { "opaque", 0, 0, 0, 1, SVGCompliance },
618 { "orange", 255, 165, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
619 { "orange1", 255, 165, 0, 1, X11Compliance },
620 { "orange2", 238, 154, 0, 1, X11Compliance },
621 { "orange3", 205, 133, 0, 1, X11Compliance },
622 { "orange4", 139, 90, 0, 1, X11Compliance },
623 { "OrangeRed", 255, 69, 0, 1, SVGCompliance | X11Compliance | XPMCompliance },
624 { "OrangeRed1", 255, 69, 0, 1, X11Compliance },
625 { "OrangeRed2", 238, 64, 0, 1, X11Compliance },
626 { "OrangeRed3", 205, 55, 0, 1, X11Compliance },
627 { "OrangeRed4", 139, 37, 0, 1, X11Compliance },
628 { "orchid", 218, 112, 214, 1, SVGCompliance | X11Compliance | XPMCompliance },
629 { "orchid1", 255, 131, 250, 1, X11Compliance },
630 { "orchid2", 238, 122, 233, 1, X11Compliance },
631 { "orchid3", 205, 105, 201, 1, X11Compliance },
632 { "orchid4", 139, 71, 137, 1, X11Compliance },
633 { "PaleGoldenrod", 238, 232, 170, 1, SVGCompliance | X11Compliance | XPMCompliance },
634 { "PaleGreen", 152, 251, 152, 1, SVGCompliance | X11Compliance | XPMCompliance },
635 { "PaleGreen1", 154, 255, 154, 1, X11Compliance },
636 { "PaleGreen2", 144, 238, 144, 1, X11Compliance },
637 { "PaleGreen3", 124, 205, 124, 1, X11Compliance },
638 { "PaleGreen4", 84, 139, 84, 1, X11Compliance },
639 { "PaleTurquoise", 175, 238, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
640 { "PaleTurquoise1", 187, 255, 255, 1, X11Compliance },
641 { "PaleTurquoise2", 174, 238, 238, 1, X11Compliance },
642 { "PaleTurquoise3", 150, 205, 205, 1, X11Compliance },
643 { "PaleTurquoise4", 102, 139, 139, 1, X11Compliance },
644 { "PaleVioletRed", 219, 112, 147, 1, SVGCompliance | X11Compliance | XPMCompliance },
645 { "PaleVioletRed1", 255, 130, 171, 1, X11Compliance },
646 { "PaleVioletRed2", 238, 121, 159, 1, X11Compliance },
647 { "PaleVioletRed3", 205, 104, 137, 1, X11Compliance },
648 { "PaleVioletRed4", 139, 71, 93, 1, X11Compliance },
649 { "PapayaWhip", 255, 239, 213, 1, SVGCompliance | X11Compliance | XPMCompliance },
650 { "PeachPuff", 255, 218, 185, 1, SVGCompliance | X11Compliance | XPMCompliance },
651 { "PeachPuff1", 255, 218, 185, 1, X11Compliance },
652 { "PeachPuff2", 238, 203, 173, 1, X11Compliance },
653 { "PeachPuff3", 205, 175, 149, 1, X11Compliance },
654 { "PeachPuff4", 139, 119, 101, 1, X11Compliance },
655 { "peru", 205, 133, 63, 1, SVGCompliance | X11Compliance | XPMCompliance },
656 { "pink", 255, 192, 203, 1, SVGCompliance | X11Compliance | XPMCompliance },
657 { "pink1", 255, 181, 197, 1, X11Compliance },
658 { "pink2", 238, 169, 184, 1, X11Compliance },
659 { "pink3", 205, 145, 158, 1, X11Compliance },
660 { "pink4", 139, 99, 108, 1, X11Compliance },
661 { "plum", 221, 160, 221, 1, SVGCompliance | X11Compliance | XPMCompliance },
662 { "plum1", 255, 187, 255, 1, X11Compliance },
663 { "plum2", 238, 174, 238, 1, X11Compliance },
664 { "plum3", 205, 150, 205, 1, X11Compliance },
665 { "plum4", 139, 102, 139, 1, X11Compliance },
666 { "PowderBlue", 176, 224, 230, 1, SVGCompliance | X11Compliance | XPMCompliance },
667 { "purple", 128, 0, 128, 1, SVGCompliance },
668 { "purple", 160, 32, 240, 1, X11Compliance | XPMCompliance },
669 { "purple1", 155, 48, 255, 1, X11Compliance },
670 { "purple2", 145, 44, 238, 1, X11Compliance },
671 { "purple3", 125, 38, 205, 1, X11Compliance },
672 { "purple4", 85, 26, 139, 1, X11Compliance },
673 { "red1", 255, 0, 0, 1, X11Compliance },
674 { "red2", 238, 0, 0, 1, X11Compliance },
675 { "red3", 205, 0, 0, 1, X11Compliance },
676 { "red4", 139, 0, 0, 1, X11Compliance },
677 { "RosyBrown", 188, 143, 143, 1, SVGCompliance | X11Compliance | XPMCompliance },
678 { "RosyBrown1", 255, 193, 193, 1, X11Compliance },
679 { "RosyBrown2", 238, 180, 180, 1, X11Compliance },
680 { "RosyBrown3", 205, 155, 155, 1, X11Compliance },
681 { "RosyBrown4", 139, 105, 105, 1, X11Compliance },
682 { "RoyalBlue", 65, 105, 225, 1, SVGCompliance | X11Compliance | XPMCompliance },
683 { "RoyalBlue1", 72, 118, 255, 1, X11Compliance },
684 { "RoyalBlue2", 67, 110, 238, 1, X11Compliance },
685 { "RoyalBlue3", 58, 95, 205, 1, X11Compliance },
686 { "RoyalBlue4", 39, 64, 139, 1, X11Compliance },
687 { "SaddleBrown", 139, 69, 19, 1, SVGCompliance | X11Compliance | XPMCompliance },
688 { "salmon", 250, 128, 114, 1, SVGCompliance | X11Compliance | XPMCompliance },
689 { "salmon1", 255, 140, 105, 1, X11Compliance },
690 { "salmon2", 238, 130, 98, 1, X11Compliance },
691 { "salmon3", 205, 112, 84, 1, X11Compliance },
692 { "salmon4", 139, 76, 57, 1, X11Compliance },
693 { "SandyBrown", 244, 164, 96, 1, SVGCompliance | X11Compliance | XPMCompliance },
694 { "SeaGreen", 46, 139, 87, 1, SVGCompliance | X11Compliance | XPMCompliance },
695 { "SeaGreen1", 84, 255, 159, 1, X11Compliance },
696 { "SeaGreen2", 78, 238, 148, 1, X11Compliance },
697 { "SeaGreen3", 67, 205, 128, 1, X11Compliance },
698 { "SeaGreen4", 46, 139, 87, 1, X11Compliance },
699 { "seashell", 255, 245, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
700 { "seashell1", 255, 245, 238, 1, X11Compliance },
701 { "seashell2", 238, 229, 222, 1, X11Compliance },
702 { "seashell3", 205, 197, 191, 1, X11Compliance },
703 { "seashell4", 139, 134, 130, 1, X11Compliance },
704 { "sienna", 160, 82, 45, 1, SVGCompliance | X11Compliance | XPMCompliance },
705 { "sienna1", 255, 130, 71, 1, X11Compliance },
706 { "sienna2", 238, 121, 66, 1, X11Compliance },
707 { "sienna3", 205, 104, 57, 1, X11Compliance },
708 { "sienna4", 139, 71, 38, 1, X11Compliance },
709 { "silver", 192, 192, 192, 1, SVGCompliance },
710 { "SkyBlue", 135, 206, 235, 1, SVGCompliance | X11Compliance | XPMCompliance },
711 { "SkyBlue1", 135, 206, 255, 1, X11Compliance },
712 { "SkyBlue2", 126, 192, 238, 1, X11Compliance },
713 { "SkyBlue3", 108, 166, 205, 1, X11Compliance },
714 { "SkyBlue4", 74, 112, 139, 1, X11Compliance },
715 { "SlateBlue", 106, 90, 205, 1, SVGCompliance | X11Compliance | XPMCompliance },
716 { "SlateBlue1", 131, 111, 255, 1, X11Compliance },
717 { "SlateBlue2", 122, 103, 238, 1, X11Compliance },
718 { "SlateBlue3", 105, 89, 205, 1, X11Compliance },
719 { "SlateBlue4", 71, 60, 139, 1, X11Compliance },
720 { "SlateGray", 112, 128, 144, 1, SVGCompliance | X11Compliance | XPMCompliance },
721 { "SlateGray1", 198, 226, 255, 1, X11Compliance },
722 { "SlateGray2", 185, 211, 238, 1, X11Compliance },
723 { "SlateGray3", 159, 182, 205, 1, X11Compliance },
724 { "SlateGray4", 108, 123, 139, 1, X11Compliance },
725 { "SlateGrey", 112, 128, 144, 1, SVGCompliance | X11Compliance },
726 { "snow", 255, 250, 250, 1, SVGCompliance | X11Compliance | XPMCompliance },
727 { "snow1", 255, 250, 250, 1, X11Compliance },
728 { "snow2", 238, 233, 233, 1, X11Compliance },
729 { "snow3", 205, 201, 201, 1, X11Compliance },
730 { "snow4", 139, 137, 137, 1, X11Compliance },
731 { "SpringGreen", 0, 255, 127, 1, SVGCompliance | X11Compliance | XPMCompliance },
732 { "SpringGreen1", 0, 255, 127, 1, X11Compliance },
733 { "SpringGreen2", 0, 238, 118, 1, X11Compliance },
734 { "SpringGreen3", 0, 205, 102, 1, X11Compliance },
735 { "SpringGreen4", 0, 139, 69, 1, X11Compliance },
736 { "SteelBlue", 70, 130, 180, 1, SVGCompliance | X11Compliance | XPMCompliance },
737 { "SteelBlue1", 99, 184, 255, 1, X11Compliance },
738 { "SteelBlue2", 92, 172, 238, 1, X11Compliance },
739 { "SteelBlue3", 79, 148, 205, 1, X11Compliance },
740 { "SteelBlue4", 54, 100, 139, 1, X11Compliance },
741 { "tan", 210, 180, 140, 1, SVGCompliance | X11Compliance | XPMCompliance },
742 { "tan1", 255, 165, 79, 1, X11Compliance },
743 { "tan2", 238, 154, 73, 1, X11Compliance },
744 { "tan3", 205, 133, 63, 1, X11Compliance },
745 { "tan4", 139, 90, 43, 1, X11Compliance },
746 { "teal", 0, 128, 128, 1, SVGCompliance },
747 { "thistle", 216, 191, 216, 1, SVGCompliance | X11Compliance | XPMCompliance },
748 { "thistle1", 255, 225, 255, 1, X11Compliance },
749 { "thistle2", 238, 210, 238, 1, X11Compliance },
750 { "thistle3", 205, 181, 205, 1, X11Compliance },
751 { "thistle4", 139, 123, 139, 1, X11Compliance },
752 { "tomato", 255, 99, 71, 1, SVGCompliance | X11Compliance | XPMCompliance },
753 { "tomato1", 255, 99, 71, 1, X11Compliance },
754 { "tomato2", 238, 92, 66, 1, X11Compliance },
755 { "tomato3", 205, 79, 57, 1, X11Compliance },
756 { "tomato4", 139, 54, 38, 1, X11Compliance },
757 { "transparent", 0, 0, 0, 0, SVGCompliance },
758 { "turquoise", 64, 224, 208, 1, SVGCompliance | X11Compliance | XPMCompliance },
759 { "turquoise1", 0, 245, 255, 1, X11Compliance },
760 { "turquoise2", 0, 229, 238, 1, X11Compliance },
761 { "turquoise3", 0, 197, 205, 1, X11Compliance },
762 { "turquoise4", 0, 134, 139, 1, X11Compliance },
763 { "violet", 238, 130, 238, 1, SVGCompliance | X11Compliance | XPMCompliance },
764 { "VioletRed", 208, 32, 144, 1, X11Compliance | XPMCompliance },
765 { "VioletRed1", 255, 62, 150, 1, X11Compliance },
766 { "VioletRed2", 238, 58, 140, 1, X11Compliance },
767 { "VioletRed3", 205, 50, 120, 1, X11Compliance },
768 { "VioletRed4", 139, 34, 82, 1, X11Compliance },
769 { "wheat", 245, 222, 179, 1, SVGCompliance | X11Compliance | XPMCompliance },
770 { "wheat1", 255, 231, 186, 1, X11Compliance },
771 { "wheat2", 238, 216, 174, 1, X11Compliance },
772 { "wheat3", 205, 186, 150, 1, X11Compliance },
773 { "wheat4", 139, 126, 102, 1, X11Compliance },
774 { "WhiteSmoke", 245, 245, 245, 1, SVGCompliance | X11Compliance | XPMCompliance },
775 { "yellow1", 255, 255, 0, 1, X11Compliance },
776 { "yellow2", 238, 238, 0, 1, X11Compliance },
777 { "yellow3", 205, 205, 0, 1, X11Compliance },
778 { "yellow4", 139, 139, 0, 1, X11Compliance },
779 { "YellowGreen", 154, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance }
785 static LinkedListInfo
786 *color_list = (LinkedListInfo *) NULL;
789 *color_semaphore = (SemaphoreInfo *) NULL;
791 static volatile MagickBooleanType
792 instantiate_color = MagickFalse;
795 Forward declarations.
797 static MagickBooleanType
798 InitializeColorList(ExceptionInfo *),
799 LoadColorLists(const char *,ExceptionInfo *);
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 + C o l o r C o m p o n e n t G e n e s i s %
810 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
812 % ColorComponentGenesis() instantiates the color component.
814 % The format of the ColorComponentGenesis method is:
816 % MagickBooleanType ColorComponentGenesis(void)
819 MagickExport MagickBooleanType ColorComponentGenesis(void)
821 AcquireSemaphoreInfo(&color_semaphore);
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 + C o l o r C o m p o n e n t T e r m i n u s %
834 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
836 % ColorComponentTerminus() destroys the color component.
838 % The format of the ColorComponentTerminus method is:
840 % ColorComponentTerminus(void)
844 static void *DestroyColorElement(void *color_info)
849 p=(ColorInfo *) color_info;
850 if (p->exempt == MagickFalse)
852 if (p->path != (char *) NULL)
853 p->path=DestroyString(p->path);
854 if (p->name != (char *) NULL)
855 p->name=DestroyString(p->name);
857 p=(ColorInfo *) RelinquishMagickMemory(p);
858 return((void *) NULL);
861 MagickExport void ColorComponentTerminus(void)
863 if (color_semaphore == (SemaphoreInfo *) NULL)
864 AcquireSemaphoreInfo(&color_semaphore);
865 LockSemaphoreInfo(color_semaphore);
866 if (color_list != (LinkedListInfo *) NULL)
867 color_list=DestroyLinkedList(color_list,DestroyColorElement);
868 instantiate_color=MagickFalse;
869 UnlockSemaphoreInfo(color_semaphore);
870 DestroySemaphoreInfo(&color_semaphore);
874 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
878 + G e t C o l o r C o m p l i a n c e %
882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 % GetColorInfo() searches the color list for the specified name and standards
885 % compliance and if found returns attributes for that color.
887 % The format of the GetColorInfo method is:
889 % const PixelPacket *GetColorInfo(const char *name,
890 % const ComplianceType compliance,ExceptionInfo *exception)
892 % A description of each parameter follows:
894 % o name: the color name.
896 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
898 % o exception: return any errors or warnings in this structure.
901 MagickExport const ColorInfo *GetColorCompliance(const char *name,
902 const ComplianceType compliance,ExceptionInfo *exception)
905 colorname[MaxTextExtent];
907 register const ColorInfo
913 assert(exception != (ExceptionInfo *) NULL);
914 if ((color_list == (LinkedListInfo *) NULL) ||
915 (instantiate_color == MagickFalse))
916 if (InitializeColorList(exception) == MagickFalse)
917 return((const ColorInfo *) NULL);
918 if ((color_list == (LinkedListInfo *) NULL) ||
919 (IsLinkedListEmpty(color_list) != MagickFalse))
920 return((const ColorInfo *) NULL);
921 if ((name == (const char *) NULL) || (LocaleCompare(name,"*") == 0))
922 return((const ColorInfo *) GetValueFromLinkedList(color_list,0));
924 Strip names of whitespace.
926 (void) CopyMagickString(colorname,name,MaxTextExtent);
927 for (q=colorname; *q != '\0'; q++)
929 if (isspace((int) ((unsigned char) *q)) == 0)
931 (void) CopyMagickString(q,q+1,MaxTextExtent);
935 Search for color tag.
937 LockSemaphoreInfo(color_semaphore);
938 ResetLinkedListIterator(color_list);
939 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
940 while (p != (const ColorInfo *) NULL)
942 if (((p->compliance & compliance) != 0) &&
943 (LocaleCompare(colorname,p->name) == 0))
945 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
947 if (p == (ColorInfo *) NULL)
948 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
949 "UnrecognizedColor","`%s'",name);
951 (void) InsertValueInLinkedList(color_list,0,
952 RemoveElementByValueFromLinkedList(color_list,p));
953 UnlockSemaphoreInfo(color_semaphore);
958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
962 + G e t C o l o r I n f o %
966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 % GetColorInfo() searches the color list for the specified name and if found
969 % returns attributes for that color.
971 % The format of the GetColorInfo method is:
973 % const PixelPacket *GetColorInfo(const char *name,
974 % ExceptionInfo *exception)
976 % A description of each parameter follows:
978 % o color_info: search the color list for the specified name and if found
979 % return attributes for that color.
981 % o name: the color name.
983 % o exception: return any errors or warnings in this structure.
986 MagickExport const ColorInfo *GetColorInfo(const char *name,
987 ExceptionInfo *exception)
989 return(GetColorCompliance(name,AllCompliance,exception));
993 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997 + 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 %
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1003 % ConcatenateColorComponent() returns the pixel as a canonical string.
1005 % The format of the ConcatenateColorComponent() method is:
1007 % void ConcatenateColorComponent(const MagickPixelPacket *pixel,
1008 % const ChannelType channel,const ComplianceType compliance,char *tuple)
1010 % A description of each parameter follows.
1012 % o pixel: The pixel.
1014 % channel: The channel.
1016 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
1018 % tuple: The color tuple.
1021 MagickExport void ConcatenateColorComponent(const MagickPixelPacket *pixel,
1022 const ChannelType channel,const ComplianceType compliance,char *tuple)
1025 component[MaxTextExtent];
1050 color=QuantumRange-pixel->opacity;
1061 if (compliance != SVGCompliance)
1063 if (pixel->depth > 16)
1065 (void) FormatMagickString(component,MaxTextExtent,"%10lu",
1066 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1067 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1070 if (pixel->depth > 8)
1072 (void) FormatMagickString(component,MaxTextExtent,"%5d",
1073 ScaleQuantumToShort(ClampToQuantum(color)));
1074 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1077 (void) FormatMagickString(component,MaxTextExtent,"%3d",
1078 ScaleQuantumToChar(ClampToQuantum(color)));
1079 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1082 if (channel == OpacityChannel)
1084 (void) FormatMagickString(component,MaxTextExtent,"%g",
1085 (double) (QuantumScale*color));
1086 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1089 if ((pixel->colorspace == HSLColorspace) ||
1090 (pixel->colorspace == HSBColorspace))
1092 (void) FormatMagickString(component,MaxTextExtent,"%g%%",
1093 (double) (100.0*QuantumScale*color));
1094 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1097 if (pixel->depth > 8)
1099 (void) FormatMagickString(component,MaxTextExtent,"%g%%",
1100 (double) (100.0*QuantumScale*color));
1101 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1104 (void) FormatMagickString(component,MaxTextExtent,"%d",
1105 ScaleQuantumToChar(ClampToQuantum(color)));
1106 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1114 % G e t C o l o r I n f o L i s t %
1118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1120 % GetColorInfoList() returns any colors that match the specified pattern.
1122 % The format of the GetColorInfoList function is:
1124 % const ColorInfo **GetColorInfoList(const char *pattern,
1125 % size_t *number_colors,ExceptionInfo *exception)
1127 % A description of each parameter follows:
1129 % o pattern: Specifies a pointer to a text string containing a pattern.
1131 % o number_colors: This integer returns the number of colors in the list.
1133 % o exception: return any errors or warnings in this structure.
1137 #if defined(__cplusplus) || defined(c_plusplus)
1141 static int ColorInfoCompare(const void *x,const void *y)
1147 p=(const ColorInfo **) x,
1148 q=(const ColorInfo **) y;
1149 if (LocaleCompare((*p)->path,(*q)->path) == 0)
1150 return(LocaleCompare((*p)->name,(*q)->name));
1151 return(LocaleCompare((*p)->path,(*q)->path));
1154 #if defined(__cplusplus) || defined(c_plusplus)
1158 MagickExport const ColorInfo **GetColorInfoList(const char *pattern,
1159 size_t *number_colors,ExceptionInfo *exception)
1164 register const ColorInfo
1171 Allocate color list.
1173 assert(pattern != (char *) NULL);
1174 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1175 assert(number_colors != (size_t *) NULL);
1177 p=GetColorInfo("*",exception);
1178 if (p == (const ColorInfo *) NULL)
1179 return((const ColorInfo **) NULL);
1180 colors=(const ColorInfo **) AcquireQuantumMemory((size_t)
1181 GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
1182 if (colors == (const ColorInfo **) NULL)
1183 return((const ColorInfo **) NULL);
1185 Generate color list.
1187 LockSemaphoreInfo(color_semaphore);
1188 ResetLinkedListIterator(color_list);
1189 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1190 for (i=0; p != (const ColorInfo *) NULL; )
1192 if ((p->stealth == MagickFalse) &&
1193 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1195 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1197 UnlockSemaphoreInfo(color_semaphore);
1198 qsort((void *) colors,(size_t) i,sizeof(*colors),ColorInfoCompare);
1199 colors[i]=(ColorInfo *) NULL;
1200 *number_colors=(size_t) i;
1205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1209 % G e t C o l o r L i s t %
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1215 % GetColorList() returns any colors that match the specified pattern.
1217 % The format of the GetColorList function is:
1219 % char **GetColorList(const char *pattern,size_t *number_colors,
1220 % ExceptionInfo *exception)
1222 % A description of each parameter follows:
1224 % o pattern: Specifies a pointer to a text string containing a pattern.
1226 % o number_colors: This integer returns the number of colors in the list.
1228 % o exception: return any errors or warnings in this structure.
1232 #if defined(__cplusplus) || defined(c_plusplus)
1236 static int ColorCompare(const void *x,const void *y)
1242 p=(const char **) x;
1243 q=(const char **) y;
1244 return(LocaleCompare(*p,*q));
1247 #if defined(__cplusplus) || defined(c_plusplus)
1251 MagickExport char **GetColorList(const char *pattern,
1252 size_t *number_colors,ExceptionInfo *exception)
1257 register const ColorInfo
1264 Allocate color list.
1266 assert(pattern != (char *) NULL);
1267 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",pattern);
1268 assert(number_colors != (size_t *) NULL);
1270 p=GetColorInfo("*",exception);
1271 if (p == (const ColorInfo *) NULL)
1272 return((char **) NULL);
1273 colors=(char **) AcquireQuantumMemory((size_t)
1274 GetNumberOfElementsInLinkedList(color_list)+1UL,sizeof(*colors));
1275 if (colors == (char **) NULL)
1276 return((char **) NULL);
1278 Generate color list.
1280 LockSemaphoreInfo(color_semaphore);
1281 ResetLinkedListIterator(color_list);
1282 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1283 for (i=0; p != (const ColorInfo *) NULL; )
1285 if ((p->stealth == MagickFalse) &&
1286 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
1287 colors[i++]=ConstantString(p->name);
1288 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
1290 UnlockSemaphoreInfo(color_semaphore);
1291 qsort((void *) colors,(size_t) i,sizeof(*colors),ColorCompare);
1292 colors[i]=(char *) NULL;
1293 *number_colors=(size_t) i;
1298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1302 + G e t C o l o r T u p l e %
1306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1308 % GetColorTuple() returns a color as a color tuple string (e.g. rgba(255,0,0))
1309 % or hex string (e.g. #FF0000).
1311 % The format of the GetColorTuple method is:
1313 % GetColorTuple(const MagickPixelPacket *pixel,const MagickBooleanType hex,
1316 % A description of each parameter follows.
1318 % o pixel: the pixel.
1320 % o hex: A value other than zero returns the tuple in a hexidecimal format.
1322 % o tuple: Return the color tuple as this string.
1326 static void ConcatentateHexColorComponent(const MagickPixelPacket *pixel,
1327 const ChannelType channel,char *tuple)
1330 component[MaxTextExtent];
1353 case OpacityChannel:
1355 color=(MagickRealType) QuantumRange-pixel->opacity;
1366 if (pixel->depth > 32)
1368 (void) FormatMagickString(component,MaxTextExtent,"%08lX%08lX",
1369 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)),
1370 (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));
1371 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1374 if (pixel->depth > 16)
1376 (void) FormatMagickString(component,MaxTextExtent,"%08X",
1377 (unsigned int) ScaleQuantumToLong(ClampToQuantum(color)));
1378 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1381 if (pixel->depth > 8)
1383 (void) FormatMagickString(component,MaxTextExtent,"%04X",
1384 ScaleQuantumToShort(ClampToQuantum(color)));
1385 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1388 (void) FormatMagickString(component,MaxTextExtent,"%02X",
1389 ScaleQuantumToChar(ClampToQuantum(color)));
1390 (void) ConcatenateMagickString(tuple,component,MaxTextExtent);
1394 MagickExport void GetColorTuple(const MagickPixelPacket *pixel,
1395 const MagickBooleanType hex,char *tuple)
1400 assert(pixel != (const MagickPixelPacket *) NULL);
1401 assert(tuple != (char *) NULL);
1402 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",tuple);
1404 if (hex != MagickFalse)
1407 Convert pixel to hex color.
1409 (void) ConcatenateMagickString(tuple,"#",MaxTextExtent);
1410 ConcatentateHexColorComponent(pixel,RedChannel,tuple);
1411 ConcatentateHexColorComponent(pixel,GreenChannel,tuple);
1412 ConcatentateHexColorComponent(pixel,BlueChannel,tuple);
1413 if (pixel->colorspace == CMYKColorspace)
1414 ConcatentateHexColorComponent(pixel,IndexChannel,tuple);
1415 if ((pixel->matte != MagickFalse) && (pixel->opacity != OpaqueOpacity))
1416 ConcatentateHexColorComponent(pixel,OpacityChannel,tuple);
1420 Convert pixel to rgb() or cmyk() color.
1423 if (color.depth > 8)
1425 #define SVGCompliant(component) ((MagickRealType) \
1426 ScaleCharToQuantum(ScaleQuantumToChar(ClampToQuantum(component))));
1432 SVG requires color depths > 8 expressed as percentages.
1434 status=color.red == SVGCompliant(color.red);
1435 status&=color.green == SVGCompliant(color.green);
1436 status&=color.blue == SVGCompliant(color.blue);
1437 if (color.colorspace != CMYKColorspace)
1438 status&=color.index == SVGCompliant(color.index);
1439 if (color.matte != MagickFalse)
1440 status&=color.opacity == SVGCompliant(color.opacity);
1441 if (status != MagickFalse)
1444 (void) ConcatenateMagickString(tuple,MagickOptionToMnemonic(
1445 MagickColorspaceOptions,(ssize_t) color.colorspace),MaxTextExtent);
1446 if (color.matte != MagickFalse)
1447 (void) ConcatenateMagickString(tuple,"a",MaxTextExtent);
1448 (void) ConcatenateMagickString(tuple,"(",MaxTextExtent);
1449 ConcatenateColorComponent(&color,RedChannel,SVGCompliance,tuple);
1450 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1451 ConcatenateColorComponent(&color,GreenChannel,SVGCompliance,tuple);
1452 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1453 ConcatenateColorComponent(&color,BlueChannel,SVGCompliance,tuple);
1454 if (color.colorspace == CMYKColorspace)
1456 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1457 ConcatenateColorComponent(&color,IndexChannel,SVGCompliance,tuple);
1459 if (color.matte != MagickFalse)
1461 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
1462 ConcatenateColorComponent(&color,AlphaChannel,SVGCompliance,tuple);
1464 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
1470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1474 + I n i t i a l i z e C o l o r L i s t %
1478 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1480 % InitializeColorList() initializes the color list.
1482 % The format of the InitializeColorList method is:
1484 % MagickBooleanType InitializeColorList(ExceptionInfo *exception)
1486 % A description of each parameter follows.
1488 % o exception: return any errors or warnings in this structure.
1491 static MagickBooleanType InitializeColorList(ExceptionInfo *exception)
1493 if ((color_list == (LinkedListInfo *) NULL) &&
1494 (instantiate_color == MagickFalse))
1496 if (color_semaphore == (SemaphoreInfo *) NULL)
1497 AcquireSemaphoreInfo(&color_semaphore);
1498 LockSemaphoreInfo(color_semaphore);
1499 if ((color_list == (LinkedListInfo *) NULL) &&
1500 (instantiate_color == MagickFalse))
1502 (void) LoadColorLists(ColorFilename,exception);
1503 instantiate_color=MagickTrue;
1505 UnlockSemaphoreInfo(color_semaphore);
1507 return(color_list != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
1511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1515 + I s C o l o r S i m i l a r %
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 % IsColorSimilar() returns MagickTrue if the distance between two colors is
1522 % less than the specified distance in a linear three dimensional color space.
1523 % This method is used by ColorFloodFill() and other algorithms which
1524 % compare two colors.
1526 % The format of the IsColorSimilar method is:
1528 % void IsColorSimilar(const Image *image,const PixelPacket *p,
1529 % const PixelPacket *q)
1531 % A description of each parameter follows:
1533 % o image: the image.
1541 static inline double MagickMax(const double x,const double y)
1548 MagickExport MagickBooleanType IsColorSimilar(const Image *image,
1549 const PixelPacket *p,const PixelPacket *q)
1555 register MagickRealType
1560 if ((image->fuzz == 0.0) && (image->matte == MagickFalse))
1561 return(IsColorEqual(p,q));
1562 fuzz=3.0*MagickMax(image->fuzz,MagickSQ1_2)*MagickMax(image->fuzz,
1566 if (image->matte != MagickFalse)
1568 alpha=(MagickRealType) (QuantumScale*(GetAlphaPixelComponent(p)));
1569 beta=(MagickRealType) (QuantumScale*GetAlphaPixelComponent(q));
1571 pixel=alpha*p->red-beta*q->red;
1572 distance=pixel*pixel;
1573 if (distance > fuzz)
1574 return(MagickFalse);
1575 pixel=alpha*p->green-beta*q->green;
1576 distance+=pixel*pixel;
1577 if (distance > fuzz)
1578 return(MagickFalse);
1579 pixel=alpha*p->blue-beta*q->blue;
1580 distance+=pixel*pixel;
1581 if (distance > fuzz)
1582 return(MagickFalse);
1587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1591 + I s I m a g e S i m i l a r %
1595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1597 % IsImageSimilar() returns true if the target is similar to a region of the
1600 % The format of the IsImageSimilar method is:
1602 % MagickBooleanType IsImageSimilar(const Image *image,
1603 % const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1604 % ExceptionInfo *exception)
1606 % A description of each parameter follows:
1608 % o image: the image.
1610 % o target_image: the target image.
1612 % o x_offset: On input the starting x position to search for a match;
1613 % on output the x position of the first match found.
1615 % o y_offset: On input the starting y position to search for a match;
1616 % on output the y position of the first match found.
1618 % o exception: return any errors or warnings in this structure.
1621 MagickExport MagickBooleanType IsImageSimilar(const Image *image,
1622 const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1623 ExceptionInfo *exception)
1625 #define SearchImageText " Searching image... "
1642 register const PixelPacket
1646 register const IndexPacket
1654 assert(image != (Image *) NULL);
1655 assert(image->signature == MagickSignature);
1656 if (image->debug != MagickFalse)
1657 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1658 assert(target_image != (Image *) NULL);
1659 assert(target_image->signature == MagickSignature);
1660 assert(x_offset != (ssize_t *) NULL);
1661 assert(y_offset != (ssize_t *) NULL);
1662 assert(exception != (ExceptionInfo *) NULL);
1664 GetMagickPixelPacket(image,&pixel);
1665 GetMagickPixelPacket(image,&target);
1666 image_view=AcquireCacheView(image);
1667 target_view=AcquireCacheView(target_image);
1668 for (y=(*y_offset); y < (ssize_t) image->rows; y++)
1670 for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
1672 for (j=0; j < (ssize_t) target_image->rows; j++)
1674 for (i=0; i < (ssize_t) target_image->columns; i++)
1676 p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
1677 indexes=GetCacheViewVirtualIndexQueue(image_view);
1678 SetMagickPixelPacket(image,p,indexes,&pixel);
1679 q=GetCacheViewVirtualPixels(target_view,i,j,1,1,exception);
1680 target_indexes=GetCacheViewVirtualIndexQueue(target_view);
1681 SetMagickPixelPacket(image,q,target_indexes,&target);
1682 if (IsMagickColorSimilar(&pixel,&target) == MagickFalse)
1685 if (i < (ssize_t) target_image->columns)
1688 if (j == (ssize_t) target_image->rows)
1691 if (x < (ssize_t) image->columns)
1693 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1698 proceed=SetImageProgress(image,SearchImageText,(MagickOffsetType) y,
1700 if (proceed == MagickFalse)
1704 target_view=DestroyCacheView(target_view);
1705 image_view=DestroyCacheView(image_view);
1708 return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
1712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1716 + I s M a g i c k C o l o r S i m i l a r %
1720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1722 % IsMagickColorSimilar() returns true if the distance between two colors is
1723 % less than the specified distance in a linear three dimensional color space.
1724 % This method is used by ColorFloodFill() and other algorithms which
1725 % compare two colors.
1727 % The format of the IsMagickColorSimilar method is:
1729 % MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p,
1730 % const MagickPixelPacket *q)
1732 % A description of each parameter follows:
1739 MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p,
1740 const MagickPixelPacket *q)
1746 register MagickRealType
1751 if ((p->fuzz == 0.0) && (q->fuzz == 0.0))
1752 return(IsMagickColorEqual(p,q));
1754 fuzz=MagickMax(q->fuzz,MagickSQ1_2)*MagickMax(q->fuzz,MagickSQ1_2);
1757 fuzz=3.0*MagickMax(p->fuzz,MagickSQ1_2)*MagickMax(p->fuzz,MagickSQ1_2);
1759 fuzz=3.0*MagickMax(p->fuzz,MagickSQ1_2)*MagickMax(q->fuzz,MagickSQ1_2);
1761 if (p->matte != MagickFalse)
1762 alpha=(MagickRealType) (QuantumScale*(GetAlphaPixelComponent(p)));
1764 if (q->matte != MagickFalse)
1765 beta=(MagickRealType) (QuantumScale*GetAlphaPixelComponent(q));
1766 if (p->colorspace == CMYKColorspace)
1768 alpha*=(MagickRealType) (QuantumScale*(QuantumRange-p->index));
1769 beta*=(MagickRealType) (QuantumScale*(QuantumRange-q->index));
1771 pixel=alpha*p->red-beta*q->red;
1772 if ((p->colorspace == HSLColorspace) || (p->colorspace == HSBColorspace) ||
1773 (p->colorspace == HWBColorspace))
1775 if (fabs(p->red-q->red) > (QuantumRange/2))
1777 if (p->red > (QuantumRange/2))
1778 pixel=alpha*(p->red-QuantumRange)-beta*q->red;
1780 pixel=alpha*p->red-beta*(q->red-QuantumRange);
1784 distance=pixel*pixel;
1785 if (distance > fuzz)
1786 return(MagickFalse);
1787 pixel=alpha*p->green-beta*q->green;
1788 distance+=pixel*pixel;
1789 if (distance > fuzz)
1790 return(MagickFalse);
1791 pixel=alpha*p->blue-beta*q->blue;
1792 distance+=pixel*pixel;
1793 if (distance > fuzz)
1794 return(MagickFalse);
1795 pixel=p->opacity-q->opacity;
1796 distance+=pixel*pixel;
1797 if (distance > fuzz)
1798 return(MagickFalse);
1803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1807 + I s O p a c i t y S i m i l a r %
1811 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1813 % IsOpacitySimilar() returns true if the distance between two opacity
1814 % values is less than the specified distance in a linear color space. This
1815 % method is used by MatteFloodFill() and other algorithms which compare
1816 % two opacity values.
1818 % The format of the IsOpacitySimilar method is:
1820 % void IsOpacitySimilar(const Image *image,const PixelPacket *p,
1821 % const PixelPacket *q)
1823 % A description of each parameter follows:
1825 % o image: the image.
1832 MagickExport MagickBooleanType IsOpacitySimilar(const Image *image,
1833 const PixelPacket *p,const PixelPacket *q)
1839 register MagickRealType
1842 if (image->matte == MagickFalse)
1844 if (p->opacity == q->opacity)
1846 fuzz=MagickMax(image->fuzz,MagickSQ1_2)*MagickMax(image->fuzz,MagickSQ1_2);
1847 pixel=(MagickRealType) p->opacity-(MagickRealType) q->opacity;
1848 distance=pixel*pixel;
1849 if (distance > fuzz)
1850 return(MagickFalse);
1855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1859 % L i s t C o l o r I n f o %
1863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1865 % ListColorInfo() lists color names to the specified file. Color names
1866 % are a convenience. Rather than defining a color by its red, green, and
1867 % blue intensities just use a color name such as white, blue, or yellow.
1869 % The format of the ListColorInfo method is:
1871 % MagickBooleanType ListColorInfo(FILE *file,ExceptionInfo *exception)
1873 % A description of each parameter follows.
1875 % o file: List color names to this file handle.
1877 % o exception: return any errors or warnings in this structure.
1880 MagickExport MagickBooleanType ListColorInfo(FILE *file,
1881 ExceptionInfo *exception)
1884 tuple[MaxTextExtent];
1899 List name and attributes of each color in the list.
1901 if (file == (const FILE *) NULL)
1903 color_info=GetColorInfoList("*",&number_colors,exception);
1904 if (color_info == (const ColorInfo **) NULL)
1905 return(MagickFalse);
1906 path=(const char *) NULL;
1907 for (i=0; i < (ssize_t) number_colors; i++)
1909 if (color_info[i]->stealth != MagickFalse)
1911 if ((path == (const char *) NULL) ||
1912 (LocaleCompare(path,color_info[i]->path) != 0))
1914 if (color_info[i]->path != (char *) NULL)
1915 (void) fprintf(file,"\nPath: %s\n\n",color_info[i]->path);
1916 (void) fprintf(file,"Name Color "
1918 (void) fprintf(file,"-------------------------------------------------"
1919 "------------------------------\n");
1921 path=color_info[i]->path;
1922 (void) fprintf(file,"%-21.21s ",color_info[i]->name);
1923 GetColorTuple(&color_info[i]->color,MagickFalse,tuple);
1924 (void) fprintf(file,"%-45.45s ",tuple);
1925 if ((color_info[i]->compliance & SVGCompliance) != 0)
1926 (void) fprintf(file,"SVG ");
1927 if ((color_info[i]->compliance & X11Compliance) != 0)
1928 (void) fprintf(file,"X11 ");
1929 if ((color_info[i]->compliance & XPMCompliance) != 0)
1930 (void) fprintf(file,"XPM ");
1931 (void) fprintf(file,"\n");
1933 color_info=(const ColorInfo **) RelinquishMagickMemory((void *) color_info);
1934 (void) fflush(file);
1939 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1943 + L o a d C o l o r L i s t %
1947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1949 % LoadColorList() loads the color configuration file which provides a mapping
1950 % between color attributes and a color name.
1952 % The format of the LoadColorList method is:
1954 % MagickBooleanType LoadColorList(const char *xml,const char *filename,
1955 % const size_t depth,ExceptionInfo *exception)
1957 % A description of each parameter follows:
1959 % o xml: The color list in XML format.
1961 % o filename: The color list filename.
1963 % o depth: depth of <include /> statements.
1965 % o exception: return any errors or warnings in this structure.
1968 static MagickBooleanType LoadColorList(const char *xml,const char *filename,
1969 const size_t depth,ExceptionInfo *exception)
1972 keyword[MaxTextExtent],
1985 Load the color map file.
1987 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1988 "Loading color file \"%s\" ...",filename);
1989 if (xml == (char *) NULL)
1990 return(MagickFalse);
1991 if (color_list == (LinkedListInfo *) NULL)
1993 color_list=NewLinkedList(0);
1994 if (color_list == (LinkedListInfo *) NULL)
1996 ThrowFileException(exception,ResourceLimitError,
1997 "MemoryAllocationFailed",filename);
1998 return(MagickFalse);
2002 color_info=(ColorInfo *) NULL;
2003 token=AcquireString(xml);
2004 for (q=(char *) xml; *q != '\0'; )
2009 GetMagickToken(q,&q,token);
2012 (void) CopyMagickString(keyword,token,MaxTextExtent);
2013 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
2018 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
2019 GetMagickToken(q,&q,token);
2022 if (LocaleNCompare(keyword,"<!--",4) == 0)
2027 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
2028 GetMagickToken(q,&q,token);
2031 if (LocaleCompare(keyword,"<include") == 0)
2036 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
2038 (void) CopyMagickString(keyword,token,MaxTextExtent);
2039 GetMagickToken(q,&q,token);
2042 GetMagickToken(q,&q,token);
2043 if (LocaleCompare(keyword,"file") == 0)
2046 (void) ThrowMagickException(exception,GetMagickModule(),
2047 ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
2051 path[MaxTextExtent],
2054 GetPathComponent(filename,HeadPath,path);
2056 (void) ConcatenateMagickString(path,DirectorySeparator,
2058 if (*token == *DirectorySeparator)
2059 (void) CopyMagickString(path,token,MaxTextExtent);
2061 (void) ConcatenateMagickString(path,token,MaxTextExtent);
2062 xml=FileToString(path,~0,exception);
2063 if (xml != (char *) NULL)
2065 status=LoadColorList(xml,path,depth+1,exception);
2066 xml=(char *) RelinquishMagickMemory(xml);
2073 if (LocaleCompare(keyword,"<color") == 0)
2078 color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
2079 if (color_info == (ColorInfo *) NULL)
2080 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2081 (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
2082 color_info->path=ConstantString(filename);
2083 color_info->exempt=MagickFalse;
2084 color_info->signature=MagickSignature;
2087 if (color_info == (ColorInfo *) NULL)
2089 if (LocaleCompare(keyword,"/>") == 0)
2091 status=AppendValueToLinkedList(color_list,color_info);
2092 if (status == MagickFalse)
2093 (void) ThrowMagickException(exception,GetMagickModule(),
2094 ResourceLimitError,"MemoryAllocationFailed","`%s'",
2096 color_info=(ColorInfo *) NULL;
2098 GetMagickToken(q,(const char **) NULL,token);
2101 GetMagickToken(q,&q,token);
2102 GetMagickToken(q,&q,token);
2108 if (LocaleCompare((char *) keyword,"color") == 0)
2110 (void) QueryMagickColor(token,&color_info->color,exception);
2113 if (LocaleCompare((char *) keyword,"compliance") == 0)
2118 compliance=color_info->compliance;
2119 if (GlobExpression(token,"*SVG*",MagickTrue) != MagickFalse)
2120 compliance|=SVGCompliance;
2121 if (GlobExpression(token,"*X11*",MagickTrue) != MagickFalse)
2122 compliance|=X11Compliance;
2123 if (GlobExpression(token,"*XPM*",MagickTrue) != MagickFalse)
2124 compliance|=XPMCompliance;
2125 color_info->compliance=(ComplianceType) compliance;
2133 if (LocaleCompare((char *) keyword,"name") == 0)
2135 color_info->name=ConstantString(token);
2143 if (LocaleCompare((char *) keyword,"stealth") == 0)
2145 color_info->stealth=IsMagickTrue(token);
2154 token=(char *) RelinquishMagickMemory(token);
2159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2163 % L o a d C o l o r L i s t s %
2167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2169 % LoadColorList() loads one or more color configuration file which provides a
2170 % mapping between color attributes and a color name.
2172 % The format of the LoadColorLists method is:
2174 % MagickBooleanType LoadColorLists(const char *filename,
2175 % ExceptionInfo *exception)
2177 % A description of each parameter follows:
2179 % o filename: the font file name.
2181 % o exception: return any errors or warnings in this structure.
2184 static MagickBooleanType LoadColorLists(const char *filename,
2185 ExceptionInfo *exception)
2200 Load built-in color map.
2203 if (color_list == (LinkedListInfo *) NULL)
2205 color_list=NewLinkedList(0);
2206 if (color_list == (LinkedListInfo *) NULL)
2208 ThrowFileException(exception,ResourceLimitError,
2209 "MemoryAllocationFailed",filename);
2210 return(MagickFalse);
2213 for (i=0; i < (ssize_t) (sizeof(ColorMap)/sizeof(*ColorMap)); i++)
2218 register const ColorMapInfo
2222 color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
2223 if (color_info == (ColorInfo *) NULL)
2225 (void) ThrowMagickException(exception,GetMagickModule(),
2226 ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
2229 (void) ResetMagickMemory(color_info,0,sizeof(*color_info));
2230 color_info->path=(char *) "[built-in]";
2231 color_info->name=(char *) p->name;
2232 GetMagickPixelPacket((Image *) NULL,&color_info->color);
2233 color_info->color.red=(MagickRealType) ScaleCharToQuantum(
2234 GetRedPixelComponent(p));
2235 color_info->color.green=(MagickRealType) ScaleCharToQuantum(
2236 GetGreenPixelComponent(p));
2237 color_info->color.blue=(MagickRealType) ScaleCharToQuantum(
2238 GetBluePixelComponent(p));
2239 color_info->color.opacity=(MagickRealType) (QuantumRange-QuantumRange*
2241 color_info->compliance=(ComplianceType) p->compliance;
2242 color_info->exempt=MagickTrue;
2243 color_info->signature=MagickSignature;
2244 status=AppendValueToLinkedList(color_list,color_info);
2245 if (status == MagickFalse)
2246 (void) ThrowMagickException(exception,GetMagickModule(),
2247 ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
2250 Load external color map.
2252 options=GetConfigureOptions(filename,exception);
2253 option=(const StringInfo *) GetNextValueInLinkedList(options);
2254 while (option != (const StringInfo *) NULL)
2256 status|=LoadColorList((const char *) GetStringInfoDatum(option),
2257 GetStringInfoPath(option),0,exception);
2258 option=(const StringInfo *) GetNextValueInLinkedList(options);
2260 options=DestroyConfigureOptions(options);
2261 return(status != 0 ? MagickTrue : MagickFalse);
2265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2269 % Q u e r y C o l o r D a t a b a s e %
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2275 % QueryColorDatabase() returns the red, green, blue, and opacity intensities
2276 % for a given color name.
2278 % The format of the QueryColorDatabase method is:
2280 % MagickBooleanType QueryColorDatabase(const char *name,
2281 % const ComplianceType compliance,PixelPacket *color,
2282 % ExceptionInfo *exception)
2284 % A description of each parameter follows:
2286 % o name: the color name (e.g. white, blue, yellow).
2288 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2290 % o color: the red, green, blue, and opacity intensities values of the
2291 % named color in this structure.
2293 % o exception: return any errors or warnings in this structure.
2297 static inline double MagickMin(const double x,const double y)
2304 MagickExport MagickBooleanType QueryColorCompliance(const char *name,
2305 const ComplianceType compliance,PixelPacket *color,ExceptionInfo *exception)
2313 status=QueryMagickColorCompliance(name,compliance,&pixel,exception);
2314 color->opacity=ClampToQuantum(pixel.opacity);
2315 if (pixel.colorspace == CMYKColorspace)
2317 color->red=ClampToQuantum((MagickRealType) (QuantumRange-MagickMin(
2318 QuantumRange,(MagickRealType) (QuantumScale*pixel.red*(QuantumRange-
2319 pixel.index)+pixel.index))));
2320 color->green=ClampToQuantum((MagickRealType) (QuantumRange-MagickMin(
2321 QuantumRange,(MagickRealType) (QuantumScale*pixel.green*(QuantumRange-
2322 pixel.index)+pixel.index))));
2323 color->blue=ClampToQuantum((MagickRealType) (QuantumRange-MagickMin(
2324 QuantumRange,(MagickRealType) (QuantumScale*pixel.blue*(QuantumRange-
2325 pixel.index)+pixel.index))));
2328 color->red=ClampToQuantum(pixel.red);
2329 color->green=ClampToQuantum(pixel.green);
2330 color->blue=ClampToQuantum(pixel.blue);
2335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2339 % Q u e r y C o l o r D a t a b a s e %
2343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2345 % QueryColorDatabase() returns the red, green, blue, and opacity intensities
2346 % for a given color name.
2348 % The format of the QueryColorDatabase method is:
2350 % MagickBooleanType QueryColorDatabase(const char *name,PixelPacket *color,
2351 % ExceptionInfo *exception)
2353 % A description of each parameter follows:
2355 % o name: the color name (e.g. white, blue, yellow).
2357 % o color: the red, green, blue, and opacity intensities values of the
2358 % named color in this structure.
2360 % o exception: return any errors or warnings in this structure.
2363 MagickExport MagickBooleanType QueryColorDatabase(const char *name,
2364 PixelPacket *color,ExceptionInfo *exception)
2366 return(QueryColorCompliance(name,AllCompliance,color,exception));
2370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2374 % Q u e r y C o l o r n a m e %
2378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2380 % QueryColorname() returns a named color for the given color intensity. If
2381 % an exact match is not found, a rgb() color is returned instead.
2383 % The format of the QueryColorname method is:
2385 % MagickBooleanType QueryColorname(const Image *image,
2386 % const PixelPacket *color,const ComplianceType compliance,char *name,
2387 % ExceptionInfo *exception)
2389 % A description of each parameter follows.
2391 % o image: the image.
2393 % o color: the color intensities.
2395 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2397 % o name: Return the color name or hex value.
2399 % o exception: return any errors or warnings in this structure.
2402 MagickExport MagickBooleanType QueryColorname(const Image *image,
2403 const PixelPacket *color,const ComplianceType compliance,char *name,
2404 ExceptionInfo *exception)
2409 GetMagickPixelPacket(image,&pixel);
2410 SetMagickPixelPacket(image,color,(IndexPacket *) NULL,&pixel);
2411 return(QueryMagickColorname(image,&pixel,compliance,name,exception));
2415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2419 % 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 %
2423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2425 % QueryMagickColorCompliance() returns the red, green, blue, and opacity
2426 % intensities for a given color name and standards compliance.
2428 % The format of the QueryMagickColor method is:
2430 % MagickBooleanType QueryMagickColor(const char *name,
2431 % const ComplianceType compliance,MagickPixelPacket *color,
2432 % ExceptionInfo *exception)
2434 % A description of each parameter follows:
2436 % o name: the color name (e.g. white, blue, yellow).
2438 % o compliance: Adhere to this color standard: SVG, X11, or XPM.
2440 % o color: the red, green, blue, and opacity intensities values of the
2441 % named color in this structure.
2443 % o exception: return any errors or warnings in this structure.
2446 MagickExport MagickBooleanType QueryMagickColorCompliance(const char *name,
2447 const ComplianceType compliance,MagickPixelPacket *color,
2448 ExceptionInfo *exception)
2462 register const ColorInfo
2469 Initialize color return value.
2471 assert(name != (const char *) NULL);
2472 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
2473 assert(color != (MagickPixelPacket *) NULL);
2474 GetMagickPixelPacket((Image *) NULL,color);
2475 if ((name == (char *) NULL) || (*name == '\0'))
2476 name=BackgroundColor;
2477 while (isspace((int) ((unsigned char) *name)) != 0)
2497 (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
2499 for (n=0; isxdigit((int) ((unsigned char) name[n])) != MagickFalse; n++) ;
2504 pixel.red=pixel.green;
2505 pixel.green=pixel.blue;
2507 for (i=(ssize_t) (n/3-1); i >= 0; i--)
2511 if ((c >= '0') && (c <= '9'))
2512 pixel.blue|=(int) (c-'0');
2514 if ((c >= 'A') && (c <= 'F'))
2515 pixel.blue|=(int) c-((int) 'A'-10);
2517 if ((c >= 'a') && (c <= 'f'))
2518 pixel.blue|=(int) c-((int) 'a'-10);
2520 return(MagickFalse);
2522 } while (isxdigit((int) ((unsigned char) *name)) != MagickFalse);
2529 (void) ThrowMagickException(exception,GetMagickModule(),
2530 OptionWarning,"UnrecognizedColor","`%s'",name);
2531 return(MagickFalse);
2535 pixel.red=pixel.green;
2536 pixel.green=pixel.blue;
2537 pixel.blue=pixel.opacity;
2539 for (i=(ssize_t) (n/4-1); i >= 0; i--)
2543 if ((c >= '0') && (c <= '9'))
2544 pixel.opacity|=(int) (c-'0');
2546 if ((c >= 'A') && (c <= 'F'))
2547 pixel.opacity|=(int) c-((int) 'A'-10);
2549 if ((c >= 'a') && (c <= 'f'))
2550 pixel.opacity|=(int) c-((int) 'a'-10);
2552 return(MagickFalse);
2554 } while (isxdigit((int) ((unsigned char) *name)) != MagickFalse);
2557 color->colorspace=RGBColorspace;
2558 color->matte=MagickFalse;
2559 range=GetQuantumRange(depth);
2560 color->red=(MagickRealType) ScaleAnyToQuantum(pixel.red,range);
2561 color->green=(MagickRealType) ScaleAnyToQuantum(pixel.green,range);
2562 color->blue=(MagickRealType) ScaleAnyToQuantum(pixel.blue,range);
2563 color->opacity=(MagickRealType) OpaqueOpacity;
2566 color->matte=MagickTrue;
2567 color->opacity=(MagickRealType) (QuantumRange-ScaleAnyToQuantum(
2568 pixel.opacity,range));
2573 if (strchr(name,'(') != (char *) NULL)
2576 colorspace[MaxTextExtent];
2579 Parse color of the form rgb(100,255,0).
2581 (void) CopyMagickString(colorspace,name,MaxTextExtent);
2582 for (i=0; colorspace[i] != '\0'; i++)
2583 if (colorspace[i] == '(')
2585 colorspace[i--]='\0';
2586 LocaleLower(colorspace);
2587 color->matte=MagickFalse;
2588 if ((i > 0) && (colorspace[i] == 'a'))
2591 color->matte=MagickTrue;
2593 type=ParseMagickOption(MagickColorspaceOptions,MagickFalse,colorspace);
2596 (void) ThrowMagickException(exception,GetMagickModule(),
2597 OptionWarning,"UnrecognizedColor","`%s'",name);
2598 return(MagickFalse);
2600 color->colorspace=(ColorspaceType) type;
2601 SetGeometryInfo(&geometry_info);
2602 flags=ParseGeometry(name+i+1,&geometry_info);
2603 scale=(MagickRealType) ScaleCharToQuantum(1);
2604 if ((flags & PercentValue) != 0)
2605 scale=(MagickRealType) (QuantumRange/100.0);
2606 if ((flags & RhoValue) != 0)
2607 color->red=(MagickRealType) ClampToQuantum(scale*geometry_info.rho);
2608 if ((flags & SigmaValue) != 0)
2609 color->green=(MagickRealType) ClampToQuantum(scale*geometry_info.sigma);
2610 if ((flags & XiValue) != 0)
2611 color->blue=(MagickRealType) ClampToQuantum(scale*geometry_info.xi);
2612 color->opacity=(MagickRealType) OpaqueOpacity;
2613 if ((flags & PsiValue) != 0)
2615 if (color->colorspace == CMYKColorspace)
2616 color->index=(MagickRealType) ClampToQuantum(scale*
2619 if (color->matte != MagickFalse)
2620 color->opacity=(MagickRealType) ClampToQuantum((MagickRealType)
2621 (QuantumRange-QuantumRange*geometry_info.psi));
2623 if (((flags & ChiValue) != 0) && (color->matte != MagickFalse))
2624 color->opacity=(MagickRealType) ClampToQuantum((MagickRealType)
2625 (QuantumRange-QuantumRange*geometry_info.chi));
2626 if (LocaleCompare(colorspace,"gray") == 0)
2628 color->green=color->red;
2629 color->blue=color->red;
2630 if (((flags & SigmaValue) != 0) && (color->matte != MagickFalse))
2631 color->opacity=(MagickRealType) ClampToQuantum((MagickRealType)
2632 (QuantumRange-QuantumRange*geometry_info.sigma));
2634 if ((LocaleCompare(colorspace,"HSB") == 0) ||
2635 (LocaleCompare(colorspace,"HSL") == 0) ||
2636 (LocaleCompare(colorspace,"HWB") == 0))
2642 if ((flags & PercentValue) != 0)
2644 geometry_info.rho*=360.0*scale;
2646 if ((flags & PercentValue) != 0)
2648 geometry_info.sigma*=scale;
2649 geometry_info.xi*=scale;
2650 if (LocaleCompare(colorspace,"HSB") == 0)
2651 ConvertHSBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2652 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2653 &pixel.green,&pixel.blue);
2655 if (LocaleCompare(colorspace,"HSL") == 0)
2656 ConvertHSLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2657 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2658 &pixel.green,&pixel.blue);
2660 ConvertHWBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2661 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2662 &pixel.green,&pixel.blue);
2663 color->colorspace=RGBColorspace;
2664 color->red=(MagickRealType) pixel.red;
2665 color->green=(MagickRealType) pixel.green;
2666 color->blue=(MagickRealType) pixel.blue;
2673 p=GetColorCompliance(name,compliance,exception);
2674 if (p == (const ColorInfo *) NULL)
2675 return(MagickFalse);
2676 color->colorspace=RGBColorspace;
2677 color->matte=p->color.opacity != OpaqueOpacity ? MagickTrue : MagickFalse;
2678 color->red=(MagickRealType) p->color.red;
2679 color->green=(MagickRealType) p->color.green;
2680 color->blue=(MagickRealType) p->color.blue;
2681 color->opacity=(MagickRealType) p->color.opacity;
2687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2691 % Q u e r y M a g i c k C o l o r %
2695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2697 % QueryMagickColor() returns the red, green, blue, and opacity intensities
2698 % for a given color name.
2700 % The format of the QueryMagickColor method is:
2702 % MagickBooleanType QueryMagickColor(const char *name,
2703 % MagickPixelPacket *color,ExceptionInfo *exception)
2705 % A description of each parameter follows:
2707 % o name: the color name (e.g. white, blue, yellow).
2709 % o color: the red, green, blue, and opacity intensities values of the
2710 % named color in this structure.
2712 % o exception: return any errors or warnings in this structure.
2715 MagickExport MagickBooleanType QueryMagickColor(const char *name,
2716 MagickPixelPacket *color,ExceptionInfo *exception)
2718 return(QueryMagickColorCompliance(name,AllCompliance,color,exception));
2722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2726 % Q u e r y M a g i c k C o l o r n a m e %
2730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2732 % QueryMagickColorname() returns a named color for the given color intensity.
2733 % If an exact match is not found, a hex value is returned instead. For
2734 % example an intensity of rgb:(0,0,0) returns black whereas rgb:(223,223,223)
2737 % The format of the QueryMagickColorname method is:
2739 % MagickBooleanType QueryMagickColorname(const Image *image,
2740 % const PixelPacket *color,const ComplianceType compliance,char *name,
2741 % ExceptionInfo *exception)
2743 % A description of each parameter follows.
2745 % o image: the image.
2747 % o color: the color intensities.
2749 % o Compliance: Adhere to this color standard: SVG, X11, or XPM.
2751 % o name: Return the color name or hex value.
2753 % o exception: return any errors or warnings in this structure.
2756 MagickExport MagickBooleanType QueryMagickColorname(const Image *image,
2757 const MagickPixelPacket *color,const ComplianceType compliance,
2758 char *name,ExceptionInfo *exception)
2766 register const ColorInfo
2771 if (compliance == XPMCompliance)
2773 pixel.matte=MagickFalse;
2774 pixel.depth=(size_t) MagickMin(1.0*image->depth,16.0);
2776 GetColorTuple(&pixel,compliance != SVGCompliance ? MagickTrue : MagickFalse,
2778 (void) GetColorInfo("*",exception);
2779 ResetLinkedListIterator(color_list);
2780 opacity=image->matte != MagickFalse ? color->opacity : OpaqueOpacity;
2781 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);
2782 while (p != (const ColorInfo *) NULL)
2784 if (((p->compliance & compliance) != 0) && ((p->color.red == color->red)) &&
2785 (p->color.green == color->green) && (p->color.blue == color->blue) &&
2786 (p->color.opacity == opacity))
2788 (void) CopyMagickString(name,p->name,MaxTextExtent);
2791 p=(const ColorInfo *) GetNextValueInLinkedList(color_list);