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;
95} ColormapInfo;
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{
833 LinkedListInfo
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
854 LinkedListInfo
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 {
873 ColorInfo
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{
956 ColorInfo
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{
1530 MagickPixelPacket
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=GetFuzzyColorDistance(image,(const Image *) NULL);
1685 scale=1.0;
1686 distance=0.0;
1687 if (image->matte != MagickFalse)
1688 {
1689 /*
1690 Transparencies are involved - set alpha distance
1691 */
1692 pixel=(MagickRealType) ((image->matte != MagickFalse ?
1693 GetPixelOpacity(p) : OpaqueOpacity)-(image->matte != MagickFalse ?
1694 q->opacity : OpaqueOpacity));
1695 distance=pixel*pixel;
1696 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
1697 return(MagickFalse);
1698 /*
1699 Generate a alpha scaling factor to generate a 4D cone on colorspace
1700 Note that if one color is transparent, distance has no color component.
1701 */
1702 scale=(QuantumScale*(double) GetPixelAlpha(p));
1703 scale*=(QuantumScale*(double) GetPixelAlpha(q));
1704 if (scale <= MagickEpsilon)
1705 return(MagickTrue);
1706 }
1707 /*
1708 RGB or CMY color cube
1709 */
1710 distance*=3.0; /* rescale appropriately */
1711 fuzz*=3.0;
1712 pixel=(double) GetPixelRed(p)-(double) GetPixelRed(q);
1713 if (IsHueCompatibleColorspace(image->colorspace) != MagickFalse)
1714 {
1715 /*
1716 This calculates a arc distance for hue. Really it should be a vector
1717 angle of 'S'/'W' length with 'L'/'B' forming appropriate cones. In
1718 other words this is a hack - Anthony
1719 */
1720 if (fabs((double) pixel) > ((double) QuantumRange/2.0))
1721 pixel-=(double) QuantumRange;
1722 pixel*=2.0;
1723 }
1724 distance+=scale*pixel*pixel;
1725 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
1726 return(MagickFalse);
1727 pixel=(double) GetPixelGreen(p)-(double) q->green;
1728 distance+=scale*pixel*pixel;
1729 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
1730 return(MagickFalse);
1731 pixel=(double) GetPixelBlue(p)-(double) q->blue;
1732 distance+=scale*pixel*pixel;
1733 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
1734 return(MagickFalse);
1735 return(MagickTrue);
1736}
1737
1738/*
1739%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1740% %
1741% %
1742% %
1743+ I s I m a g e S i m i l a r %
1744% %
1745% %
1746% %
1747%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1748%
1749% IsImageSimilar() returns true if the target is similar to a region of the
1750% image.
1751%
1752% The format of the IsImageSimilar method is:
1753%
1754% MagickBooleanType IsImageSimilar(const Image *image,
1755% const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1756% ExceptionInfo *exception)
1757%
1758% A description of each parameter follows:
1759%
1760% o image: the image.
1761%
1762% o target_image: the target image.
1763%
1764% o x_offset: On input the starting x position to search for a match;
1765% on output the x position of the first match found.
1766%
1767% o y_offset: On input the starting y position to search for a match;
1768% on output the y position of the first match found.
1769%
1770% o exception: return any errors or warnings in this structure.
1771%
1772*/
1773MagickExport MagickBooleanType IsImageSimilar(const Image *image,
1774 const Image *target_image,ssize_t *x_offset,ssize_t *y_offset,
1775 ExceptionInfo *exception)
1776{
1777#define SearchImageText " Searching image... "
1778
1779 CacheView
1780 *image_view,
1781 *target_view;
1782
1783 MagickBooleanType
1784 status;
1785
1786 MagickPixelPacket
1787 target,
1788 pixel;
1789
1790 const PixelPacket
1791 *p,
1792 *q;
1793
1794 const IndexPacket
1795 *indexes,
1796 *target_indexes;
1797
1798 ssize_t
1799 i,
1800 x;
1801
1802 ssize_t
1803 j,
1804 y;
1805
1806 assert(image != (Image *) NULL);
1807 assert(image->signature == MagickCoreSignature);
1808 assert(target_image != (Image *) NULL);
1809 assert(target_image->signature == MagickCoreSignature);
1810 assert(x_offset != (ssize_t *) NULL);
1811 assert(y_offset != (ssize_t *) NULL);
1812 assert(exception != (ExceptionInfo *) NULL);
1813 if (IsEventLogging() != MagickFalse)
1814 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1815 x=0;
1816 status=MagickTrue;
1817 GetMagickPixelPacket(image,&pixel);
1818 GetMagickPixelPacket(image,&target);
1819 image_view=AcquireVirtualCacheView(image,exception);
1820 target_view=AcquireVirtualCacheView(target_image,exception);
1821 for (y=(*y_offset); y < (ssize_t) image->rows; y++)
1822 {
1823 for (x=y == 0 ? *x_offset : 0; x < (ssize_t) image->columns; x++)
1824 {
1825 for (j=0; j < (ssize_t) target_image->rows; j++)
1826 {
1827 for (i=0; i < (ssize_t) target_image->columns; i++)
1828 {
1829 p=GetCacheViewVirtualPixels(image_view,x+i,y+j,1,1,exception);
1830 if (p == (const PixelPacket *) NULL)
1831 break;
1832 indexes=GetCacheViewVirtualIndexQueue(image_view);
1833 SetMagickPixelPacket(image,p,indexes,&pixel);
1834 q=GetCacheViewVirtualPixels(target_view,i,j,1,1,exception);
1835 if (q == (const PixelPacket *) NULL)
1836 break;
1837 target_indexes=GetCacheViewVirtualIndexQueue(target_view);
1838 SetMagickPixelPacket(image,q,target_indexes,&target);
1839 if (IsMagickColorSimilar(&pixel,&target) == MagickFalse)
1840 break;
1841 }
1842 if (i < (ssize_t) target_image->columns)
1843 break;
1844 }
1845 if (j == (ssize_t) target_image->rows)
1846 break;
1847 }
1848 if (x < (ssize_t) image->columns)
1849 break;
1850 if (image->progress_monitor != (MagickProgressMonitor) NULL)
1851 {
1852 MagickBooleanType
1853 proceed;
1854
1855 proceed=SetImageProgress(image,SearchImageText,(MagickOffsetType) y,
1856 image->rows);
1857 if (proceed == MagickFalse)
1858 status=MagickFalse;
1859 }
1860 }
1861 target_view=DestroyCacheView(target_view);
1862 image_view=DestroyCacheView(image_view);
1863 *x_offset=x;
1864 *y_offset=y;
1865 if (status == MagickFalse)
1866 return(status);
1867 return(y < (ssize_t) image->rows ? MagickTrue : MagickFalse);
1868}
1869
1870/*
1871%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1872% %
1873% %
1874% %
1875+ I s I n t e n s i t y S i m i l a r %
1876% %
1877% %
1878% %
1879%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1880%
1881% IsIntensitySimilar() returns true if the distance between two intensity
1882% values is less than the specified distance in a linear color space.
1883%
1884% The format of the IsIntensitySimilar method is:
1885%
1886% void IsIntensitySimilar(const Image *image,const PixelPacket *p,
1887% const PixelPacket *q)
1888%
1889% A description of each parameter follows:
1890%
1891% o image: the image.
1892%
1893% o p: Pixel p.
1894%
1895% o q: Pixel q.
1896%
1897*/
1898MagickPrivate MagickBooleanType IsIntensitySimilar(const Image *image,
1899 const PixelPacket *p,const PixelPacket *q)
1900{
1901 MagickRealType
1902 fuzz,
1903 pixel;
1904
1905 if (GetPixelIntensity(image,p) == GetPixelIntensity(image,q))
1906 return(MagickTrue);
1907 fuzz=GetFuzzyColorDistance(image,(const Image *) NULL);
1908 pixel=GetPixelIntensity(image,p)-GetPixelIntensity(image,q);
1909 if (MagickSafeSignificantError(pixel*pixel,fuzz) != MagickFalse)
1910 return(MagickFalse);
1911 return(MagickTrue);
1912}
1913
1914/*
1915%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1916% %
1917% %
1918% %
1919+ I s M a g i c k C o l o r S i m i l a r %
1920% %
1921% %
1922% %
1923%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1924%
1925% IsMagickColorSimilar() returns true if the distance between two colors is
1926% less than the specified distance in a linear three dimensional color space.
1927% This method is used by ColorFloodFill() and other algorithms which
1928% compare two colors.
1929%
1930% This implements the equivalent of...
1931% fuzz < sqrt( color_distance^2 * u.a*v.a + alpha_distance^2 )
1932%
1933% Which produces a multi-dimensional cone for that colorspace along the
1934% transparency vector.
1935%
1936% For example for an RGB
1937% color_distance^2 = ( (u.r-v.r)^2 + (u.g-v.g)^2 + (u.b-v.b)^2 ) / 3
1938%
1939% See https://imagemagick.org/Usage/bugs/fuzz_distance/
1940%
1941% Hue colorspace distances need more work. Hue is not a distance, it is an
1942% angle!
1943%
1944% A check that q is in the same color space as p should be made and the
1945% appropriate mapping made. -- Anthony Thyssen 8 December 2010
1946%
1947% The format of the IsMagickColorSimilar method is:
1948%
1949% MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p,
1950% const MagickPixelPacket *q)
1951%
1952% A description of each parameter follows:
1953%
1954% o p: Pixel p.
1955%
1956% o q: Pixel q.
1957%
1958*/
1959MagickExport MagickBooleanType IsMagickColorSimilar(const MagickPixelPacket *p,
1960 const MagickPixelPacket *q)
1961{
1962 double
1963 fuzz,
1964 pixel,
1965 scale,
1966 distance;
1967
1968 if ((p->fuzz == 0.0) && (q->fuzz == 0.0))
1969 return(IsMagickColorEqual(p,q));
1970 fuzz=p->fuzz*p->fuzz+q->fuzz*q->fuzz;
1971 scale=1.0;
1972 distance=0.0;
1973 if ((p->matte != MagickFalse) || (q->matte != MagickFalse))
1974 {
1975 /*
1976 Transparencies are involved - set alpha distance.
1977 */
1978 pixel=(p->matte != MagickFalse ? (double) GetPixelOpacity(p) : (double)
1979 OpaqueOpacity)-(q->matte != MagickFalse ? (double) q->opacity :
1980 (double) OpaqueOpacity);
1981 distance=pixel*pixel;
1982 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
1983 return(MagickFalse);
1984 /*
1985 Generate a alpha scaling factor to generate a 4D cone on colorspace.
1986 Note that if one color is transparent, distance has no color component
1987 */
1988 if (p->matte != MagickFalse)
1989 scale=(QuantumScale*(double) GetPixelAlpha(p));
1990 if (q->matte != MagickFalse)
1991 scale*=(QuantumScale*(double) GetPixelAlpha(q));
1992 if (scale <= MagickEpsilon)
1993 return(MagickTrue);
1994 }
1995 /*
1996 CMYK create a CMY cube with a multi-dimensional cone toward black.
1997 */
1998 if (p->colorspace == CMYKColorspace)
1999 {
2000 pixel=p->index-q->index;
2001 distance+=pixel*pixel*scale;
2002 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
2003 return(MagickFalse);
2004 scale*=(MagickRealType) (QuantumScale*((double) QuantumRange-p->index));
2005 scale*=(MagickRealType) (QuantumScale*((double) QuantumRange-q->index));
2006 }
2007 /*
2008 RGB or CMY color cube.
2009 */
2010 distance*=3.0; /* rescale appropriately */
2011 fuzz*=3.0;
2012 pixel=p->red-q->red;
2013 if (IsHueCompatibleColorspace(p->colorspace) != MagickFalse)
2014 {
2015 /*
2016 This calculates a arc distance for hue. Really if should be a vector
2017 angle of 'S'/'W' length with 'L'/'B' forming appropriate cones. In
2018 other words this is a hack - Anthony
2019 */
2020 if (fabs((double) pixel) > ((double) QuantumRange/2.0))
2021 pixel-=(double) QuantumRange;
2022 pixel*=2.0;
2023 }
2024 distance+=pixel*pixel*scale;
2025 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
2026 return(MagickFalse);
2027 pixel=GetPixelGreen(p)-q->green;
2028 distance+=pixel*pixel*scale;
2029 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
2030 return(MagickFalse);
2031 pixel=GetPixelBlue(p)-q->blue;
2032 distance+=pixel*pixel*scale;
2033 if (MagickSafeSignificantError(distance,fuzz) != MagickFalse)
2034 return(MagickFalse);
2035 return(MagickTrue);
2036}
2037
2038/*
2039%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2040% %
2041% %
2042% %
2043+ I s O p a c i t y S i m i l a r %
2044% %
2045% %
2046% %
2047%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2048%
2049% IsOpacitySimilar() returns true if the distance between two opacity
2050% values is less than the specified distance in a linear color space. This
2051% method is used by MatteFloodFill() and other algorithms which compare
2052% two opacity values.
2053%
2054% The format of the IsOpacitySimilar method is:
2055%
2056% void IsOpacitySimilar(const Image *image,const PixelPacket *p,
2057% const PixelPacket *q)
2058%
2059% A description of each parameter follows:
2060%
2061% o image: the image.
2062%
2063% o p: Pixel p.
2064%
2065% o q: Pixel q.
2066%
2067*/
2068MagickExport MagickBooleanType IsOpacitySimilar(const Image *image,
2069 const PixelPacket *p,const PixelPacket *q)
2070{
2071 MagickRealType
2072 fuzz,
2073 pixel;
2074
2075 if (image->matte == MagickFalse)
2076 return(MagickTrue);
2077 if (GetPixelOpacity(p) == GetPixelOpacity(q))
2078 return(MagickTrue);
2079 fuzz=GetFuzzyColorDistance(image,(const Image *) NULL);
2080 pixel=(MagickRealType) GetPixelOpacity(p)-(MagickRealType) GetPixelOpacity(q);
2081 if (MagickSafeSignificantError(pixel*pixel,fuzz) != MagickFalse)
2082 return(MagickFalse);
2083 return(MagickTrue);
2084}
2085
2086/*
2087%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2088% %
2089% %
2090% %
2091% L i s t C o l o r I n f o %
2092% %
2093% %
2094% %
2095%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2096%
2097% ListColorInfo() lists color names to the specified file. Color names
2098% are a convenience. Rather than defining a color by its red, green, and
2099% blue intensities just use a color name such as white, blue, or yellow.
2100%
2101% The format of the ListColorInfo method is:
2102%
2103% MagickBooleanType ListColorInfo(FILE *file,ExceptionInfo *exception)
2104%
2105% A description of each parameter follows.
2106%
2107% o file: List color names to this file handle.
2108%
2109% o exception: return any errors or warnings in this structure.
2110%
2111*/
2112MagickExport MagickBooleanType ListColorInfo(FILE *file,
2113 ExceptionInfo *exception)
2114{
2115 char
2116 tuple[MaxTextExtent];
2117
2118 const char
2119 *path;
2120
2121 const ColorInfo
2122 **color_info;
2123
2124 ssize_t
2125 i;
2126
2127 size_t
2128 number_colors;
2129
2130 /*
2131 List name and attributes of each color in the list.
2132 */
2133 if (file == (const FILE *) NULL)
2134 file=stdout;
2135 color_info=GetColorInfoList("*",&number_colors,exception);
2136 if (color_info == (const ColorInfo **) NULL)
2137 return(MagickFalse);
2138 path=(const char *) NULL;
2139 for (i=0; i < (ssize_t) number_colors; i++)
2140 {
2141 if (color_info[i]->stealth != MagickFalse)
2142 continue;
2143 if ((path == (const char *) NULL) ||
2144 (LocaleCompare(path,color_info[i]->path) != 0))
2145 {
2146 if (color_info[i]->path != (char *) NULL)
2147 (void) FormatLocaleFile(file,"\nPath: %s\n\n",color_info[i]->path);
2148 (void) FormatLocaleFile(file,
2149 "Name Color "
2150 " Compliance\n");
2151 (void) FormatLocaleFile(file,
2152 "-------------------------------------------------"
2153 "------------------------------\n");
2154 }
2155 path=color_info[i]->path;
2156 (void) FormatLocaleFile(file,"%-21.21s ",color_info[i]->name);
2157 GetColorTuple(&color_info[i]->color,MagickFalse,tuple);
2158 (void) FormatLocaleFile(file,"%-45.45s ",tuple);
2159 if ((color_info[i]->compliance & SVGCompliance) != 0)
2160 (void) FormatLocaleFile(file,"SVG ");
2161 if ((color_info[i]->compliance & X11Compliance) != 0)
2162 (void) FormatLocaleFile(file,"X11 ");
2163 if ((color_info[i]->compliance & XPMCompliance) != 0)
2164 (void) FormatLocaleFile(file,"XPM ");
2165 (void) FormatLocaleFile(file,"\n");
2166 }
2167 color_info=(const ColorInfo **) RelinquishMagickMemory((void *) color_info);
2168 (void) fflush(file);
2169 return(MagickTrue);
2170}
2171
2172#if !MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
2173/*
2174%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2175% %
2176% %
2177% %
2178+ L o a d C o l o r C a c h e %
2179% %
2180% %
2181% %
2182%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2183%
2184% LoadColorCache() loads the color configurations which provides a mapping
2185% between color attributes and a color name.
2186%
2187% The format of the LoadColorCache method is:
2188%
2189% MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
2190% const char *filename,const size_t depth,ExceptionInfo *exception)
2191%
2192% A description of each parameter follows:
2193%
2194% o xml: The color list in XML format.
2195%
2196% o filename: The color list filename.
2197%
2198% o depth: depth of <include /> statements.
2199%
2200% o exception: return any errors or warnings in this structure.
2201%
2202*/
2203static MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
2204 const char *filename,const size_t depth,ExceptionInfo *exception)
2205{
2206 char
2207 keyword[MaxTextExtent],
2208 *token;
2209
2210 ColorInfo
2211 *color_info;
2212
2213 const char
2214 *q;
2215
2216 MagickStatusType
2217 status;
2218
2219 size_t
2220 extent;
2221
2222 /*
2223 Load the color map file.
2224 */
2225 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
2226 "Loading color file \"%s\" ...",filename);
2227 if (xml == (char *) NULL)
2228 return(MagickFalse);
2229 status=MagickTrue;
2230 color_info=(ColorInfo *) NULL;
2231 token=AcquireString(xml);
2232 extent=strlen(token)+MaxTextExtent;
2233 for (q=(char *) xml; *q != '\0'; )
2234 {
2235 /*
2236 Interpret XML.
2237 */
2238 (void) GetNextToken(q,&q,extent,token);
2239 if (*token == '\0')
2240 break;
2241 (void) CopyMagickString(keyword,token,MaxTextExtent);
2242 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
2243 {
2244 /*
2245 Doctype element.
2246 */
2247 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
2248 (void) GetNextToken(q,&q,extent,token);
2249 continue;
2250 }
2251 if (LocaleNCompare(keyword,"<!--",4) == 0)
2252 {
2253 /*
2254 Comment element.
2255 */
2256 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
2257 (void) GetNextToken(q,&q,extent,token);
2258 continue;
2259 }
2260 if (LocaleCompare(keyword,"<include") == 0)
2261 {
2262 /*
2263 Include element.
2264 */
2265 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
2266 {
2267 (void) CopyMagickString(keyword,token,MaxTextExtent);
2268 (void) GetNextToken(q,&q,extent,token);
2269 if (*token != '=')
2270 continue;
2271 (void) GetNextToken(q,&q,extent,token);
2272 if (LocaleCompare(keyword,"file") == 0)
2273 {
2274 if (depth > MagickMaxRecursionDepth)
2275 (void) ThrowMagickException(exception,GetMagickModule(),
2276 ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
2277 else
2278 {
2279 char
2280 path[MaxTextExtent],
2281 *xml;
2282
2283 GetPathComponent(filename,HeadPath,path);
2284 if (*path != '\0')
2285 (void) ConcatenateMagickString(path,DirectorySeparator,
2286 MaxTextExtent);
2287 if (*token == *DirectorySeparator)
2288 (void) CopyMagickString(path,token,MaxTextExtent);
2289 else
2290 (void) ConcatenateMagickString(path,token,MaxTextExtent);
2291 xml=FileToXML(path,~0UL);
2292 if (xml != (char *) NULL)
2293 {
2294 status&=LoadColorCache(cache,xml,path,depth+1,exception);
2295 xml=(char *) RelinquishMagickMemory(xml);
2296 }
2297 }
2298 }
2299 }
2300 continue;
2301 }
2302 if (LocaleCompare(keyword,"<color") == 0)
2303 {
2304 /*
2305 Color element.
2306 */
2307 color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info));
2308 if (color_info == (ColorInfo *) NULL)
2309 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
2310 (void) memset(color_info,0,sizeof(*color_info));
2311 color_info->path=ConstantString(filename);
2312 color_info->exempt=MagickFalse;
2313 color_info->signature=MagickCoreSignature;
2314 continue;
2315 }
2316 if (color_info == (ColorInfo *) NULL)
2317 continue;
2318 if ((LocaleCompare(keyword,"/>") == 0) ||
2319 (LocaleCompare(keyword,"</policy>") == 0))
2320 {
2321 status=AppendValueToLinkedList(cache,color_info);
2322 if (status == MagickFalse)
2323 (void) ThrowMagickException(exception,GetMagickModule(),
2324 ResourceLimitError,"MemoryAllocationFailed","`%s'",
2325 color_info->name);
2326 color_info=(ColorInfo *) NULL;
2327 continue;
2328 }
2329 (void) GetNextToken(q,(const char **) NULL,extent,token);
2330 if (*token != '=')
2331 continue;
2332 (void) GetNextToken(q,&q,extent,token);
2333 (void) GetNextToken(q,&q,extent,token);
2334 switch (*keyword)
2335 {
2336 case 'C':
2337 case 'c':
2338 {
2339 if (LocaleCompare((char *) keyword,"color") == 0)
2340 {
2341 (void) QueryMagickColor(token,&color_info->color,exception);
2342 break;
2343 }
2344 if (LocaleCompare((char *) keyword,"compliance") == 0)
2345 {
2346 ssize_t
2347 compliance;
2348
2349 compliance=color_info->compliance;
2350 if (StringLocateSubstring(token,"*SVG*") != (char *) NULL)
2351 compliance|=SVGCompliance;
2352 if (StringLocateSubstring(token,"*X11*") != (char *) NULL)
2353 compliance|=X11Compliance;
2354 if (StringLocateSubstring(token,"*XPM*") != (char *) NULL)
2355 compliance|=XPMCompliance;
2356 color_info->compliance=(ComplianceType) compliance;
2357 break;
2358 }
2359 break;
2360 }
2361 case 'N':
2362 case 'n':
2363 {
2364 if (LocaleCompare((char *) keyword,"name") == 0)
2365 {
2366 color_info->name=ConstantString(token);
2367 break;
2368 }
2369 break;
2370 }
2371 case 'S':
2372 case 's':
2373 {
2374 if (LocaleCompare((char *) keyword,"stealth") == 0)
2375 {
2376 color_info->stealth=IsMagickTrue(token);
2377 break;
2378 }
2379 break;
2380 }
2381 default:
2382 break;
2383 }
2384 }
2385 token=(char *) RelinquishMagickMemory(token);
2386 return(status != 0 ? MagickTrue : MagickFalse);
2387}
2388#endif
2389
2390/*
2391%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2392% %
2393% %
2394% %
2395% Q u e r y C o l o r C o m p l i e n c e %
2396% %
2397% %
2398% %
2399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2400%
2401% QueryColorCompliance() returns the red, green, blue, and opacity intensities
2402% for a given color name.
2403%
2404% The format of the QueryColorCompliance method is:
2405%
2406% MagickBooleanType QueryColorCompliance(const char *name,
2407% const ComplianceType compliance,PixelPacket *color,
2408% ExceptionInfo *exception)
2409%
2410% A description of each parameter follows:
2411%
2412% o name: the color name (e.g. white, blue, yellow).
2413%
2414% o compliance: Adhere to this color standard: SVG, X11, or XPM.
2415%
2416% o color: the red, green, blue, and opacity intensities values of the
2417% named color in this structure.
2418%
2419% o exception: return any errors or warnings in this structure.
2420%
2421*/
2422MagickExport MagickBooleanType QueryColorCompliance(const char *name,
2423 const ComplianceType compliance,PixelPacket *color,ExceptionInfo *exception)
2424{
2425 MagickBooleanType
2426 status;
2427
2428 MagickPixelPacket
2429 pixel;
2430
2431 status=QueryMagickColorCompliance(name,compliance,&pixel,exception);
2432 SetPixelOpacity(color,ClampToQuantum(pixel.opacity));
2433 if (pixel.colorspace == CMYKColorspace)
2434 {
2435 SetPixelRed(color,ClampToQuantum((double) QuantumRange-
2436 MagickMin((double) QuantumRange,QuantumScale*pixel.red*((double)
2437 QuantumRange-(double) pixel.index)+pixel.index)));
2438 SetPixelGreen(color,ClampToQuantum((double) QuantumRange-
2439 MagickMin((double) QuantumRange,QuantumScale*pixel.green*((double)
2440 QuantumRange-(double) pixel.index)+pixel.index)));
2441 SetPixelBlue(color,ClampToQuantum((double) QuantumRange-
2442 MagickMin((double) QuantumRange,QuantumScale*pixel.blue*((double)
2443 QuantumRange-(double) pixel.index)+pixel.index)));
2444 return(status);
2445 }
2446 SetPixelRed(color,ClampToQuantum(pixel.red));
2447 SetPixelGreen(color,ClampToQuantum(pixel.green));
2448 SetPixelBlue(color,ClampToQuantum(pixel.blue));
2449 return(status);
2450}
2451
2452/*
2453%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2454% %
2455% %
2456% %
2457% Q u e r y C o l o r D a t a b a s e %
2458% %
2459% %
2460% %
2461%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2462%
2463% QueryColorDatabase() returns the red, green, blue, and opacity intensities
2464% for a given color name.
2465%
2466% The format of the QueryColorDatabase method is:
2467%
2468% MagickBooleanType QueryColorDatabase(const char *name,PixelPacket *color,
2469% ExceptionInfo *exception)
2470%
2471% A description of each parameter follows:
2472%
2473% o name: the color name (e.g. white, blue, yellow).
2474%
2475% o color: the red, green, blue, and opacity intensities values of the
2476% named color in this structure.
2477%
2478% o exception: return any errors or warnings in this structure.
2479%
2480*/
2481MagickExport MagickBooleanType QueryColorDatabase(const char *name,
2482 PixelPacket *color,ExceptionInfo *exception)
2483{
2484 return(QueryColorCompliance(name,AllCompliance,color,exception));
2485}
2486
2487/*
2488%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2489% %
2490% %
2491% %
2492% Q u e r y C o l o r n a m e %
2493% %
2494% %
2495% %
2496%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2497%
2498% QueryColorname() returns a named color for the given color intensity. If
2499% an exact match is not found, a rgb() color is returned instead.
2500%
2501% The format of the QueryColorname method is:
2502%
2503% MagickBooleanType QueryColorname(const Image *image,
2504% const PixelPacket *color,const ComplianceType compliance,char *name,
2505% ExceptionInfo *exception)
2506%
2507% A description of each parameter follows.
2508%
2509% o image: the image.
2510%
2511% o color: the color intensities.
2512%
2513% o compliance: Adhere to this color standard: SVG, X11, or XPM.
2514%
2515% o name: Return the color name or hex value.
2516%
2517% o exception: return any errors or warnings in this structure.
2518%
2519*/
2520MagickExport MagickBooleanType QueryColorname(const Image *image,
2521 const PixelPacket *color,const ComplianceType compliance,char *name,
2522 ExceptionInfo *exception)
2523{
2524 MagickPixelPacket
2525 pixel;
2526
2527 GetMagickPixelPacket(image,&pixel);
2528 SetMagickPixelPacket(image,color,(IndexPacket *) NULL,&pixel);
2529 return(QueryMagickColorname(image,&pixel,compliance,name,exception));
2530}
2531
2532/*
2533%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2534% %
2535% %
2536% %
2537% 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 %
2538% %
2539% %
2540% %
2541%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2542%
2543% QueryMagickColorCompliance() returns the red, green, blue, and opacity
2544% intensities for a given color name and standards compliance.
2545%
2546% The format of the QueryMagickColor method is:
2547%
2548% MagickBooleanType QueryMagickColorCompiliance(const char *name,
2549% const ComplianceType compliance,MagickPixelPacket *color,
2550% ExceptionInfo *exception)
2551%
2552% A description of each parameter follows:
2553%
2554% o name: the color name (e.g. white, blue, yellow).
2555%
2556% o compliance: Adhere to this color standard: SVG, X11, or XPM.
2557%
2558% o color: the red, green, blue, and opacity intensities values of the
2559% named color in this structure.
2560%
2561% o exception: return any errors or warnings in this structure.
2562%
2563*/
2564
2565static MagickStatusType ParseCSSColor(const char *magick_restrict color,
2566 GeometryInfo *geometry_info)
2567{
2568 char
2569 *q;
2570
2571 ssize_t
2572 i;
2573
2574 MagickStatusType
2575 flags;
2576
2577 SetGeometryInfo(geometry_info);
2578 flags=NoValue;
2579 if ((color == (char *) NULL) || (*color == '\0'))
2580 return(flags);
2581 q=(char *) color;
2582 if (*q == '(')
2583 q++;
2584 for (i=0; (i < 5) && (*q != ')') && (*q != '\0'); i++)
2585 {
2586 char
2587 *p;
2588
2589 double
2590 intensity;
2591
2592 p=q;
2593 intensity=(float) StringToDouble(p,&q);
2594 if (p == q)
2595 break;
2596 if (*q == '%')
2597 {
2598 intensity*=0.01*255.0;
2599 q++;
2600 }
2601 switch (i)
2602 {
2603 case 0:
2604 {
2605 geometry_info->rho=intensity;
2606 flags|=RhoValue;
2607 if (LocaleNCompare(q,"deg",3) == 0)
2608 q+=(ptrdiff_t) 3;
2609 break;
2610 }
2611 case 1:
2612 {
2613 geometry_info->sigma=intensity;
2614 flags|=SigmaValue;
2615 break;
2616 }
2617 case 2:
2618 {
2619 geometry_info->xi=intensity;
2620 flags|=XiValue;
2621 break;
2622 }
2623 case 3:
2624 {
2625 geometry_info->psi=intensity;
2626 flags|=PsiValue;
2627 break;
2628 }
2629 case 4:
2630 {
2631 geometry_info->chi=intensity;
2632 flags|=ChiValue;
2633 break;
2634 }
2635 }
2636 while (isspace((int) ((unsigned char) *q)) != 0)
2637 q++;
2638 if (*q == ',')
2639 q++;
2640 if (*q == '/')
2641 {
2642 flags|=AlphaValue;
2643 q++;
2644 }
2645 }
2646 return(flags);
2647}
2648
2649MagickExport MagickBooleanType QueryMagickColorCompliance(const char *name,
2650 const ComplianceType compliance,MagickPixelPacket *color,
2651 ExceptionInfo *exception)
2652{
2653 const ColorInfo
2654 *p;
2655
2656 double
2657 scale;
2658
2659 GeometryInfo
2660 geometry_info;
2661
2662 MagickStatusType
2663 flags;
2664
2665 ssize_t
2666 i,
2667 type;
2668
2669 /*
2670 Initialize color return value.
2671 */
2672 assert(color != (MagickPixelPacket *) NULL);
2673 if ((name == (char *) NULL) || (*name == '\0'))
2674 name=BackgroundColor;
2675 if (IsEventLogging() != MagickFalse)
2676 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",name);
2677 if (strlen(name) > MagickPathExtent)
2678 {
2679 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
2680 "UnrecognizedColor","`%s'",name);
2681 return(MagickFalse);
2682 }
2683 while (isspace((int) ((unsigned char) *name)) != 0)
2684 name++;
2685 GetMagickPixelPacket((Image *) NULL,color);
2686 if (*name == '#')
2687 {
2688 char
2689 c;
2690
2691 LongPixelPacket
2692 pixel = { 0, 0, 0, 0, 0 };
2693
2694 QuantumAny
2695 range;
2696
2697 size_t
2698 depth,
2699 n;
2700
2701 /*
2702 Parse hex color.
2703 */
2704 name++;
2705 for (n=0; isxdigit((int) ((unsigned char) name[n])) != 0; n++) ;
2706 if ((n == 3) || (n == 6) || (n == 9) || (n == 12) || (n == 24) ||
2707 (n == 48))
2708 {
2709 do
2710 {
2711 pixel.red=pixel.green;
2712 pixel.green=pixel.blue;
2713 pixel.blue=0;
2714 for (i=(ssize_t) (n/3-1); i >= 0; i--)
2715 {
2716 c=(*name++);
2717 pixel.blue<<=4;
2718 if ((c >= '0') && (c <= '9'))
2719 pixel.blue|=(int) (c-'0');
2720 else
2721 if ((c >= 'A') && (c <= 'F'))
2722 pixel.blue|=(int) c-((int) 'A'-10);
2723 else
2724 if ((c >= 'a') && (c <= 'f'))
2725 pixel.blue|=(int) c-((int) 'a'-10);
2726 else
2727 return(MagickFalse);
2728 }
2729 } while (isxdigit((int) ((unsigned char) *name)) != 0);
2730 depth=4*(n/3);
2731 }
2732 else
2733 {
2734 if ((n != 4) && (n != 8) && (n != 16) && (n != 32) && (n != 64))
2735 {
2736 (void) ThrowMagickException(exception,GetMagickModule(),
2737 OptionWarning,"UnrecognizedColor","`%s'",name);
2738 return(MagickFalse);
2739 }
2740 do
2741 {
2742 pixel.red=pixel.green;
2743 pixel.green=pixel.blue;
2744 pixel.blue=pixel.opacity;
2745 pixel.opacity=0;
2746 for (i=(ssize_t) (n/4-1); i >= 0; i--)
2747 {
2748 c=(*name++);
2749 pixel.opacity<<=4;
2750 if ((c >= '0') && (c <= '9'))
2751 pixel.opacity|=(int) (c-'0');
2752 else
2753 if ((c >= 'A') && (c <= 'F'))
2754 pixel.opacity|=(int) c-((int) 'A'-10);
2755 else
2756 if ((c >= 'a') && (c <= 'f'))
2757 pixel.opacity|=(int) c-((int) 'a'-10);
2758 else
2759 return(MagickFalse);
2760 }
2761 } while (isxdigit((int) ((unsigned char) *name)) != 0);
2762 depth=4*(n/4);
2763 }
2764 color->colorspace=sRGBColorspace;
2765 color->depth=depth;
2766 color->matte=MagickFalse;
2767 range=GetQuantumRange(depth);
2768 color->red=(MagickRealType) ScaleAnyToQuantum(pixel.red,range);
2769 color->green=(MagickRealType) ScaleAnyToQuantum(pixel.green,range);
2770 color->blue=(MagickRealType) ScaleAnyToQuantum(pixel.blue,range);
2771 color->opacity=(MagickRealType) OpaqueOpacity;
2772 if ((n % 3) != 0)
2773 {
2774 color->matte=MagickTrue;
2775 color->opacity=(MagickRealType) (QuantumRange-ScaleAnyToQuantum(
2776 pixel.opacity,range));
2777 }
2778 color->index=0.0;
2779 return(MagickTrue);
2780 }
2781 if (strchr(name,'(') != (char *) NULL)
2782 {
2783 char
2784 colorspace[2*MaxTextExtent];
2785
2786 MagickBooleanType
2787 icc_color;
2788
2789 /*
2790 Parse color of the form rgb(100,255,0).
2791 */
2792 (void) memset(colorspace,0,sizeof(colorspace));
2793 (void) CopyMagickString(colorspace,name,MaxTextExtent);
2794 for (i=0; colorspace[i] != '\0'; i++)
2795 if (colorspace[i] == '(')
2796 break;
2797 colorspace[i--]='\0';
2798 scale=(double) ScaleCharToQuantum(1);
2799 icc_color=MagickFalse;
2800 if (LocaleNCompare(colorspace,"device-",7) == 0)
2801 {
2802 (void) CopyMagickString(colorspace,colorspace+7,MaxTextExtent);
2803 if (strchr(name,'%') == (char *) NULL)
2804 scale=(double) QuantumRange;
2805 icc_color=MagickTrue;
2806 }
2807 if ((LocaleCompare(colorspace,"color") == 0) ||
2808 (LocaleCompare(colorspace,"icc-color") == 0))
2809 {
2810 ssize_t
2811 j;
2812
2813 (void) CopyMagickString(colorspace,name+i+2,MaxTextExtent);
2814 for (j=0; colorspace[j] != '\0'; j++)
2815 if ((colorspace[j] == ' ') || (colorspace[j] == ','))
2816 break;
2817 colorspace[j--]='\0';
2818 i+=j+3;
2819 scale=(double) QuantumRange;
2820 icc_color=MagickTrue;
2821 }
2822 LocaleLower(colorspace);
2823 color->matte=MagickFalse;
2824 if ((i > 0) && (colorspace[i] == 'a'))
2825 {
2826 colorspace[i]='\0';
2827 color->matte=MagickTrue;
2828 }
2829 type=ParseCommandOption(MagickColorspaceOptions,MagickFalse,colorspace);
2830 if (type < 0)
2831 {
2832 (void) ThrowMagickException(exception,GetMagickModule(),
2833 OptionWarning,"UnrecognizedColor","`%s'",name);
2834 return(MagickFalse);
2835 }
2836 color->colorspace=(ColorspaceType) type;
2837 if ((icc_color == MagickFalse) && (color->colorspace == RGBColorspace))
2838 {
2839 color->colorspace=sRGBColorspace; /* as required by SVG standard */
2840 color->depth=8;
2841 }
2842 if (i >= (ssize_t) strlen(name))
2843 flags=ParseCSSColor(name,&geometry_info);
2844 else
2845 flags=ParseCSSColor(name+i+1,&geometry_info);
2846 if (flags == 0)
2847 {
2848 char
2849 *colorname;
2850
2851 ColorspaceType
2852 colorspace;
2853
2854 MagickBooleanType
2855 status;
2856
2857 colorspace=color->colorspace;
2858 if (i >= (ssize_t) strlen(name))
2859 colorname=AcquireString(name);
2860 else
2861 colorname=AcquireString(name+i+1);
2862 (void) SubstituteString(&colorname,"(","");
2863 (void) SubstituteString(&colorname,")","");
2864 status=MagickFalse;
2865 if (LocaleCompare(name,colorname) != 0)
2866 status=QueryMagickColor(colorname,color,exception);
2867 color->colorspace=colorspace;
2868 if (*colorname == '\0')
2869 {
2870 (void) ThrowMagickException(exception,GetMagickModule(),
2871 OptionWarning,"UnrecognizedColor","`%s'",name);
2872 status=MagickFalse;
2873 }
2874 colorname=DestroyString(colorname);
2875 return(status);
2876 }
2877 if ((flags & AlphaValue) != 0)
2878 color->matte=MagickTrue;
2879 if ((flags & RhoValue) != 0)
2880 color->red=(MagickRealType) ClampToQuantum((MagickRealType)
2881 (scale*geometry_info.rho));
2882 if ((flags & SigmaValue) != 0)
2883 color->green=(MagickRealType) ClampToQuantum((MagickRealType)
2884 (scale*geometry_info.sigma));
2885 if ((flags & XiValue) != 0)
2886 color->blue=(MagickRealType) ClampToQuantum((MagickRealType)
2887 (scale*geometry_info.xi));
2888 color->opacity=(MagickRealType) OpaqueOpacity;
2889 if ((flags & PsiValue) != 0)
2890 {
2891 if (color->colorspace == CMYKColorspace)
2892 color->index=(MagickRealType) ClampToQuantum((MagickRealType)
2893 (scale*geometry_info.psi));
2894 else
2895 if (color->matte != MagickFalse)
2896 {
2897 if ((flags & AlphaValue) != 0)
2898 color->opacity=(MagickRealType) ClampToQuantum(
2899 (MagickRealType) (scale*geometry_info.psi));
2900 else
2901 color->opacity=(MagickRealType) ClampToQuantum(
2902 (MagickRealType) QuantumRange-(MagickRealType) QuantumRange*
2903 geometry_info.psi);
2904 }
2905 }
2906 if (((flags & ChiValue) != 0) && (color->matte != MagickFalse))
2907 color->opacity=(MagickRealType) ClampToQuantum((MagickRealType)
2908 QuantumRange-(MagickRealType) QuantumRange*geometry_info.chi);
2909 if (IsLabCompatibleColorspace(color->colorspace) != MagickFalse)
2910 {
2911 color->red=(MagickRealType) ClampToQuantum((MagickRealType)
2912 QuantumRange*geometry_info.rho/100.0);
2913 if ((flags & SigmaValue) != 0)
2914 color->green=(MagickRealType) ClampToQuantum((MagickRealType)
2915 (scale*geometry_info.sigma+((double) QuantumRange+1.0)/2.0));
2916 if ((flags & XiValue) != 0)
2917 color->blue=(MagickRealType) ClampToQuantum((MagickRealType)
2918 (scale*geometry_info.xi+((double) QuantumRange+1.0)/2.0));
2919 }
2920 if ((LocaleCompare(colorspace,"gray") == 0) ||
2921 (LocaleCompare(colorspace,"lineargray") == 0))
2922 {
2923 color->green=color->red;
2924 color->blue=color->red;
2925 if (((flags & SigmaValue) != 0) && (color->matte != MagickFalse))
2926 color->opacity=(MagickRealType) ClampToQuantum((MagickRealType)
2927 ((double) QuantumRange-(double) QuantumRange*
2928 geometry_info.sigma));
2929 }
2930 if ((LocaleCompare(colorspace,"HCL") == 0) ||
2931 (LocaleCompare(colorspace,"HSB") == 0) ||
2932 (LocaleCompare(colorspace,"HSL") == 0) ||
2933 (LocaleCompare(colorspace,"HSV") == 0) ||
2934 (LocaleCompare(colorspace,"HWB") == 0))
2935 {
2936 PixelPacket
2937 pixel;
2938
2939 scale=1.0/255.0;
2940 geometry_info.sigma*=scale;
2941 geometry_info.xi*=scale;
2942 pixel.red=0.0;
2943 pixel.green=0.0;
2944 pixel.blue=0.0;
2945 switch (color->colorspace)
2946 {
2947 case HCLColorspace:
2948 {
2949 ConvertHCLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,360.0)/
2950 360.0,geometry_info.sigma,geometry_info.xi,&pixel.red,
2951 &pixel.green,&pixel.blue);
2952 break;
2953 }
2954 case HSBColorspace:
2955 {
2956 ConvertHSBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,
2957 360.0)/360.0,geometry_info.sigma,geometry_info.xi,
2958 &pixel.red,&pixel.green,&pixel.blue);
2959 break;
2960 }
2961 case HSLColorspace:
2962 {
2963 ConvertHSLToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,
2964 360.0)/360.0,geometry_info.sigma,geometry_info.xi,
2965 &pixel.red,&pixel.green,&pixel.blue);
2966 break;
2967 }
2968 case HSVColorspace:
2969 {
2970 ConvertHSVToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,
2971 360.0)/360.0,geometry_info.sigma,geometry_info.xi,
2972 &pixel.red,&pixel.green,&pixel.blue);
2973 break;
2974 }
2975 case HWBColorspace:
2976 {
2977 ConvertHWBToRGB(fmod(fmod(geometry_info.rho,360.0)+360.0,
2978 360.0)/360.0,geometry_info.sigma,geometry_info.xi,
2979 &pixel.red,&pixel.green,&pixel.blue);
2980 break;
2981 }
2982 default:
2983 break;
2984 }
2985 color->colorspace=sRGBColorspace;
2986 color->red=(MagickRealType) pixel.red;
2987 color->green=(MagickRealType) pixel.green;
2988 color->blue=(MagickRealType) pixel.blue;
2989 }
2990 return(MagickTrue);
2991 }
2992 /*
2993 Parse named color.
2994 */
2995 p=GetColorCompliance(name,compliance,exception);
2996 if (p == (const ColorInfo *) NULL)
2997 return(MagickFalse);
2998 color->colorspace=sRGBColorspace;
2999 if ((LocaleNCompare(name,"gray",4) == 0) ||
3000 (LocaleNCompare(name,"grey",4) == 0))
3001 color->colorspace=GRAYColorspace;
3002 color->depth=8;
3003 color->matte=p->color.opacity != (double) OpaqueOpacity ? MagickTrue :
3004 MagickFalse;
3005 color->red=(MagickRealType) p->color.red;
3006 color->green=(MagickRealType) p->color.green;
3007 color->blue=(MagickRealType) p->color.blue;
3008 color->opacity=(MagickRealType) p->color.opacity;
3009 color->index=0.0;
3010 return(MagickTrue);
3011}
3012
3013/*
3014%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3015% %
3016% %
3017% %
3018% Q u e r y M a g i c k C o l o r %
3019% %
3020% %
3021% %
3022%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3023%
3024% QueryMagickColor() returns the red, green, blue, and opacity intensities
3025% for a given color name.
3026%
3027% The format of the QueryMagickColor method is:
3028%
3029% MagickBooleanType QueryMagickColor(const char *name,
3030% MagickPixelPacket *color,ExceptionInfo *exception)
3031%
3032% A description of each parameter follows:
3033%
3034% o name: the color name (e.g. white, blue, yellow).
3035%
3036% o color: the red, green, blue, and opacity intensities values of the
3037% named color in this structure.
3038%
3039% o exception: return any errors or warnings in this structure.
3040%
3041*/
3042MagickExport MagickBooleanType QueryMagickColor(const char *name,
3043 MagickPixelPacket *color,ExceptionInfo *exception)
3044{
3045 return(QueryMagickColorCompliance(name,AllCompliance,color,exception));
3046}
3047
3048/*
3049%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3050% %
3051% %
3052% %
3053% Q u e r y M a g i c k C o l o r n a m e %
3054% %
3055% %
3056% %
3057%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3058%
3059% QueryMagickColorname() returns a named color for the given color intensity.
3060% If an exact match is not found, a hex value is returned instead. For
3061% example an intensity of rgb:(0,0,0) returns black whereas rgb:(223,223,223)
3062% returns #dfdfdf.
3063%
3064% The format of the QueryMagickColorname method is:
3065%
3066% MagickBooleanType QueryMagickColorname(const Image *image,
3067% const PixelPacket *color,const ComplianceType compliance,char *name,
3068% ExceptionInfo *exception)
3069%
3070% A description of each parameter follows.
3071%
3072% o image: the image.
3073%
3074% o color: the color intensities.
3075%
3076% o Compliance: Adhere to this color standard: SVG, X11, or XPM.
3077%
3078% o name: Return the color name or hex value.
3079%
3080% o exception: return any errors or warnings in this structure.
3081%
3082*/
3083MagickExport MagickBooleanType QueryMagickColorname(const Image *image,
3084 const MagickPixelPacket *color,const ComplianceType compliance,
3085 char *name,ExceptionInfo *exception)
3086{
3087 const ColorInfo
3088 *p;
3089
3090 MagickPixelPacket
3091 pixel;
3092
3093 MagickRealType
3094 opacity;
3095
3096 *name='\0';
3097 pixel=(*color);
3098 if (compliance == XPMCompliance)
3099 {
3100 pixel.matte=MagickFalse;
3101 pixel.depth=(size_t) MagickMin(1.0*image->depth,16.0);
3102 }
3103 GetColorTuple(&pixel,compliance != SVGCompliance ? MagickTrue : MagickFalse,
3104 name);
3105 if (IssRGBColorspace(pixel.colorspace) == MagickFalse)
3106 return(MagickFalse);
3107 (void) GetColorInfo("*",exception);
3108 ResetLinkedListIterator(color_cache);
3109 opacity=image->matte != MagickFalse ? color->opacity : (double) OpaqueOpacity;
3110 p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
3111 while (p != (const ColorInfo *) NULL)
3112 {
3113 if (((p->compliance & compliance) != 0) && ((p->color.red == color->red)) &&
3114 (p->color.green == color->green) && (p->color.blue == color->blue) &&
3115 (p->color.opacity == opacity))
3116 {
3117 (void) CopyMagickString(name,p->name,MaxTextExtent);
3118 break;
3119 }
3120 p=(const ColorInfo *) GetNextValueInLinkedList(color_cache);
3121 }
3122 return(MagickTrue);
3123}