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