1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
35 #include "gdkprivate.h"
39 #define strcasecmp stricmp
42 static gint gdk_colormap_match_color (GdkColormap *cmap,
44 const gchar *available);
45 static void gdk_colormap_add (GdkColormap *cmap);
46 static void gdk_colormap_remove (GdkColormap *cmap);
47 static guint gdk_colormap_hash (Colormap *cmap);
48 static gint gdk_colormap_cmp (Colormap *a,
50 static void gdk_colormap_real_destroy (GdkColormap *colormap);
52 static GHashTable *colormap_hash = NULL;
55 alloc_color_cells(Colormap colormap,
57 unsigned long plane_masks_return[],
59 unsigned long pixels_return[],
62 unsigned int i, nfree, iret;
65 for (i = 0; i < colormap->size && nfree < npixels; i++)
66 if (!colormap->in_use[i])
69 if (colormap->size + npixels - nfree > colormap->sizepalette)
71 g_warning ("alloc_color_cells: too large palette: %d",
72 colormap->size + npixels);
77 for (i = 0; i < colormap->size && iret < npixels; i++)
78 if (!colormap->in_use[i])
80 colormap->in_use[i] = TRUE;
81 pixels_return[iret] = i;
87 int nmore = npixels - nfree;
89 /* I don't understand why, if the code below in #if 0 is
90 enabled, gdkrgb fails miserably. The palette doesn't get
91 realized correctly. There doesn't seem to be any harm done by
92 keeping this code out, either. */
93 #ifdef SOME_STRANGE_BUG
94 if (!ResizePalette (colormap->palette, colormap->size + nmore))
96 g_warning ("alloc_color_cells: ResizePalette to %d failed",
97 colormap->size + nmore);
100 g_print("alloc_color_cells: %#x to %d\n",
101 colormap->palette, colormap->size + nmore);
103 for (i = colormap->size; i < colormap->size + nmore; i++)
105 pixels_return[iret] = i;
107 colormap->in_use[i] = TRUE;
109 #ifdef SOME_STRANGE_BUG
110 colormap->size += nmore;
116 /* The following functions are from Tk8.0, but heavily modified.
117 Here are tk's licensing terms. I hope these terms don't conflict
118 with the GNU Library General Public License? They shouldn't, as
119 they are looser that the GLPL, yes? */
122 This software is copyrighted by the Regents of the University of
123 California, Sun Microsystems, Inc., and other parties. The following
124 terms apply to all files associated with the software unless explicitly
125 disclaimed in individual files.
127 The authors hereby grant permission to use, copy, modify, distribute,
128 and license this software and its documentation for any purpose, provided
129 that existing copyright notices are retained in all copies and that this
130 notice is included verbatim in any distributions. No written agreement,
131 license, or royalty fee is required for any of the authorized uses.
132 Modifications to this software may be copyrighted by their authors
133 and need not follow the licensing terms described here, provided that
134 the new terms are clearly indicated on the first page of each file where
137 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
138 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
139 ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
140 DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
141 POSSIBILITY OF SUCH DAMAGE.
143 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
144 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
145 FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
146 IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
147 NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
150 GOVERNMENT USE: If you are acquiring this software on behalf of the
151 U.S. government, the Government shall have only "Restricted Rights"
152 in the software and related documentation as defined in the Federal
153 Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
154 are acquiring the software on behalf of the Department of Defense, the
155 software shall be classified as "Commercial Computer Software" and the
156 Government shall have only "Restricted Rights" as defined in Clause
157 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
158 authors grant the U.S. Government and others acting in its behalf
159 permission to use and distribute the software in accordance with the
160 terms specified in this license.
163 *----------------------------------------------------------------------
167 * Find the closest available color to the specified XColor.
170 * Updates the color argument and returns 1 on success. Otherwise
174 * Allocates a new color in the palette.
176 *----------------------------------------------------------------------
180 alloc_color(Colormap colormap,
184 PALETTEENTRY entry, closeEntry;
191 if (colormap->rc_palette)
193 COLORREF newPixel, closePixel;
197 * Find the nearest existing palette entry.
200 newPixel = RGB (entry.peRed, entry.peGreen, entry.peBlue);
201 index = GetNearestPaletteIndex (colormap->palette, newPixel);
202 GetPaletteEntries (colormap->palette, index, 1, &closeEntry);
203 closePixel = RGB (closeEntry.peRed, closeEntry.peGreen,
206 if (newPixel != closePixel)
208 /* Not a perfect match. */
209 if (!colormap->in_use[index])
211 /* It was a free'd entry anyway, so we can use it, and
212 set it to the correct color. */
213 if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
214 g_warning ("alloc_color: SetPaletteEntries #1 failed");
218 /* The close entry found is in use, so search for a
221 for (i = 0; i < colormap->size; i++)
222 if (!colormap->in_use[i])
224 /* A free slot, use it. */
225 if (SetPaletteEntries (colormap->palette,
226 index, 1, &entry) == 0)
227 g_warning ("alloc_color: SetPaletteEntries #2 failed");
231 if (i == colormap->size)
233 /* No free slots found. If the palette isn't maximal
235 if (colormap->size == colormap->sizepalette)
237 /* The palette is maximal, and no free slots available,
238 so use the close entry, then, dammit. */
243 /* There is room to grow the palette. */
244 index = colormap->size;
246 if (!ResizePalette (colormap->palette, colormap->size))
247 g_warning ("alloc_color: ResizePalette to %d failed",
249 if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
250 g_warning ("alloc_color: SetPaletteEntries #3 failed");
254 colormap->stale = TRUE;
258 /* We got a match, so use it. */
262 colormap->in_use[index] = TRUE;
264 g_print("alloc_color from %#x: index %d for %02x %02x %02x\n",
265 colormap->palette, index,
266 entry.peRed, entry.peGreen, entry.peBlue);
272 * Determine what color will actually be used on non-colormap systems.
274 *pixelp = GetNearestColor (gdk_DC, RGB(entry.peRed, entry.peGreen, entry.peBlue));
276 color->peRed = GetRValue (*pixelp);
277 color->peGreen = GetGValue (*pixelp);
278 color->peBlue = GetBValue (*pixelp);
285 *----------------------------------------------------------------------
289 * Deallocate a block of colors.
295 * Removes entries for the current palette and compacts the
298 *----------------------------------------------------------------------
302 XFreeColors(Colormap colormap,
308 PALETTEENTRY entries[256];
311 * We don't have to do anything for non-palette devices.
314 if (colormap->rc_palette)
317 int lowestpixel = 256;
318 int highestpixel = -1;
320 npal = GetPaletteEntries (colormap->palette, 0, 256, entries);
321 for (i = 0; i < npixels; i++)
323 int pixel = pixels[i];
325 if (pixel < lowestpixel)
327 if (pixel > highestpixel)
328 highestpixel = pixel;
330 colormap->in_use[pixel] = FALSE;
332 entries[pixel] = entries[0];
335 if (SetPaletteEntries (colormap->palette, lowestpixel,
336 highestpixel - lowestpixel + 1,
337 entries + lowestpixel) == 0)
338 g_warning ("XFreeColors: SetPaletteEntries failed");
340 colormap->stale = TRUE;
342 g_print("XFreeColors %#x lowestpixel = %d, highestpixel = %d\n",
343 colormap->palette, lowestpixel, highestpixel);
349 *----------------------------------------------------------------------
353 * Allocate a new colormap.
356 * Returns a newly allocated colormap.
359 * Allocates an empty palette and color list.
361 *----------------------------------------------------------------------
365 create_colormap (HWND w,
369 char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
370 LOGPALETTE *logPalettePtr;
371 PALETTEENTRY *entryPtr;
377 /* Should the alloc parameter do something? */
380 /* Allocate a starting palette with all of the reserved colors. */
382 logPalettePtr = (LOGPALETTE *) logPalBuf;
383 logPalettePtr->palVersion = 0x300;
384 sysPal = (HPALETTE) GetStockObject (DEFAULT_PALETTE);
385 logPalettePtr->palNumEntries =
386 GetPaletteEntries (sysPal, 0, 256, logPalettePtr->palPalEntry);
388 colormap = (Colormap) g_new (ColormapStruct, 1);
389 colormap->size = logPalettePtr->palNumEntries;
390 colormap->stale = TRUE;
391 colormap->palette = CreatePalette (logPalettePtr);
393 colormap->rc_palette = ((GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) != 0);
394 if (colormap->rc_palette)
396 colormap->sizepalette = GetDeviceCaps (hdc, SIZEPALETTE);
397 colormap->in_use = g_new (gboolean, colormap->sizepalette);
398 /* Mark static colors in use. */
399 for (i = 0; i < logPalettePtr->palNumEntries; i++)
400 colormap->in_use[i] = TRUE;
401 /* Mark rest not in use */
402 for (i = logPalettePtr->palNumEntries; i < colormap->sizepalette; i++)
403 colormap->in_use[i] = FALSE;
405 ReleaseDC (NULL, hdc);
411 *----------------------------------------------------------------------
415 * Frees the resources associated with the given colormap.
421 * Deletes the palette associated with the colormap. Note that
422 * the palette must not be selected into a device context when
425 *----------------------------------------------------------------------
429 XFreeColormap(Colormap colormap)
432 if (!DeleteObject (colormap->palette))
434 g_error ("Unable to free colormap, palette is still selected.");
446 static XColorEntry xColors[] = {
447 { "alice blue", 240, 248, 255 },
448 { "AliceBlue", 240, 248, 255 },
449 { "antique white", 250, 235, 215 },
450 { "AntiqueWhite", 250, 235, 215 },
451 { "AntiqueWhite1", 255, 239, 219 },
452 { "AntiqueWhite2", 238, 223, 204 },
453 { "AntiqueWhite3", 205, 192, 176 },
454 { "AntiqueWhite4", 139, 131, 120 },
455 { "aquamarine", 127, 255, 212 },
456 { "aquamarine1", 127, 255, 212 },
457 { "aquamarine2", 118, 238, 198 },
458 { "aquamarine3", 102, 205, 170 },
459 { "aquamarine4", 69, 139, 116 },
460 { "azure", 240, 255, 255 },
461 { "azure1", 240, 255, 255 },
462 { "azure2", 224, 238, 238 },
463 { "azure3", 193, 205, 205 },
464 { "azure4", 131, 139, 139 },
465 { "beige", 245, 245, 220 },
466 { "bisque", 255, 228, 196 },
467 { "bisque1", 255, 228, 196 },
468 { "bisque2", 238, 213, 183 },
469 { "bisque3", 205, 183, 158 },
470 { "bisque4", 139, 125, 107 },
471 { "black", 0, 0, 0 },
472 { "blanched almond", 255, 235, 205 },
473 { "BlanchedAlmond", 255, 235, 205 },
474 { "blue", 0, 0, 255 },
475 { "blue violet", 138, 43, 226 },
476 { "blue1", 0, 0, 255 },
477 { "blue2", 0, 0, 238 },
478 { "blue3", 0, 0, 205 },
479 { "blue4", 0, 0, 139 },
480 { "BlueViolet", 138, 43, 226 },
481 { "brown", 165, 42, 42 },
482 { "brown1", 255, 64, 64 },
483 { "brown2", 238, 59, 59 },
484 { "brown3", 205, 51, 51 },
485 { "brown4", 139, 35, 35 },
486 { "burlywood", 222, 184, 135 },
487 { "burlywood1", 255, 211, 155 },
488 { "burlywood2", 238, 197, 145 },
489 { "burlywood3", 205, 170, 125 },
490 { "burlywood4", 139, 115, 85 },
491 { "cadet blue", 95, 158, 160 },
492 { "CadetBlue", 95, 158, 160 },
493 { "CadetBlue1", 152, 245, 255 },
494 { "CadetBlue2", 142, 229, 238 },
495 { "CadetBlue3", 122, 197, 205 },
496 { "CadetBlue4", 83, 134, 139 },
497 { "chartreuse", 127, 255, 0 },
498 { "chartreuse1", 127, 255, 0 },
499 { "chartreuse2", 118, 238, 0 },
500 { "chartreuse3", 102, 205, 0 },
501 { "chartreuse4", 69, 139, 0 },
502 { "chocolate", 210, 105, 30 },
503 { "chocolate1", 255, 127, 36 },
504 { "chocolate2", 238, 118, 33 },
505 { "chocolate3", 205, 102, 29 },
506 { "chocolate4", 139, 69, 19 },
507 { "coral", 255, 127, 80 },
508 { "coral1", 255, 114, 86 },
509 { "coral2", 238, 106, 80 },
510 { "coral3", 205, 91, 69 },
511 { "coral4", 139, 62, 47 },
512 { "cornflower blue", 100, 149, 237 },
513 { "CornflowerBlue", 100, 149, 237 },
514 { "cornsilk", 255, 248, 220 },
515 { "cornsilk1", 255, 248, 220 },
516 { "cornsilk2", 238, 232, 205 },
517 { "cornsilk3", 205, 200, 177 },
518 { "cornsilk4", 139, 136, 120 },
519 { "cyan", 0, 255, 255 },
520 { "cyan1", 0, 255, 255 },
521 { "cyan2", 0, 238, 238 },
522 { "cyan3", 0, 205, 205 },
523 { "cyan4", 0, 139, 139 },
524 { "dark blue", 0, 0, 139 },
525 { "dark cyan", 0, 139, 139 },
526 { "dark goldenrod", 184, 134, 11 },
527 { "dark gray", 169, 169, 169 },
528 { "dark green", 0, 100, 0 },
529 { "dark grey", 169, 169, 169 },
530 { "dark khaki", 189, 183, 107 },
531 { "dark magenta", 139, 0, 139 },
532 { "dark olive green", 85, 107, 47 },
533 { "dark orange", 255, 140, 0 },
534 { "dark orchid", 153, 50, 204 },
535 { "dark red", 139, 0, 0 },
536 { "dark salmon", 233, 150, 122 },
537 { "dark sea green", 143, 188, 143 },
538 { "dark slate blue", 72, 61, 139 },
539 { "dark slate gray", 47, 79, 79 },
540 { "dark slate grey", 47, 79, 79 },
541 { "dark turquoise", 0, 206, 209 },
542 { "dark violet", 148, 0, 211 },
543 { "DarkBlue", 0, 0, 139 },
544 { "DarkCyan", 0, 139, 139 },
545 { "DarkGoldenrod", 184, 134, 11 },
546 { "DarkGoldenrod1", 255, 185, 15 },
547 { "DarkGoldenrod2", 238, 173, 14 },
548 { "DarkGoldenrod3", 205, 149, 12 },
549 { "DarkGoldenrod4", 139, 101, 8 },
550 { "DarkGray", 169, 169, 169 },
551 { "DarkGreen", 0, 100, 0 },
552 { "DarkGrey", 169, 169, 169 },
553 { "DarkKhaki", 189, 183, 107 },
554 { "DarkMagenta", 139, 0, 139 },
555 { "DarkOliveGreen", 85, 107, 47 },
556 { "DarkOliveGreen1", 202, 255, 112 },
557 { "DarkOliveGreen2", 188, 238, 104 },
558 { "DarkOliveGreen3", 162, 205, 90 },
559 { "DarkOliveGreen4", 110, 139, 61 },
560 { "DarkOrange", 255, 140, 0 },
561 { "DarkOrange1", 255, 127, 0 },
562 { "DarkOrange2", 238, 118, 0 },
563 { "DarkOrange3", 205, 102, 0 },
564 { "DarkOrange4", 139, 69, 0 },
565 { "DarkOrchid", 153, 50, 204 },
566 { "DarkOrchid1", 191, 62, 255 },
567 { "DarkOrchid2", 178, 58, 238 },
568 { "DarkOrchid3", 154, 50, 205 },
569 { "DarkOrchid4", 104, 34, 139 },
570 { "DarkRed", 139, 0, 0 },
571 { "DarkSalmon", 233, 150, 122 },
572 { "DarkSeaGreen", 143, 188, 143 },
573 { "DarkSeaGreen1", 193, 255, 193 },
574 { "DarkSeaGreen2", 180, 238, 180 },
575 { "DarkSeaGreen3", 155, 205, 155 },
576 { "DarkSeaGreen4", 105, 139, 105 },
577 { "DarkSlateBlue", 72, 61, 139 },
578 { "DarkSlateGray", 47, 79, 79 },
579 { "DarkSlateGray1", 151, 255, 255 },
580 { "DarkSlateGray2", 141, 238, 238 },
581 { "DarkSlateGray3", 121, 205, 205 },
582 { "DarkSlateGray4", 82, 139, 139 },
583 { "DarkSlateGrey", 47, 79, 79 },
584 { "DarkTurquoise", 0, 206, 209 },
585 { "DarkViolet", 148, 0, 211 },
586 { "deep pink", 255, 20, 147 },
587 { "deep sky blue", 0, 191, 255 },
588 { "DeepPink", 255, 20, 147 },
589 { "DeepPink1", 255, 20, 147 },
590 { "DeepPink2", 238, 18, 137 },
591 { "DeepPink3", 205, 16, 118 },
592 { "DeepPink4", 139, 10, 80 },
593 { "DeepSkyBlue", 0, 191, 255 },
594 { "DeepSkyBlue1", 0, 191, 255 },
595 { "DeepSkyBlue2", 0, 178, 238 },
596 { "DeepSkyBlue3", 0, 154, 205 },
597 { "DeepSkyBlue4", 0, 104, 139 },
598 { "dim gray", 105, 105, 105 },
599 { "dim grey", 105, 105, 105 },
600 { "DimGray", 105, 105, 105 },
601 { "DimGrey", 105, 105, 105 },
602 { "dodger blue", 30, 144, 255 },
603 { "DodgerBlue", 30, 144, 255 },
604 { "DodgerBlue1", 30, 144, 255 },
605 { "DodgerBlue2", 28, 134, 238 },
606 { "DodgerBlue3", 24, 116, 205 },
607 { "DodgerBlue4", 16, 78, 139 },
608 { "firebrick", 178, 34, 34 },
609 { "firebrick1", 255, 48, 48 },
610 { "firebrick2", 238, 44, 44 },
611 { "firebrick3", 205, 38, 38 },
612 { "firebrick4", 139, 26, 26 },
613 { "floral white", 255, 250, 240 },
614 { "FloralWhite", 255, 250, 240 },
615 { "forest green", 34, 139, 34 },
616 { "ForestGreen", 34, 139, 34 },
617 { "gainsboro", 220, 220, 220 },
618 { "ghost white", 248, 248, 255 },
619 { "GhostWhite", 248, 248, 255 },
620 { "gold", 255, 215, 0 },
621 { "gold1", 255, 215, 0 },
622 { "gold2", 238, 201, 0 },
623 { "gold3", 205, 173, 0 },
624 { "gold4", 139, 117, 0 },
625 { "goldenrod", 218, 165, 32 },
626 { "goldenrod1", 255, 193, 37 },
627 { "goldenrod2", 238, 180, 34 },
628 { "goldenrod3", 205, 155, 29 },
629 { "goldenrod4", 139, 105, 20 },
630 { "gray", 190, 190, 190 },
631 { "gray0", 0, 0, 0 },
632 { "gray1", 3, 3, 3 },
633 { "gray10", 26, 26, 26 },
634 { "gray100", 255, 255, 255 },
635 { "gray11", 28, 28, 28 },
636 { "gray12", 31, 31, 31 },
637 { "gray13", 33, 33, 33 },
638 { "gray14", 36, 36, 36 },
639 { "gray15", 38, 38, 38 },
640 { "gray16", 41, 41, 41 },
641 { "gray17", 43, 43, 43 },
642 { "gray18", 46, 46, 46 },
643 { "gray19", 48, 48, 48 },
644 { "gray2", 5, 5, 5 },
645 { "gray20", 51, 51, 51 },
646 { "gray21", 54, 54, 54 },
647 { "gray22", 56, 56, 56 },
648 { "gray23", 59, 59, 59 },
649 { "gray24", 61, 61, 61 },
650 { "gray25", 64, 64, 64 },
651 { "gray26", 66, 66, 66 },
652 { "gray27", 69, 69, 69 },
653 { "gray28", 71, 71, 71 },
654 { "gray29", 74, 74, 74 },
655 { "gray3", 8, 8, 8 },
656 { "gray30", 77, 77, 77 },
657 { "gray31", 79, 79, 79 },
658 { "gray32", 82, 82, 82 },
659 { "gray33", 84, 84, 84 },
660 { "gray34", 87, 87, 87 },
661 { "gray35", 89, 89, 89 },
662 { "gray36", 92, 92, 92 },
663 { "gray37", 94, 94, 94 },
664 { "gray38", 97, 97, 97 },
665 { "gray39", 99, 99, 99 },
666 { "gray4", 10, 10, 10 },
667 { "gray40", 102, 102, 102 },
668 { "gray41", 105, 105, 105 },
669 { "gray42", 107, 107, 107 },
670 { "gray43", 110, 110, 110 },
671 { "gray44", 112, 112, 112 },
672 { "gray45", 115, 115, 115 },
673 { "gray46", 117, 117, 117 },
674 { "gray47", 120, 120, 120 },
675 { "gray48", 122, 122, 122 },
676 { "gray49", 125, 125, 125 },
677 { "gray5", 13, 13, 13 },
678 { "gray50", 127, 127, 127 },
679 { "gray51", 130, 130, 130 },
680 { "gray52", 133, 133, 133 },
681 { "gray53", 135, 135, 135 },
682 { "gray54", 138, 138, 138 },
683 { "gray55", 140, 140, 140 },
684 { "gray56", 143, 143, 143 },
685 { "gray57", 145, 145, 145 },
686 { "gray58", 148, 148, 148 },
687 { "gray59", 150, 150, 150 },
688 { "gray6", 15, 15, 15 },
689 { "gray60", 153, 153, 153 },
690 { "gray61", 156, 156, 156 },
691 { "gray62", 158, 158, 158 },
692 { "gray63", 161, 161, 161 },
693 { "gray64", 163, 163, 163 },
694 { "gray65", 166, 166, 166 },
695 { "gray66", 168, 168, 168 },
696 { "gray67", 171, 171, 171 },
697 { "gray68", 173, 173, 173 },
698 { "gray69", 176, 176, 176 },
699 { "gray7", 18, 18, 18 },
700 { "gray70", 179, 179, 179 },
701 { "gray71", 181, 181, 181 },
702 { "gray72", 184, 184, 184 },
703 { "gray73", 186, 186, 186 },
704 { "gray74", 189, 189, 189 },
705 { "gray75", 191, 191, 191 },
706 { "gray76", 194, 194, 194 },
707 { "gray77", 196, 196, 196 },
708 { "gray78", 199, 199, 199 },
709 { "gray79", 201, 201, 201 },
710 { "gray8", 20, 20, 20 },
711 { "gray80", 204, 204, 204 },
712 { "gray81", 207, 207, 207 },
713 { "gray82", 209, 209, 209 },
714 { "gray83", 212, 212, 212 },
715 { "gray84", 214, 214, 214 },
716 { "gray85", 217, 217, 217 },
717 { "gray86", 219, 219, 219 },
718 { "gray87", 222, 222, 222 },
719 { "gray88", 224, 224, 224 },
720 { "gray89", 227, 227, 227 },
721 { "gray9", 23, 23, 23 },
722 { "gray90", 229, 229, 229 },
723 { "gray91", 232, 232, 232 },
724 { "gray92", 235, 235, 235 },
725 { "gray93", 237, 237, 237 },
726 { "gray94", 240, 240, 240 },
727 { "gray95", 242, 242, 242 },
728 { "gray96", 245, 245, 245 },
729 { "gray97", 247, 247, 247 },
730 { "gray98", 250, 250, 250 },
731 { "gray99", 252, 252, 252 },
732 { "green", 0, 255, 0 },
733 { "green yellow", 173, 255, 47 },
734 { "green1", 0, 255, 0 },
735 { "green2", 0, 238, 0 },
736 { "green3", 0, 205, 0 },
737 { "green4", 0, 139, 0 },
738 { "GreenYellow", 173, 255, 47 },
739 { "grey", 190, 190, 190 },
740 { "grey0", 0, 0, 0 },
741 { "grey1", 3, 3, 3 },
742 { "grey10", 26, 26, 26 },
743 { "grey100", 255, 255, 255 },
744 { "grey11", 28, 28, 28 },
745 { "grey12", 31, 31, 31 },
746 { "grey13", 33, 33, 33 },
747 { "grey14", 36, 36, 36 },
748 { "grey15", 38, 38, 38 },
749 { "grey16", 41, 41, 41 },
750 { "grey17", 43, 43, 43 },
751 { "grey18", 46, 46, 46 },
752 { "grey19", 48, 48, 48 },
753 { "grey2", 5, 5, 5 },
754 { "grey20", 51, 51, 51 },
755 { "grey21", 54, 54, 54 },
756 { "grey22", 56, 56, 56 },
757 { "grey23", 59, 59, 59 },
758 { "grey24", 61, 61, 61 },
759 { "grey25", 64, 64, 64 },
760 { "grey26", 66, 66, 66 },
761 { "grey27", 69, 69, 69 },
762 { "grey28", 71, 71, 71 },
763 { "grey29", 74, 74, 74 },
764 { "grey3", 8, 8, 8 },
765 { "grey30", 77, 77, 77 },
766 { "grey31", 79, 79, 79 },
767 { "grey32", 82, 82, 82 },
768 { "grey33", 84, 84, 84 },
769 { "grey34", 87, 87, 87 },
770 { "grey35", 89, 89, 89 },
771 { "grey36", 92, 92, 92 },
772 { "grey37", 94, 94, 94 },
773 { "grey38", 97, 97, 97 },
774 { "grey39", 99, 99, 99 },
775 { "grey4", 10, 10, 10 },
776 { "grey40", 102, 102, 102 },
777 { "grey41", 105, 105, 105 },
778 { "grey42", 107, 107, 107 },
779 { "grey43", 110, 110, 110 },
780 { "grey44", 112, 112, 112 },
781 { "grey45", 115, 115, 115 },
782 { "grey46", 117, 117, 117 },
783 { "grey47", 120, 120, 120 },
784 { "grey48", 122, 122, 122 },
785 { "grey49", 125, 125, 125 },
786 { "grey5", 13, 13, 13 },
787 { "grey50", 127, 127, 127 },
788 { "grey51", 130, 130, 130 },
789 { "grey52", 133, 133, 133 },
790 { "grey53", 135, 135, 135 },
791 { "grey54", 138, 138, 138 },
792 { "grey55", 140, 140, 140 },
793 { "grey56", 143, 143, 143 },
794 { "grey57", 145, 145, 145 },
795 { "grey58", 148, 148, 148 },
796 { "grey59", 150, 150, 150 },
797 { "grey6", 15, 15, 15 },
798 { "grey60", 153, 153, 153 },
799 { "grey61", 156, 156, 156 },
800 { "grey62", 158, 158, 158 },
801 { "grey63", 161, 161, 161 },
802 { "grey64", 163, 163, 163 },
803 { "grey65", 166, 166, 166 },
804 { "grey66", 168, 168, 168 },
805 { "grey67", 171, 171, 171 },
806 { "grey68", 173, 173, 173 },
807 { "grey69", 176, 176, 176 },
808 { "grey7", 18, 18, 18 },
809 { "grey70", 179, 179, 179 },
810 { "grey71", 181, 181, 181 },
811 { "grey72", 184, 184, 184 },
812 { "grey73", 186, 186, 186 },
813 { "grey74", 189, 189, 189 },
814 { "grey75", 191, 191, 191 },
815 { "grey76", 194, 194, 194 },
816 { "grey77", 196, 196, 196 },
817 { "grey78", 199, 199, 199 },
818 { "grey79", 201, 201, 201 },
819 { "grey8", 20, 20, 20 },
820 { "grey80", 204, 204, 204 },
821 { "grey81", 207, 207, 207 },
822 { "grey82", 209, 209, 209 },
823 { "grey83", 212, 212, 212 },
824 { "grey84", 214, 214, 214 },
825 { "grey85", 217, 217, 217 },
826 { "grey86", 219, 219, 219 },
827 { "grey87", 222, 222, 222 },
828 { "grey88", 224, 224, 224 },
829 { "grey89", 227, 227, 227 },
830 { "grey9", 23, 23, 23 },
831 { "grey90", 229, 229, 229 },
832 { "grey91", 232, 232, 232 },
833 { "grey92", 235, 235, 235 },
834 { "grey93", 237, 237, 237 },
835 { "grey94", 240, 240, 240 },
836 { "grey95", 242, 242, 242 },
837 { "grey96", 245, 245, 245 },
838 { "grey97", 247, 247, 247 },
839 { "grey98", 250, 250, 250 },
840 { "grey99", 252, 252, 252 },
841 { "honeydew", 240, 255, 240 },
842 { "honeydew1", 240, 255, 240 },
843 { "honeydew2", 224, 238, 224 },
844 { "honeydew3", 193, 205, 193 },
845 { "honeydew4", 131, 139, 131 },
846 { "hot pink", 255, 105, 180 },
847 { "HotPink", 255, 105, 180 },
848 { "HotPink1", 255, 110, 180 },
849 { "HotPink2", 238, 106, 167 },
850 { "HotPink3", 205, 96, 144 },
851 { "HotPink4", 139, 58, 98 },
852 { "indian red", 205, 92, 92 },
853 { "IndianRed", 205, 92, 92 },
854 { "IndianRed1", 255, 106, 106 },
855 { "IndianRed2", 238, 99, 99 },
856 { "IndianRed3", 205, 85, 85 },
857 { "IndianRed4", 139, 58, 58 },
858 { "ivory", 255, 255, 240 },
859 { "ivory1", 255, 255, 240 },
860 { "ivory2", 238, 238, 224 },
861 { "ivory3", 205, 205, 193 },
862 { "ivory4", 139, 139, 131 },
863 { "khaki", 240, 230, 140 },
864 { "khaki1", 255, 246, 143 },
865 { "khaki2", 238, 230, 133 },
866 { "khaki3", 205, 198, 115 },
867 { "khaki4", 139, 134, 78 },
868 { "lavender", 230, 230, 250 },
869 { "lavender blush", 255, 240, 245 },
870 { "LavenderBlush", 255, 240, 245 },
871 { "LavenderBlush1", 255, 240, 245 },
872 { "LavenderBlush2", 238, 224, 229 },
873 { "LavenderBlush3", 205, 193, 197 },
874 { "LavenderBlush4", 139, 131, 134 },
875 { "lawn green", 124, 252, 0 },
876 { "LawnGreen", 124, 252, 0 },
877 { "lemon chiffon", 255, 250, 205 },
878 { "LemonChiffon", 255, 250, 205 },
879 { "LemonChiffon1", 255, 250, 205 },
880 { "LemonChiffon2", 238, 233, 191 },
881 { "LemonChiffon3", 205, 201, 165 },
882 { "LemonChiffon4", 139, 137, 112 },
883 { "light blue", 173, 216, 230 },
884 { "light coral", 240, 128, 128 },
885 { "light cyan", 224, 255, 255 },
886 { "light goldenrod", 238, 221, 130 },
887 { "light goldenrod yellow", 250, 250, 210 },
888 { "light gray", 211, 211, 211 },
889 { "light green", 144, 238, 144 },
890 { "light grey", 211, 211, 211 },
891 { "light pink", 255, 182, 193 },
892 { "light salmon", 255, 160, 122 },
893 { "light sea green", 32, 178, 170 },
894 { "light sky blue", 135, 206, 250 },
895 { "light slate blue", 132, 112, 255 },
896 { "light slate gray", 119, 136, 153 },
897 { "light slate grey", 119, 136, 153 },
898 { "light steel blue", 176, 196, 222 },
899 { "light yellow", 255, 255, 224 },
900 { "LightBlue", 173, 216, 230 },
901 { "LightBlue1", 191, 239, 255 },
902 { "LightBlue2", 178, 223, 238 },
903 { "LightBlue3", 154, 192, 205 },
904 { "LightBlue4", 104, 131, 139 },
905 { "LightCoral", 240, 128, 128 },
906 { "LightCyan", 224, 255, 255 },
907 { "LightCyan1", 224, 255, 255 },
908 { "LightCyan2", 209, 238, 238 },
909 { "LightCyan3", 180, 205, 205 },
910 { "LightCyan4", 122, 139, 139 },
911 { "LightGoldenrod", 238, 221, 130 },
912 { "LightGoldenrod1", 255, 236, 139 },
913 { "LightGoldenrod2", 238, 220, 130 },
914 { "LightGoldenrod3", 205, 190, 112 },
915 { "LightGoldenrod4", 139, 129, 76 },
916 { "LightGoldenrodYellow", 250, 250, 210 },
917 { "LightGray", 211, 211, 211 },
918 { "LightGreen", 144, 238, 144 },
919 { "LightGrey", 211, 211, 211 },
920 { "LightPink", 255, 182, 193 },
921 { "LightPink1", 255, 174, 185 },
922 { "LightPink2", 238, 162, 173 },
923 { "LightPink3", 205, 140, 149 },
924 { "LightPink4", 139, 95, 101 },
925 { "LightSalmon", 255, 160, 122 },
926 { "LightSalmon1", 255, 160, 122 },
927 { "LightSalmon2", 238, 149, 114 },
928 { "LightSalmon3", 205, 129, 98 },
929 { "LightSalmon4", 139, 87, 66 },
930 { "LightSeaGreen", 32, 178, 170 },
931 { "LightSkyBlue", 135, 206, 250 },
932 { "LightSkyBlue1", 176, 226, 255 },
933 { "LightSkyBlue2", 164, 211, 238 },
934 { "LightSkyBlue3", 141, 182, 205 },
935 { "LightSkyBlue4", 96, 123, 139 },
936 { "LightSlateBlue", 132, 112, 255 },
937 { "LightSlateGray", 119, 136, 153 },
938 { "LightSlateGrey", 119, 136, 153 },
939 { "LightSteelBlue", 176, 196, 222 },
940 { "LightSteelBlue1", 202, 225, 255 },
941 { "LightSteelBlue2", 188, 210, 238 },
942 { "LightSteelBlue3", 162, 181, 205 },
943 { "LightSteelBlue4", 110, 123, 139 },
944 { "LightYellow", 255, 255, 224 },
945 { "LightYellow1", 255, 255, 224 },
946 { "LightYellow2", 238, 238, 209 },
947 { "LightYellow3", 205, 205, 180 },
948 { "LightYellow4", 139, 139, 122 },
949 { "lime green", 50, 205, 50 },
950 { "LimeGreen", 50, 205, 50 },
951 { "linen", 250, 240, 230 },
952 { "magenta", 255, 0, 255 },
953 { "magenta1", 255, 0, 255 },
954 { "magenta2", 238, 0, 238 },
955 { "magenta3", 205, 0, 205 },
956 { "magenta4", 139, 0, 139 },
957 { "maroon", 176, 48, 96 },
958 { "maroon1", 255, 52, 179 },
959 { "maroon2", 238, 48, 167 },
960 { "maroon3", 205, 41, 144 },
961 { "maroon4", 139, 28, 98 },
962 { "medium aquamarine", 102, 205, 170 },
963 { "medium blue", 0, 0, 205 },
964 { "medium orchid", 186, 85, 211 },
965 { "medium purple", 147, 112, 219 },
966 { "medium sea green", 60, 179, 113 },
967 { "medium slate blue", 123, 104, 238 },
968 { "medium spring green", 0, 250, 154 },
969 { "medium turquoise", 72, 209, 204 },
970 { "medium violet red", 199, 21, 133 },
971 { "MediumAquamarine", 102, 205, 170 },
972 { "MediumBlue", 0, 0, 205 },
973 { "MediumOrchid", 186, 85, 211 },
974 { "MediumOrchid1", 224, 102, 255 },
975 { "MediumOrchid2", 209, 95, 238 },
976 { "MediumOrchid3", 180, 82, 205 },
977 { "MediumOrchid4", 122, 55, 139 },
978 { "MediumPurple", 147, 112, 219 },
979 { "MediumPurple1", 171, 130, 255 },
980 { "MediumPurple2", 159, 121, 238 },
981 { "MediumPurple3", 137, 104, 205 },
982 { "MediumPurple4", 93, 71, 139 },
983 { "MediumSeaGreen", 60, 179, 113 },
984 { "MediumSlateBlue", 123, 104, 238 },
985 { "MediumSpringGreen", 0, 250, 154 },
986 { "MediumTurquoise", 72, 209, 204 },
987 { "MediumVioletRed", 199, 21, 133 },
988 { "midnight blue", 25, 25, 112 },
989 { "MidnightBlue", 25, 25, 112 },
990 { "mint cream", 245, 255, 250 },
991 { "MintCream", 245, 255, 250 },
992 { "misty rose", 255, 228, 225 },
993 { "MistyRose", 255, 228, 225 },
994 { "MistyRose1", 255, 228, 225 },
995 { "MistyRose2", 238, 213, 210 },
996 { "MistyRose3", 205, 183, 181 },
997 { "MistyRose4", 139, 125, 123 },
998 { "moccasin", 255, 228, 181 },
999 { "navajo white", 255, 222, 173 },
1000 { "NavajoWhite", 255, 222, 173 },
1001 { "NavajoWhite1", 255, 222, 173 },
1002 { "NavajoWhite2", 238, 207, 161 },
1003 { "NavajoWhite3", 205, 179, 139 },
1004 { "NavajoWhite4", 139, 121, 94 },
1005 { "navy", 0, 0, 128 },
1006 { "navy blue", 0, 0, 128 },
1007 { "NavyBlue", 0, 0, 128 },
1008 { "old lace", 253, 245, 230 },
1009 { "OldLace", 253, 245, 230 },
1010 { "olive drab", 107, 142, 35 },
1011 { "OliveDrab", 107, 142, 35 },
1012 { "OliveDrab1", 192, 255, 62 },
1013 { "OliveDrab2", 179, 238, 58 },
1014 { "OliveDrab3", 154, 205, 50 },
1015 { "OliveDrab4", 105, 139, 34 },
1016 { "orange", 255, 165, 0 },
1017 { "orange red", 255, 69, 0 },
1018 { "orange1", 255, 165, 0 },
1019 { "orange2", 238, 154, 0 },
1020 { "orange3", 205, 133, 0 },
1021 { "orange4", 139, 90, 0 },
1022 { "OrangeRed", 255, 69, 0 },
1023 { "OrangeRed1", 255, 69, 0 },
1024 { "OrangeRed2", 238, 64, 0 },
1025 { "OrangeRed3", 205, 55, 0 },
1026 { "OrangeRed4", 139, 37, 0 },
1027 { "orchid", 218, 112, 214 },
1028 { "orchid1", 255, 131, 250 },
1029 { "orchid2", 238, 122, 233 },
1030 { "orchid3", 205, 105, 201 },
1031 { "orchid4", 139, 71, 137 },
1032 { "pale goldenrod", 238, 232, 170 },
1033 { "pale green", 152, 251, 152 },
1034 { "pale turquoise", 175, 238, 238 },
1035 { "pale violet red", 219, 112, 147 },
1036 { "PaleGoldenrod", 238, 232, 170 },
1037 { "PaleGreen", 152, 251, 152 },
1038 { "PaleGreen1", 154, 255, 154 },
1039 { "PaleGreen2", 144, 238, 144 },
1040 { "PaleGreen3", 124, 205, 124 },
1041 { "PaleGreen4", 84, 139, 84 },
1042 { "PaleTurquoise", 175, 238, 238 },
1043 { "PaleTurquoise1", 187, 255, 255 },
1044 { "PaleTurquoise2", 174, 238, 238 },
1045 { "PaleTurquoise3", 150, 205, 205 },
1046 { "PaleTurquoise4", 102, 139, 139 },
1047 { "PaleVioletRed", 219, 112, 147 },
1048 { "PaleVioletRed1", 255, 130, 171 },
1049 { "PaleVioletRed2", 238, 121, 159 },
1050 { "PaleVioletRed3", 205, 104, 137 },
1051 { "PaleVioletRed4", 139, 71, 93 },
1052 { "papaya whip", 255, 239, 213 },
1053 { "PapayaWhip", 255, 239, 213 },
1054 { "peach puff", 255, 218, 185 },
1055 { "PeachPuff", 255, 218, 185 },
1056 { "PeachPuff1", 255, 218, 185 },
1057 { "PeachPuff2", 238, 203, 173 },
1058 { "PeachPuff3", 205, 175, 149 },
1059 { "PeachPuff4", 139, 119, 101 },
1060 { "peru", 205, 133, 63 },
1061 { "pink", 255, 192, 203 },
1062 { "pink1", 255, 181, 197 },
1063 { "pink2", 238, 169, 184 },
1064 { "pink3", 205, 145, 158 },
1065 { "pink4", 139, 99, 108 },
1066 { "plum", 221, 160, 221 },
1067 { "plum1", 255, 187, 255 },
1068 { "plum2", 238, 174, 238 },
1069 { "plum3", 205, 150, 205 },
1070 { "plum4", 139, 102, 139 },
1071 { "powder blue", 176, 224, 230 },
1072 { "PowderBlue", 176, 224, 230 },
1073 { "purple", 160, 32, 240 },
1074 { "purple1", 155, 48, 255 },
1075 { "purple2", 145, 44, 238 },
1076 { "purple3", 125, 38, 205 },
1077 { "purple4", 85, 26, 139 },
1078 { "red", 255, 0, 0 },
1079 { "red1", 255, 0, 0 },
1080 { "red2", 238, 0, 0 },
1081 { "red3", 205, 0, 0 },
1082 { "red4", 139, 0, 0 },
1083 { "rosy brown", 188, 143, 143 },
1084 { "RosyBrown", 188, 143, 143 },
1085 { "RosyBrown1", 255, 193, 193 },
1086 { "RosyBrown2", 238, 180, 180 },
1087 { "RosyBrown3", 205, 155, 155 },
1088 { "RosyBrown4", 139, 105, 105 },
1089 { "royal blue", 65, 105, 225 },
1090 { "RoyalBlue", 65, 105, 225 },
1091 { "RoyalBlue1", 72, 118, 255 },
1092 { "RoyalBlue2", 67, 110, 238 },
1093 { "RoyalBlue3", 58, 95, 205 },
1094 { "RoyalBlue4", 39, 64, 139 },
1095 { "saddle brown", 139, 69, 19 },
1096 { "SaddleBrown", 139, 69, 19 },
1097 { "salmon", 250, 128, 114 },
1098 { "salmon1", 255, 140, 105 },
1099 { "salmon2", 238, 130, 98 },
1100 { "salmon3", 205, 112, 84 },
1101 { "salmon4", 139, 76, 57 },
1102 { "sandy brown", 244, 164, 96 },
1103 { "SandyBrown", 244, 164, 96 },
1104 { "sea green", 46, 139, 87 },
1105 { "SeaGreen", 46, 139, 87 },
1106 { "SeaGreen1", 84, 255, 159 },
1107 { "SeaGreen2", 78, 238, 148 },
1108 { "SeaGreen3", 67, 205, 128 },
1109 { "SeaGreen4", 46, 139, 87 },
1110 { "seashell", 255, 245, 238 },
1111 { "seashell1", 255, 245, 238 },
1112 { "seashell2", 238, 229, 222 },
1113 { "seashell3", 205, 197, 191 },
1114 { "seashell4", 139, 134, 130 },
1115 { "sienna", 160, 82, 45 },
1116 { "sienna1", 255, 130, 71 },
1117 { "sienna2", 238, 121, 66 },
1118 { "sienna3", 205, 104, 57 },
1119 { "sienna4", 139, 71, 38 },
1120 { "sky blue", 135, 206, 235 },
1121 { "SkyBlue", 135, 206, 235 },
1122 { "SkyBlue1", 135, 206, 255 },
1123 { "SkyBlue2", 126, 192, 238 },
1124 { "SkyBlue3", 108, 166, 205 },
1125 { "SkyBlue4", 74, 112, 139 },
1126 { "slate blue", 106, 90, 205 },
1127 { "slate gray", 112, 128, 144 },
1128 { "slate grey", 112, 128, 144 },
1129 { "SlateBlue", 106, 90, 205 },
1130 { "SlateBlue1", 131, 111, 255 },
1131 { "SlateBlue2", 122, 103, 238 },
1132 { "SlateBlue3", 105, 89, 205 },
1133 { "SlateBlue4", 71, 60, 139 },
1134 { "SlateGray", 112, 128, 144 },
1135 { "SlateGray1", 198, 226, 255 },
1136 { "SlateGray2", 185, 211, 238 },
1137 { "SlateGray3", 159, 182, 205 },
1138 { "SlateGray4", 108, 123, 139 },
1139 { "SlateGrey", 112, 128, 144 },
1140 { "snow", 255, 250, 250 },
1141 { "snow1", 255, 250, 250 },
1142 { "snow2", 238, 233, 233 },
1143 { "snow3", 205, 201, 201 },
1144 { "snow4", 139, 137, 137 },
1145 { "spring green", 0, 255, 127 },
1146 { "SpringGreen", 0, 255, 127 },
1147 { "SpringGreen1", 0, 255, 127 },
1148 { "SpringGreen2", 0, 238, 118 },
1149 { "SpringGreen3", 0, 205, 102 },
1150 { "SpringGreen4", 0, 139, 69 },
1151 { "steel blue", 70, 130, 180 },
1152 { "SteelBlue", 70, 130, 180 },
1153 { "SteelBlue1", 99, 184, 255 },
1154 { "SteelBlue2", 92, 172, 238 },
1155 { "SteelBlue3", 79, 148, 205 },
1156 { "SteelBlue4", 54, 100, 139 },
1157 { "tan", 210, 180, 140 },
1158 { "tan1", 255, 165, 79 },
1159 { "tan2", 238, 154, 73 },
1160 { "tan3", 205, 133, 63 },
1161 { "tan4", 139, 90, 43 },
1162 { "thistle", 216, 191, 216 },
1163 { "thistle1", 255, 225, 255 },
1164 { "thistle2", 238, 210, 238 },
1165 { "thistle3", 205, 181, 205 },
1166 { "thistle4", 139, 123, 139 },
1167 { "tomato", 255, 99, 71 },
1168 { "tomato1", 255, 99, 71 },
1169 { "tomato2", 238, 92, 66 },
1170 { "tomato3", 205, 79, 57 },
1171 { "tomato4", 139, 54, 38 },
1172 { "turquoise", 64, 224, 208 },
1173 { "turquoise1", 0, 245, 255 },
1174 { "turquoise2", 0, 229, 238 },
1175 { "turquoise3", 0, 197, 205 },
1176 { "turquoise4", 0, 134, 139 },
1177 { "violet", 238, 130, 238 },
1178 { "violet red", 208, 32, 144 },
1179 { "VioletRed", 208, 32, 144 },
1180 { "VioletRed1", 255, 62, 150 },
1181 { "VioletRed2", 238, 58, 140 },
1182 { "VioletRed3", 205, 50, 120 },
1183 { "VioletRed4", 139, 34, 82 },
1184 { "wheat", 245, 222, 179 },
1185 { "wheat1", 255, 231, 186 },
1186 { "wheat2", 238, 216, 174 },
1187 { "wheat3", 205, 186, 150 },
1188 { "wheat4", 139, 126, 102 },
1189 { "white", 255, 255, 255 },
1190 { "white smoke", 245, 245, 245 },
1191 { "WhiteSmoke", 245, 245, 245 },
1192 { "yellow", 255, 255, 0 },
1193 { "yellow green", 154, 205, 50 },
1194 { "yellow1", 255, 255, 0 },
1195 { "yellow2", 238, 238, 0 },
1196 { "yellow3", 205, 205, 0 },
1197 { "yellow4", 139, 139, 0 },
1198 { "YellowGreen", 154, 205, 50 }
1201 #define numXColors (sizeof (xColors) / sizeof (*xColors))
1204 *----------------------------------------------------------------------
1208 * This routine finds the color entry that corresponds to the
1212 * Returns non-zero on success. The RGB values of the XColor
1213 * will be initialized to the proper values on success.
1218 *----------------------------------------------------------------------
1222 compare_xcolor_entries (const void *a, const void *b)
1224 return strcasecmp ((const char *) a, ((const XColorEntry *) b)->name);
1228 FindColor(const char *name,
1233 found = bsearch (name, xColors, numXColors, sizeof (XColorEntry),
1234 compare_xcolor_entries);
1238 colorPtr->red = (found->red * 65535) / 255;
1239 colorPtr->green = (found->green * 65535) / 255;
1240 colorPtr->blue = (found->blue * 65535) / 255;
1245 *----------------------------------------------------------------------
1249 * Partial implementation of X color name parsing interface.
1252 * Returns non-zero on success.
1257 *----------------------------------------------------------------------
1261 parse_color(Colormap map,
1265 if (spec[0] == '#') {
1267 int i, red, green, blue;
1269 if ((i = strlen(spec+1))%3) {
1274 sprintf(fmt, "%%%dx%%%dx%%%dx", i, i, i);
1275 if (sscanf(spec+1, fmt, &red, &green, &blue) != 3) {
1280 colorPtr->red = red;
1281 colorPtr->green = green;
1282 colorPtr->blue = blue;
1286 colorPtr->red = (red * 65535) / 15;
1287 colorPtr->green = (green * 65535) / 15;
1288 colorPtr->blue = (blue * 65535) / 15;
1292 colorPtr->red = (red * 65535) / 255;
1293 colorPtr->green = (green * 65535) / 255;
1294 colorPtr->blue = (blue * 65535) / 255;
1296 else /* if (i == 3) */
1298 colorPtr->red = (red * 65535) / 4095;
1299 colorPtr->green = (green * 65535) / 4095;
1300 colorPtr->blue = (blue * 65535) / 4095;
1303 if (!FindColor(spec, colorPtr)) {
1310 /* End of code from Tk8.0 */
1315 static Colormap colormap;
1321 colormap = create_colormap ( NULL, NULL, AllocNone);
1327 gdk_colormap_new (GdkVisual *visual,
1330 GdkColormap *colormap;
1331 GdkColormapPrivate *private;
1336 g_return_val_if_fail (visual != NULL, NULL);
1338 private = g_new (GdkColormapPrivate, 1);
1339 colormap = (GdkColormap*) private;
1341 private->visual = visual;
1342 private->ref_count = 1;
1344 private->hash = NULL;
1345 private->last_sync_time = 0;
1346 private->info = NULL;
1348 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
1350 colormap->size = visual->colormap_size;
1351 colormap->colors = g_new (GdkColor, colormap->size);
1353 switch (visual->type)
1355 case GDK_VISUAL_GRAYSCALE:
1356 case GDK_VISUAL_PSEUDO_COLOR:
1357 private->info = g_new0 (GdkColorInfo, colormap->size);
1358 colormap->colors = g_new (GdkColor, colormap->size);
1360 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
1361 (GCompareFunc) gdk_color_equal);
1363 private->private_val = private_cmap;
1364 private->xcolormap = create_colormap (gdk_root_window, xvisual,
1365 (private_cmap) ? (AllocAll) : (AllocNone));
1369 PALETTEENTRY pal[256];
1372 npal = GetPaletteEntries (private->xcolormap->palette, 0, colormap->size, pal);
1373 for (i = 0; i < colormap->size; i++)
1375 colormap->colors[i].pixel = i;
1378 colormap->colors[i].red =
1379 colormap->colors[i].green =
1380 colormap->colors[i].blue = 0;
1384 colormap->colors[i].red = (pal[i].peRed * 65535) / 255;
1385 colormap->colors[i].green = (pal[i].peGreen * 65525) / 255;
1386 colormap->colors[i].blue = (pal[i].peBlue * 65535) / 255;
1389 gdk_colormap_change (colormap, colormap->size);
1393 case GDK_VISUAL_STATIC_GRAY:
1394 case GDK_VISUAL_STATIC_COLOR:
1395 case GDK_VISUAL_TRUE_COLOR:
1396 private->private_val = FALSE;
1397 private->xcolormap = create_colormap (gdk_root_window,
1398 xvisual, AllocNone);
1402 gdk_colormap_add (colormap);
1408 gdk_colormap_real_destroy (GdkColormap *colormap)
1410 GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
1412 g_return_if_fail (colormap != NULL);
1413 g_return_if_fail (private->ref_count == 0);
1415 gdk_colormap_remove (colormap);
1416 XFreeColormap (private->xcolormap);
1419 g_hash_table_destroy (private->hash);
1421 g_free (private->info);
1422 g_free (colormap->colors);
1427 gdk_colormap_ref (GdkColormap *cmap)
1429 GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
1431 g_return_val_if_fail (cmap != NULL, NULL);
1433 private->ref_count += 1;
1438 gdk_colormap_unref (GdkColormap *cmap)
1440 GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
1442 g_return_if_fail (cmap != NULL);
1443 g_return_if_fail (private->ref_count > 0);
1445 private->ref_count -= 1;
1446 if (private->ref_count == 0)
1447 gdk_colormap_real_destroy (cmap);
1450 #define MIN_SYNC_TIME 2
1453 gdk_colormap_get_visual (GdkColormap *colormap)
1455 GdkColormapPrivate *private;
1457 g_return_val_if_fail (colormap != NULL, NULL);
1459 private = (GdkColormapPrivate *)colormap;
1461 return private->visual;
1465 gdk_colormap_sync (GdkColormap *colormap,
1468 time_t current_time;
1469 GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
1474 g_return_if_fail (colormap != NULL);
1476 current_time = time (NULL);
1477 if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
1480 private->last_sync_time = current_time;
1483 xpalette = g_new (XColor, colormap->size);
1485 nlookup = GetPaletteEntries (private->xcolormap->palette,
1486 0, colormap->size, xpalette);
1488 for (i = 0; i < nlookup; i++)
1490 colormap->colors[i].pixel = i;
1491 colormap->colors[i].red = (xpalette[i].peRed * 65535) / 255;
1492 colormap->colors[i].green = (xpalette[i].peGreen * 65535) / 255;
1493 colormap->colors[i].blue = (xpalette[i].peBlue * 65535) / 255;
1501 gdk_colormap_get_system (void)
1503 static GdkColormap *colormap = NULL;
1504 GdkColormapPrivate *private;
1509 private = g_new (GdkColormapPrivate, 1);
1510 colormap = (GdkColormap*) private;
1512 private->xcolormap = DefaultColormap ();
1513 private->visual = gdk_visual_get_system ();
1514 private->private_val = FALSE;
1515 private->ref_count = 1;
1517 private->hash = NULL;
1518 private->last_sync_time = 0;
1519 private->info = NULL;
1521 colormap->colors = NULL;
1522 colormap->size = private->visual->colormap_size;
1524 if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
1525 (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
1527 private->info = g_new0 (GdkColorInfo, colormap->size);
1528 colormap->colors = g_new (GdkColor, colormap->size);
1530 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
1531 (GCompareFunc) gdk_color_equal);
1533 gdk_colormap_sync (colormap, TRUE);
1535 gdk_colormap_add (colormap);
1542 gdk_colormap_get_system_size (void)
1546 bitspixel = GetDeviceCaps (gdk_DC, BITSPIXEL);
1550 else if (bitspixel == 4)
1552 else if (bitspixel == 8)
1554 else if (bitspixel == 12)
1556 else if (bitspixel == 16)
1558 else /* if (bitspixel >= 24) */
1563 gdk_colormap_change (GdkColormap *colormap,
1566 GdkColormapPrivate *private;
1574 g_return_if_fail (colormap != NULL);
1576 palette = g_new (XColor, ncolors);
1578 private = (GdkColormapPrivate*) colormap;
1579 switch (private->visual->type)
1581 case GDK_VISUAL_GRAYSCALE:
1582 case GDK_VISUAL_PSEUDO_COLOR:
1583 for (i = 0; i < ncolors; i++)
1585 palette[i].peRed = (colormap->colors[i].red >> 8);
1586 palette[i].peGreen = (colormap->colors[i].green >> 8);
1587 palette[i].peBlue = (colormap->colors[i].blue >> 8);
1588 palette[i].peFlags = 0;
1591 if (SetPaletteEntries (private->xcolormap->palette,
1592 0, ncolors, palette) == 0)
1593 g_warning ("gdk_colormap_change: SetPaletteEntries failed");
1594 private->xcolormap->stale = TRUE;
1605 gdk_colors_store (GdkColormap *colormap,
1611 for (i = 0; i < ncolors; i++)
1613 colormap->colors[i].pixel = colors[i].pixel;
1614 colormap->colors[i].red = colors[i].red;
1615 colormap->colors[i].green = colors[i].green;
1616 colormap->colors[i].blue = colors[i].blue;
1619 gdk_colormap_change (colormap, ncolors);
1623 gdk_colors_alloc (GdkColormap *colormap,
1630 GdkColormapPrivate *private;
1634 g_return_val_if_fail (colormap != NULL, 0);
1636 private = (GdkColormapPrivate*) colormap;
1638 return_val = alloc_color_cells (private->xcolormap, contiguous,
1639 planes, nplanes, pixels, npixels);
1643 for (i=0; i<npixels; i++)
1645 private->info[pixels[i]].ref_count++;
1646 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
1653 /* This is almost identical to gdk_colormap_free_colors.
1654 * Keep them in sync!
1657 gdk_colors_free (GdkColormap *colormap,
1662 GdkColormapPrivate *private;
1667 g_return_if_fail (colormap != NULL);
1668 g_return_if_fail (in_pixels != NULL);
1670 private = (GdkColormapPrivate*) colormap;
1672 if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
1673 (private->visual->type != GDK_VISUAL_GRAYSCALE))
1676 pixels = g_new (gulong, in_npixels);
1678 for (i=0; i<in_npixels; i++)
1680 gulong pixel = in_pixels[i];
1682 if (private->info[pixel].ref_count)
1684 private->info[pixel].ref_count--;
1686 if (private->info[pixel].ref_count == 0)
1688 pixels[npixels++] = pixel;
1689 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
1690 g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
1691 private->info[pixel].flags = 0;
1698 XFreeColors (private->xcolormap, pixels, npixels, planes);
1704 *--------------------------------------------------------------
1707 * Copy a color structure into new storage.
1710 * "color" is the color struct to copy.
1713 * A new color structure. Free it with gdk_color_free.
1715 *--------------------------------------------------------------
1718 static GMemChunk *color_chunk;
1721 gdk_color_copy (GdkColor *color)
1723 GdkColor *new_color;
1725 g_return_val_if_fail (color != NULL, NULL);
1727 if (color_chunk == NULL)
1728 color_chunk = g_mem_chunk_new ("colors",
1733 new_color = g_chunk_new (GdkColor, color_chunk);
1734 *new_color = *color;
1739 *--------------------------------------------------------------
1742 * Free a color structure obtained from gdk_color_copy. Do not use
1743 * with other color structures.
1746 * "color" is the color struct to free.
1748 *-------------------------------------------------------------- */
1751 gdk_color_free (GdkColor *color)
1753 g_assert (color_chunk != NULL);
1754 g_return_if_fail (color != NULL);
1756 g_mem_chunk_free (color_chunk, color);
1760 gdk_color_white (GdkColormap *colormap,
1765 g_return_val_if_fail (colormap != NULL, FALSE);
1770 color->green = 65535;
1771 color->blue = 65535;
1773 return_val = gdk_color_alloc (colormap, color);
1782 gdk_color_black (GdkColormap *colormap,
1787 g_return_val_if_fail (colormap != NULL, FALSE);
1795 return_val = gdk_color_alloc (colormap, color);
1804 gdk_color_parse (const gchar *spec,
1809 gboolean return_val;
1811 g_return_val_if_fail (spec != NULL, FALSE);
1812 g_return_val_if_fail (color != NULL, FALSE);
1814 xcolormap = DefaultColormap ();
1816 if (parse_color (xcolormap, spec, color))
1824 /********************
1825 * Color allocation *
1826 ********************/
1828 /* Try to allocate a single color using alloc_color. If it succeeds,
1829 * cache the result in our colormap, and store in ret.
1832 gdk_colormap_alloc1 (GdkColormap *colormap,
1836 GdkColormapPrivate *private;
1839 private = (GdkColormapPrivate*) colormap;
1841 xcolor.peRed = color->red >> 8;
1842 xcolor.peGreen = color->green >> 8;
1843 xcolor.peBlue = color->blue >> 8;
1845 if (alloc_color (private->xcolormap, &xcolor, &ret->pixel))
1847 ret->red = (xcolor.peRed * 65535) / 255;
1848 ret->green = (xcolor.peGreen * 65535) / 255;;
1849 ret->blue = (xcolor.peBlue * 65535) / 255;
1851 if ((guint) ret->pixel < colormap->size)
1853 if (private->info[ret->pixel].ref_count) /* got a duplicate */
1859 colormap->colors[ret->pixel] = *color;
1860 private->info[ret->pixel].ref_count = 1;
1862 g_hash_table_insert (private->hash,
1863 &colormap->colors[ret->pixel],
1864 &colormap->colors[ret->pixel]);
1876 gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
1880 gboolean best_match,
1883 GdkColormapPrivate *private;
1888 private = (GdkColormapPrivate*) colormap;
1890 if (private->private_val)
1893 for (i=0; i<ncolors; i++)
1895 while ((index < colormap->size) && (private->info[index].ref_count != 0))
1898 if (index < colormap->size)
1900 colors[i].pixel = index;
1902 private->info[index].ref_count++;
1903 private->info[i].flags |= GDK_COLOR_WRITEABLE;
1912 pixels = g_new (gulong, ncolors);
1914 /* Allocation of a writeable color cells */
1915 status = alloc_color_cells (private->xcolormap, FALSE, NULL,
1916 0, pixels, ncolors);
1919 for (i=0; i<ncolors; i++)
1921 colors[i].pixel = pixels[i];
1922 private->info[pixels[i]].ref_count++;
1923 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
1929 return status ? ncolors : 0;
1934 gdk_colormap_alloc_colors_private (GdkColormap *colormap,
1938 gboolean best_match,
1941 GdkColormapPrivate *private;
1943 XColor *store = g_new (XColor, ncolors);
1945 gint nremaining = 0;
1947 private = (GdkColormapPrivate*) colormap;
1950 /* First, store the colors we have room for */
1953 for (i=0; i<ncolors; i++)
1957 while ((index < colormap->size) && (private->info[index].ref_count != 0))
1960 if (index < colormap->size)
1962 store[nstore].peRed = colors[i].red >> 8;
1963 store[nstore].peBlue = colors[i].blue >> 8;
1964 store[nstore].peGreen = colors[i].green >> 8;
1969 colors[i].pixel = index;
1970 private->info[index].ref_count++;
1977 if (SetPaletteEntries (private->xcolormap->palette,
1978 0, nstore, store) == 0)
1979 g_warning ("gdk_colormap_alloc_colors_private: SetPaletteEntries failed");
1980 private->xcolormap->stale = TRUE;
1984 if (nremaining > 0 && best_match)
1986 /* Get best matches for remaining colors */
1988 gchar *available = g_new (gchar, colormap->size);
1989 for (i = 0; i < colormap->size; i++)
1990 available[i] = TRUE;
1992 for (i=0; i<ncolors; i++)
1996 index = gdk_colormap_match_color (colormap,
2001 colors[i] = colormap->colors[index];
2002 private->info[index].ref_count++;
2011 return (ncolors - nremaining);
2015 gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
2019 gboolean best_match,
2022 GdkColormapPrivate *private;
2024 gint nremaining = 0;
2027 private = (GdkColormapPrivate*) colormap;
2030 for (i=0; i<ncolors; i++)
2034 if (gdk_colormap_alloc1 (colormap, &colors[i], &colors[i]))
2042 if (nremaining > 0 && best_match)
2044 gchar *available = g_new (gchar, colormap->size);
2045 for (i = 0; i < colormap->size; i++)
2046 available[i] = ((private->info[i].ref_count == 0) ||
2047 !(private->info[i].flags && GDK_COLOR_WRITEABLE));
2048 gdk_colormap_sync (colormap, FALSE);
2050 while (nremaining > 0)
2052 for (i=0; i<ncolors; i++)
2056 index = gdk_colormap_match_color (colormap, &colors[i], available);
2059 if (private->info[index].ref_count)
2061 private->info[index].ref_count++;
2062 colors[i] = colormap->colors[index];
2068 if (gdk_colormap_alloc1 (colormap,
2069 &colormap->colors[index],
2078 available[index] = FALSE;
2086 success[i] = 2; /* flag as permanent failure */
2094 /* Change back the values we flagged as permanent failures */
2097 for (i=0; i<ncolors; i++)
2098 if (success[i] == 2)
2100 nremaining = nfailed;
2103 return (ncolors - nremaining);
2107 gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
2111 gboolean best_match,
2114 GdkColormapPrivate *private;
2115 GdkColor *lookup_color;
2117 gint nremaining = 0;
2119 private = (GdkColormapPrivate*) colormap;
2121 /* Check for an exact match among previously allocated colors */
2123 for (i=0; i<ncolors; i++)
2127 lookup_color = g_hash_table_lookup (private->hash, &colors[i]);
2130 private->info[lookup_color->pixel].ref_count++;
2131 colors[i].pixel = lookup_color->pixel;
2139 /* If that failed, we try to allocate a new color, or approxmiate
2140 * with what we can get if best_match is TRUE.
2144 if (private->private_val)
2145 return gdk_colormap_alloc_colors_private (colormap, colors, ncolors, writeable, best_match, success);
2147 return gdk_colormap_alloc_colors_shared (colormap, colors, ncolors, writeable, best_match, success);
2154 gdk_colormap_alloc_colors (GdkColormap *colormap,
2158 gboolean best_match,
2161 GdkColormapPrivate *private;
2164 gint nremaining = 0;
2167 g_return_val_if_fail (colormap != NULL, FALSE);
2168 g_return_val_if_fail (colors != NULL, FALSE);
2170 private = (GdkColormapPrivate*) colormap;
2172 for (i=0; i<ncolors; i++)
2177 switch (private->visual->type)
2179 case GDK_VISUAL_PSEUDO_COLOR:
2180 case GDK_VISUAL_GRAYSCALE:
2182 return gdk_colormap_alloc_colors_writeable (colormap, colors, ncolors,
2183 writeable, best_match, success);
2185 return gdk_colormap_alloc_colors_pseudocolor (colormap, colors, ncolors,
2186 writeable, best_match, success);
2189 case GDK_VISUAL_TRUE_COLOR:
2190 visual = private->visual;
2192 for (i=0; i<ncolors; i++)
2194 colors[i].pixel = (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
2195 ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
2196 ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
2201 case GDK_VISUAL_STATIC_GRAY:
2202 case GDK_VISUAL_STATIC_COLOR:
2203 for (i=0; i<ncolors; i++)
2205 xcolor.peRed = colors[i].red >> 8;
2206 xcolor.peGreen = colors[i].green >> 8;
2207 xcolor.peBlue = colors[i].blue >> 8;
2208 if (alloc_color (private->xcolormap, &xcolor, &colors[i].pixel))
2219 gdk_colormap_alloc_color (GdkColormap *colormap,
2222 gboolean best_match)
2226 GDK_NOTE (MISC, g_print ("gdk_colormap_alloc_color: (%.04x,%.04x,%.04x)",
2227 color->red, color->green, color->blue));
2229 gdk_colormap_alloc_colors (colormap, color, 1, writeable, best_match,
2231 GDK_NOTE (MISC, g_print (" -> %.08x\n", color->pixel));
2236 /* This is almost identical to gdk_colors_free.
2237 * Keep them in sync!
2240 gdk_colormap_free_colors (GdkColormap *colormap,
2244 GdkColormapPrivate *private;
2249 g_return_if_fail (colormap != NULL);
2250 g_return_if_fail (colors != NULL);
2252 private = (GdkColormapPrivate*) colormap;
2254 if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
2255 (private->visual->type != GDK_VISUAL_GRAYSCALE))
2258 pixels = g_new (gulong, ncolors);
2260 for (i=0; i<ncolors; i++)
2262 gulong pixel = colors[i].pixel;
2264 if (private->info[pixel].ref_count)
2266 private->info[pixel].ref_count--;
2268 if (private->info[pixel].ref_count == 0)
2270 pixels[npixels++] = pixel;
2271 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
2272 g_hash_table_remove (private->hash, &colors[i]);
2273 private->info[pixel].flags = 0;
2278 XFreeColors (private->xcolormap, pixels, npixels, 0);
2283 gdk_color_alloc (GdkColormap *colormap,
2288 GDK_NOTE (MISC, g_print ("gdk_color_alloc: (%.04x,%.04x,%.04x)",
2289 color->red, color->green, color->blue));
2291 gdk_colormap_alloc_colors (colormap, color, 1, FALSE, TRUE, &success);
2293 GDK_NOTE (MISC, g_print (" -> %.08x\n", color->pixel));
2299 gdk_color_change (GdkColormap *colormap,
2302 GdkColormapPrivate *private;
2305 g_return_val_if_fail (colormap != NULL, FALSE);
2306 g_return_val_if_fail (color != NULL, FALSE);
2308 private = (GdkColormapPrivate*) colormap;
2310 xcolor.peRed = color->red >> 8;
2311 xcolor.peGreen = color->green >> 8;
2312 xcolor.peBlue = color->blue >> 8;
2314 if (SetPaletteEntries (private->xcolormap->palette,
2315 color->pixel, 1, &xcolor) == 0)
2316 g_warning ("gdk_color_change: SetPaletteEntries failed");
2317 private->xcolormap->stale = TRUE;
2323 gdk_color_hash (const GdkColor *colora)
2325 return ((colora->red) +
2326 (colora->green << 11) +
2327 (colora->blue << 22) +
2328 (colora->blue >> 6));
2332 gdk_color_equal (const GdkColor *colora,
2333 const GdkColor *colorb)
2335 g_return_val_if_fail (colora != NULL, FALSE);
2336 g_return_val_if_fail (colorb != NULL, FALSE);
2338 return ((colora->red == colorb->red) &&
2339 (colora->green == colorb->green) &&
2340 (colora->blue == colorb->blue));
2344 gdk_colormap_match_color (GdkColormap *cmap,
2346 const gchar *available)
2350 gint rdiff, gdiff, bdiff;
2353 g_return_val_if_fail (cmap != NULL, 0);
2354 g_return_val_if_fail (color != NULL, 0);
2356 colors = cmap->colors;
2360 for (i = 0; i < cmap->size; i++)
2362 if ((!available) || (available && available[i]))
2364 rdiff = (color->red - colors[i].red);
2365 gdiff = (color->green - colors[i].green);
2366 bdiff = (color->blue - colors[i].blue);
2368 sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
2382 gdk_colormap_lookup (Colormap xcolormap)
2389 cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
2394 gdk_colormap_add (GdkColormap *cmap)
2396 GdkColormapPrivate *private;
2399 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
2400 (GCompareFunc) gdk_colormap_cmp);
2402 private = (GdkColormapPrivate*) cmap;
2404 g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
2408 gdk_colormap_remove (GdkColormap *cmap)
2410 GdkColormapPrivate *private;
2413 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
2414 (GCompareFunc) gdk_colormap_cmp);
2416 private = (GdkColormapPrivate*) cmap;
2418 g_hash_table_remove (colormap_hash, &private->xcolormap);
2422 gdk_colormap_hash (Colormap *cmap)
2424 return (guint) *cmap;
2428 gdk_colormap_cmp (Colormap *a,
2435 gdk_color_to_string (GdkColor *color)
2437 static char buf[100];
2439 sprintf (buf, "(%.04x,%.04x,%.04x): %.06x",
2440 color->red, color->green, color->blue, color->pixel);