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"
37 static gint gdk_colormap_match_color (GdkColormap *cmap,
39 const gchar *available);
40 static void gdk_colormap_add (GdkColormap *cmap);
41 static void gdk_colormap_remove (GdkColormap *cmap);
42 static guint gdk_colormap_hash (Colormap *cmap);
43 static gint gdk_colormap_cmp (Colormap *a,
45 static void gdk_colormap_real_destroy (GdkColormap *colormap);
47 static GHashTable *colormap_hash = NULL;
50 alloc_color_cells(Colormap colormap,
52 unsigned long plane_masks_return[],
54 unsigned long pixels_return[],
57 unsigned int i, nfree, iret;
60 for (i = 0; i < colormap->size && nfree < npixels; i++)
61 if (!colormap->in_use[i])
64 if (colormap->size + npixels - nfree > colormap->sizepalette)
66 g_warning ("alloc_color_cells: too large palette: %d",
67 colormap->size + npixels);
72 for (i = 0; i < colormap->size && iret < npixels; i++)
73 if (!colormap->in_use[i])
75 colormap->in_use[i] = TRUE;
76 pixels_return[iret] = i;
82 int nmore = npixels - nfree;
84 /* I don't understand why, if the code below in #if 0 is
85 enabled, gdkrgb fails miserably. The palette doesn't get
86 realized correctly. There doesn't seem to be any harm done by
87 keeping this code out, either. */
88 #ifdef SOME_STRANGE_BUG
89 if (!ResizePalette (colormap->palette, colormap->size + nmore))
91 g_warning ("alloc_color_cells: ResizePalette to %d failed",
92 colormap->size + nmore);
95 g_print("alloc_color_cells: %#x to %d\n",
96 colormap->palette, colormap->size + nmore);
98 for (i = colormap->size; i < colormap->size + nmore; i++)
100 pixels_return[iret] = i;
102 colormap->in_use[i] = TRUE;
104 #ifdef SOME_STRANGE_BUG
105 colormap->size += nmore;
111 /* The following functions are from Tk8.0, but heavily modified.
112 Here are tk's licensing terms. I hope these terms don't conflict
113 with the GNU Library General Public License? They shouldn't, as
114 they are looser that the GLPL, yes? */
117 This software is copyrighted by the Regents of the University of
118 California, Sun Microsystems, Inc., and other parties. The following
119 terms apply to all files associated with the software unless explicitly
120 disclaimed in individual files.
122 The authors hereby grant permission to use, copy, modify, distribute,
123 and license this software and its documentation for any purpose, provided
124 that existing copyright notices are retained in all copies and that this
125 notice is included verbatim in any distributions. No written agreement,
126 license, or royalty fee is required for any of the authorized uses.
127 Modifications to this software may be copyrighted by their authors
128 and need not follow the licensing terms described here, provided that
129 the new terms are clearly indicated on the first page of each file where
132 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
133 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
134 ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
135 DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
136 POSSIBILITY OF SUCH DAMAGE.
138 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
139 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
140 FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
141 IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
142 NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
145 GOVERNMENT USE: If you are acquiring this software on behalf of the
146 U.S. government, the Government shall have only "Restricted Rights"
147 in the software and related documentation as defined in the Federal
148 Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
149 are acquiring the software on behalf of the Department of Defense, the
150 software shall be classified as "Commercial Computer Software" and the
151 Government shall have only "Restricted Rights" as defined in Clause
152 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
153 authors grant the U.S. Government and others acting in its behalf
154 permission to use and distribute the software in accordance with the
155 terms specified in this license.
158 *----------------------------------------------------------------------
162 * Find the closest available color to the specified XColor.
165 * Updates the color argument and returns 1 on success. Otherwise
169 * Allocates a new color in the palette.
171 *----------------------------------------------------------------------
175 alloc_color(Colormap colormap,
179 PALETTEENTRY entry, closeEntry;
186 if (colormap->rc_palette)
188 COLORREF newPixel, closePixel;
192 * Find the nearest existing palette entry.
195 newPixel = RGB (entry.peRed, entry.peGreen, entry.peBlue);
196 index = GetNearestPaletteIndex (colormap->palette, newPixel);
197 GetPaletteEntries (colormap->palette, index, 1, &closeEntry);
198 closePixel = RGB (closeEntry.peRed, closeEntry.peGreen,
201 if (newPixel != closePixel)
203 /* Not a perfect match. */
204 if (!colormap->in_use[index])
206 /* It was a free'd entry anyway, so we can use it, and
207 set it to the correct color. */
208 if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
209 g_warning ("alloc_color: SetPaletteEntries #1 failed");
213 /* The close entry found is in use, so search for a
216 for (i = 0; i < colormap->size; i++)
217 if (!colormap->in_use[i])
219 /* A free slot, use it. */
220 if (SetPaletteEntries (colormap->palette,
221 index, 1, &entry) == 0)
222 g_warning ("alloc_color: SetPaletteEntries #2 failed");
226 if (i == colormap->size)
228 /* No free slots found. If the palette isn't maximal
230 if (colormap->size == colormap->sizepalette)
232 /* The palette is maximal, and no free slots available,
233 so use the close entry, then, dammit. */
238 /* There is room to grow the palette. */
239 index = colormap->size;
241 if (!ResizePalette (colormap->palette, colormap->size))
242 g_warning ("alloc_color: ResizePalette to %d failed",
244 if (SetPaletteEntries (colormap->palette, index, 1, &entry) == 0)
245 g_warning ("alloc_color: SetPaletteEntries #3 failed");
249 colormap->stale = TRUE;
253 /* We got a match, so use it. */
257 colormap->in_use[index] = TRUE;
259 g_print("alloc_color from %#x: index %d for %02x %02x %02x\n",
260 colormap->palette, index,
261 entry.peRed, entry.peGreen, entry.peBlue);
267 * Determine what color will actually be used on non-colormap systems.
269 *pixelp = GetNearestColor (gdk_DC, RGB(entry.peRed, entry.peGreen, entry.peBlue));
271 color->peRed = GetRValue (*pixelp);
272 color->peGreen = GetGValue (*pixelp);
273 color->peBlue = GetBValue (*pixelp);
280 *----------------------------------------------------------------------
284 * Deallocate a block of colors.
290 * Removes entries for the current palette and compacts the
293 *----------------------------------------------------------------------
297 XFreeColors(Colormap colormap,
303 PALETTEENTRY entries[256];
306 * We don't have to do anything for non-palette devices.
309 if (colormap->rc_palette)
312 int lowestpixel = 256;
313 int highestpixel = -1;
315 npal = GetPaletteEntries (colormap->palette, 0, 256, entries);
316 for (i = 0; i < npixels; i++)
318 int pixel = pixels[i];
320 if (pixel < lowestpixel)
322 if (pixel > highestpixel)
323 highestpixel = pixel;
325 colormap->in_use[pixel] = FALSE;
327 entries[pixel] = entries[0];
330 if (SetPaletteEntries (colormap->palette, lowestpixel,
331 highestpixel - lowestpixel + 1,
332 entries + lowestpixel) == 0)
333 g_warning ("XFreeColors: SetPaletteEntries failed");
335 colormap->stale = TRUE;
337 g_print("XFreeColors %#x lowestpixel = %d, highestpixel = %d\n",
338 colormap->palette, lowestpixel, highestpixel);
344 *----------------------------------------------------------------------
348 * Allocate a new colormap.
351 * Returns a newly allocated colormap.
354 * Allocates an empty palette and color list.
356 *----------------------------------------------------------------------
360 create_colormap (HWND w,
364 char logPalBuf[sizeof(LOGPALETTE) + 256 * sizeof(PALETTEENTRY)];
365 LOGPALETTE *logPalettePtr;
366 PALETTEENTRY *entryPtr;
372 /* Should the alloc parameter do something? */
375 /* Allocate a starting palette with all of the reserved colors. */
377 logPalettePtr = (LOGPALETTE *) logPalBuf;
378 logPalettePtr->palVersion = 0x300;
379 sysPal = (HPALETTE) GetStockObject (DEFAULT_PALETTE);
380 logPalettePtr->palNumEntries =
381 GetPaletteEntries (sysPal, 0, 256, logPalettePtr->palPalEntry);
383 colormap = (Colormap) g_new (ColormapStruct, 1);
384 colormap->size = logPalettePtr->palNumEntries;
385 colormap->stale = TRUE;
386 colormap->palette = CreatePalette (logPalettePtr);
388 colormap->rc_palette = ((GetDeviceCaps (hdc, RASTERCAPS) & RC_PALETTE) != 0);
389 if (colormap->rc_palette)
391 colormap->sizepalette = GetDeviceCaps (hdc, SIZEPALETTE);
392 colormap->in_use = g_new (gboolean, colormap->sizepalette);
393 /* Mark static colors in use. */
394 for (i = 0; i < logPalettePtr->palNumEntries; i++)
395 colormap->in_use[i] = TRUE;
396 /* Mark rest not in use */
397 for (i = logPalettePtr->palNumEntries; i < colormap->sizepalette; i++)
398 colormap->in_use[i] = FALSE;
400 ReleaseDC (NULL, hdc);
406 *----------------------------------------------------------------------
410 * Frees the resources associated with the given colormap.
416 * Deletes the palette associated with the colormap. Note that
417 * the palette must not be selected into a device context when
420 *----------------------------------------------------------------------
424 XFreeColormap(Colormap colormap)
427 if (!DeleteObject (colormap->palette))
429 g_error ("Unable to free colormap, palette is still selected.");
441 static XColorEntry xColors[] = {
442 { "alice blue", 240, 248, 255 },
443 { "AliceBlue", 240, 248, 255 },
444 { "antique white", 250, 235, 215 },
445 { "AntiqueWhite", 250, 235, 215 },
446 { "AntiqueWhite1", 255, 239, 219 },
447 { "AntiqueWhite2", 238, 223, 204 },
448 { "AntiqueWhite3", 205, 192, 176 },
449 { "AntiqueWhite4", 139, 131, 120 },
450 { "aquamarine", 127, 255, 212 },
451 { "aquamarine1", 127, 255, 212 },
452 { "aquamarine2", 118, 238, 198 },
453 { "aquamarine3", 102, 205, 170 },
454 { "aquamarine4", 69, 139, 116 },
455 { "azure", 240, 255, 255 },
456 { "azure1", 240, 255, 255 },
457 { "azure2", 224, 238, 238 },
458 { "azure3", 193, 205, 205 },
459 { "azure4", 131, 139, 139 },
460 { "beige", 245, 245, 220 },
461 { "bisque", 255, 228, 196 },
462 { "bisque1", 255, 228, 196 },
463 { "bisque2", 238, 213, 183 },
464 { "bisque3", 205, 183, 158 },
465 { "bisque4", 139, 125, 107 },
466 { "black", 0, 0, 0 },
467 { "blanched almond", 255, 235, 205 },
468 { "BlanchedAlmond", 255, 235, 205 },
469 { "blue", 0, 0, 255 },
470 { "blue violet", 138, 43, 226 },
471 { "blue1", 0, 0, 255 },
472 { "blue2", 0, 0, 238 },
473 { "blue3", 0, 0, 205 },
474 { "blue4", 0, 0, 139 },
475 { "BlueViolet", 138, 43, 226 },
476 { "brown", 165, 42, 42 },
477 { "brown1", 255, 64, 64 },
478 { "brown2", 238, 59, 59 },
479 { "brown3", 205, 51, 51 },
480 { "brown4", 139, 35, 35 },
481 { "burlywood", 222, 184, 135 },
482 { "burlywood1", 255, 211, 155 },
483 { "burlywood2", 238, 197, 145 },
484 { "burlywood3", 205, 170, 125 },
485 { "burlywood4", 139, 115, 85 },
486 { "cadet blue", 95, 158, 160 },
487 { "CadetBlue", 95, 158, 160 },
488 { "CadetBlue1", 152, 245, 255 },
489 { "CadetBlue2", 142, 229, 238 },
490 { "CadetBlue3", 122, 197, 205 },
491 { "CadetBlue4", 83, 134, 139 },
492 { "chartreuse", 127, 255, 0 },
493 { "chartreuse1", 127, 255, 0 },
494 { "chartreuse2", 118, 238, 0 },
495 { "chartreuse3", 102, 205, 0 },
496 { "chartreuse4", 69, 139, 0 },
497 { "chocolate", 210, 105, 30 },
498 { "chocolate1", 255, 127, 36 },
499 { "chocolate2", 238, 118, 33 },
500 { "chocolate3", 205, 102, 29 },
501 { "chocolate4", 139, 69, 19 },
502 { "coral", 255, 127, 80 },
503 { "coral1", 255, 114, 86 },
504 { "coral2", 238, 106, 80 },
505 { "coral3", 205, 91, 69 },
506 { "coral4", 139, 62, 47 },
507 { "cornflower blue", 100, 149, 237 },
508 { "CornflowerBlue", 100, 149, 237 },
509 { "cornsilk", 255, 248, 220 },
510 { "cornsilk1", 255, 248, 220 },
511 { "cornsilk2", 238, 232, 205 },
512 { "cornsilk3", 205, 200, 177 },
513 { "cornsilk4", 139, 136, 120 },
514 { "cyan", 0, 255, 255 },
515 { "cyan1", 0, 255, 255 },
516 { "cyan2", 0, 238, 238 },
517 { "cyan3", 0, 205, 205 },
518 { "cyan4", 0, 139, 139 },
519 { "dark blue", 0, 0, 139 },
520 { "dark cyan", 0, 139, 139 },
521 { "dark goldenrod", 184, 134, 11 },
522 { "dark gray", 169, 169, 169 },
523 { "dark green", 0, 100, 0 },
524 { "dark grey", 169, 169, 169 },
525 { "dark khaki", 189, 183, 107 },
526 { "dark magenta", 139, 0, 139 },
527 { "dark olive green", 85, 107, 47 },
528 { "dark orange", 255, 140, 0 },
529 { "dark orchid", 153, 50, 204 },
530 { "dark red", 139, 0, 0 },
531 { "dark salmon", 233, 150, 122 },
532 { "dark sea green", 143, 188, 143 },
533 { "dark slate blue", 72, 61, 139 },
534 { "dark slate gray", 47, 79, 79 },
535 { "dark slate grey", 47, 79, 79 },
536 { "dark turquoise", 0, 206, 209 },
537 { "dark violet", 148, 0, 211 },
538 { "DarkBlue", 0, 0, 139 },
539 { "DarkCyan", 0, 139, 139 },
540 { "DarkGoldenrod", 184, 134, 11 },
541 { "DarkGoldenrod1", 255, 185, 15 },
542 { "DarkGoldenrod2", 238, 173, 14 },
543 { "DarkGoldenrod3", 205, 149, 12 },
544 { "DarkGoldenrod4", 139, 101, 8 },
545 { "DarkGray", 169, 169, 169 },
546 { "DarkGreen", 0, 100, 0 },
547 { "DarkGrey", 169, 169, 169 },
548 { "DarkKhaki", 189, 183, 107 },
549 { "DarkMagenta", 139, 0, 139 },
550 { "DarkOliveGreen", 85, 107, 47 },
551 { "DarkOliveGreen1", 202, 255, 112 },
552 { "DarkOliveGreen2", 188, 238, 104 },
553 { "DarkOliveGreen3", 162, 205, 90 },
554 { "DarkOliveGreen4", 110, 139, 61 },
555 { "DarkOrange", 255, 140, 0 },
556 { "DarkOrange1", 255, 127, 0 },
557 { "DarkOrange2", 238, 118, 0 },
558 { "DarkOrange3", 205, 102, 0 },
559 { "DarkOrange4", 139, 69, 0 },
560 { "DarkOrchid", 153, 50, 204 },
561 { "DarkOrchid1", 191, 62, 255 },
562 { "DarkOrchid2", 178, 58, 238 },
563 { "DarkOrchid3", 154, 50, 205 },
564 { "DarkOrchid4", 104, 34, 139 },
565 { "DarkRed", 139, 0, 0 },
566 { "DarkSalmon", 233, 150, 122 },
567 { "DarkSeaGreen", 143, 188, 143 },
568 { "DarkSeaGreen1", 193, 255, 193 },
569 { "DarkSeaGreen2", 180, 238, 180 },
570 { "DarkSeaGreen3", 155, 205, 155 },
571 { "DarkSeaGreen4", 105, 139, 105 },
572 { "DarkSlateBlue", 72, 61, 139 },
573 { "DarkSlateGray", 47, 79, 79 },
574 { "DarkSlateGray1", 151, 255, 255 },
575 { "DarkSlateGray2", 141, 238, 238 },
576 { "DarkSlateGray3", 121, 205, 205 },
577 { "DarkSlateGray4", 82, 139, 139 },
578 { "DarkSlateGrey", 47, 79, 79 },
579 { "DarkTurquoise", 0, 206, 209 },
580 { "DarkViolet", 148, 0, 211 },
581 { "deep pink", 255, 20, 147 },
582 { "deep sky blue", 0, 191, 255 },
583 { "DeepPink", 255, 20, 147 },
584 { "DeepPink1", 255, 20, 147 },
585 { "DeepPink2", 238, 18, 137 },
586 { "DeepPink3", 205, 16, 118 },
587 { "DeepPink4", 139, 10, 80 },
588 { "DeepSkyBlue", 0, 191, 255 },
589 { "DeepSkyBlue1", 0, 191, 255 },
590 { "DeepSkyBlue2", 0, 178, 238 },
591 { "DeepSkyBlue3", 0, 154, 205 },
592 { "DeepSkyBlue4", 0, 104, 139 },
593 { "dim gray", 105, 105, 105 },
594 { "dim grey", 105, 105, 105 },
595 { "DimGray", 105, 105, 105 },
596 { "DimGrey", 105, 105, 105 },
597 { "dodger blue", 30, 144, 255 },
598 { "DodgerBlue", 30, 144, 255 },
599 { "DodgerBlue1", 30, 144, 255 },
600 { "DodgerBlue2", 28, 134, 238 },
601 { "DodgerBlue3", 24, 116, 205 },
602 { "DodgerBlue4", 16, 78, 139 },
603 { "firebrick", 178, 34, 34 },
604 { "firebrick1", 255, 48, 48 },
605 { "firebrick2", 238, 44, 44 },
606 { "firebrick3", 205, 38, 38 },
607 { "firebrick4", 139, 26, 26 },
608 { "floral white", 255, 250, 240 },
609 { "FloralWhite", 255, 250, 240 },
610 { "forest green", 34, 139, 34 },
611 { "ForestGreen", 34, 139, 34 },
612 { "gainsboro", 220, 220, 220 },
613 { "ghost white", 248, 248, 255 },
614 { "GhostWhite", 248, 248, 255 },
615 { "gold", 255, 215, 0 },
616 { "gold1", 255, 215, 0 },
617 { "gold2", 238, 201, 0 },
618 { "gold3", 205, 173, 0 },
619 { "gold4", 139, 117, 0 },
620 { "goldenrod", 218, 165, 32 },
621 { "goldenrod1", 255, 193, 37 },
622 { "goldenrod2", 238, 180, 34 },
623 { "goldenrod3", 205, 155, 29 },
624 { "goldenrod4", 139, 105, 20 },
625 { "gray", 190, 190, 190 },
626 { "gray0", 0, 0, 0 },
627 { "gray1", 3, 3, 3 },
628 { "gray10", 26, 26, 26 },
629 { "gray100", 255, 255, 255 },
630 { "gray11", 28, 28, 28 },
631 { "gray12", 31, 31, 31 },
632 { "gray13", 33, 33, 33 },
633 { "gray14", 36, 36, 36 },
634 { "gray15", 38, 38, 38 },
635 { "gray16", 41, 41, 41 },
636 { "gray17", 43, 43, 43 },
637 { "gray18", 46, 46, 46 },
638 { "gray19", 48, 48, 48 },
639 { "gray2", 5, 5, 5 },
640 { "gray20", 51, 51, 51 },
641 { "gray21", 54, 54, 54 },
642 { "gray22", 56, 56, 56 },
643 { "gray23", 59, 59, 59 },
644 { "gray24", 61, 61, 61 },
645 { "gray25", 64, 64, 64 },
646 { "gray26", 66, 66, 66 },
647 { "gray27", 69, 69, 69 },
648 { "gray28", 71, 71, 71 },
649 { "gray29", 74, 74, 74 },
650 { "gray3", 8, 8, 8 },
651 { "gray30", 77, 77, 77 },
652 { "gray31", 79, 79, 79 },
653 { "gray32", 82, 82, 82 },
654 { "gray33", 84, 84, 84 },
655 { "gray34", 87, 87, 87 },
656 { "gray35", 89, 89, 89 },
657 { "gray36", 92, 92, 92 },
658 { "gray37", 94, 94, 94 },
659 { "gray38", 97, 97, 97 },
660 { "gray39", 99, 99, 99 },
661 { "gray4", 10, 10, 10 },
662 { "gray40", 102, 102, 102 },
663 { "gray41", 105, 105, 105 },
664 { "gray42", 107, 107, 107 },
665 { "gray43", 110, 110, 110 },
666 { "gray44", 112, 112, 112 },
667 { "gray45", 115, 115, 115 },
668 { "gray46", 117, 117, 117 },
669 { "gray47", 120, 120, 120 },
670 { "gray48", 122, 122, 122 },
671 { "gray49", 125, 125, 125 },
672 { "gray5", 13, 13, 13 },
673 { "gray50", 127, 127, 127 },
674 { "gray51", 130, 130, 130 },
675 { "gray52", 133, 133, 133 },
676 { "gray53", 135, 135, 135 },
677 { "gray54", 138, 138, 138 },
678 { "gray55", 140, 140, 140 },
679 { "gray56", 143, 143, 143 },
680 { "gray57", 145, 145, 145 },
681 { "gray58", 148, 148, 148 },
682 { "gray59", 150, 150, 150 },
683 { "gray6", 15, 15, 15 },
684 { "gray60", 153, 153, 153 },
685 { "gray61", 156, 156, 156 },
686 { "gray62", 158, 158, 158 },
687 { "gray63", 161, 161, 161 },
688 { "gray64", 163, 163, 163 },
689 { "gray65", 166, 166, 166 },
690 { "gray66", 168, 168, 168 },
691 { "gray67", 171, 171, 171 },
692 { "gray68", 173, 173, 173 },
693 { "gray69", 176, 176, 176 },
694 { "gray7", 18, 18, 18 },
695 { "gray70", 179, 179, 179 },
696 { "gray71", 181, 181, 181 },
697 { "gray72", 184, 184, 184 },
698 { "gray73", 186, 186, 186 },
699 { "gray74", 189, 189, 189 },
700 { "gray75", 191, 191, 191 },
701 { "gray76", 194, 194, 194 },
702 { "gray77", 196, 196, 196 },
703 { "gray78", 199, 199, 199 },
704 { "gray79", 201, 201, 201 },
705 { "gray8", 20, 20, 20 },
706 { "gray80", 204, 204, 204 },
707 { "gray81", 207, 207, 207 },
708 { "gray82", 209, 209, 209 },
709 { "gray83", 212, 212, 212 },
710 { "gray84", 214, 214, 214 },
711 { "gray85", 217, 217, 217 },
712 { "gray86", 219, 219, 219 },
713 { "gray87", 222, 222, 222 },
714 { "gray88", 224, 224, 224 },
715 { "gray89", 227, 227, 227 },
716 { "gray9", 23, 23, 23 },
717 { "gray90", 229, 229, 229 },
718 { "gray91", 232, 232, 232 },
719 { "gray92", 235, 235, 235 },
720 { "gray93", 237, 237, 237 },
721 { "gray94", 240, 240, 240 },
722 { "gray95", 242, 242, 242 },
723 { "gray96", 245, 245, 245 },
724 { "gray97", 247, 247, 247 },
725 { "gray98", 250, 250, 250 },
726 { "gray99", 252, 252, 252 },
727 { "green", 0, 255, 0 },
728 { "green yellow", 173, 255, 47 },
729 { "green1", 0, 255, 0 },
730 { "green2", 0, 238, 0 },
731 { "green3", 0, 205, 0 },
732 { "green4", 0, 139, 0 },
733 { "GreenYellow", 173, 255, 47 },
734 { "grey", 190, 190, 190 },
735 { "grey0", 0, 0, 0 },
736 { "grey1", 3, 3, 3 },
737 { "grey10", 26, 26, 26 },
738 { "grey100", 255, 255, 255 },
739 { "grey11", 28, 28, 28 },
740 { "grey12", 31, 31, 31 },
741 { "grey13", 33, 33, 33 },
742 { "grey14", 36, 36, 36 },
743 { "grey15", 38, 38, 38 },
744 { "grey16", 41, 41, 41 },
745 { "grey17", 43, 43, 43 },
746 { "grey18", 46, 46, 46 },
747 { "grey19", 48, 48, 48 },
748 { "grey2", 5, 5, 5 },
749 { "grey20", 51, 51, 51 },
750 { "grey21", 54, 54, 54 },
751 { "grey22", 56, 56, 56 },
752 { "grey23", 59, 59, 59 },
753 { "grey24", 61, 61, 61 },
754 { "grey25", 64, 64, 64 },
755 { "grey26", 66, 66, 66 },
756 { "grey27", 69, 69, 69 },
757 { "grey28", 71, 71, 71 },
758 { "grey29", 74, 74, 74 },
759 { "grey3", 8, 8, 8 },
760 { "grey30", 77, 77, 77 },
761 { "grey31", 79, 79, 79 },
762 { "grey32", 82, 82, 82 },
763 { "grey33", 84, 84, 84 },
764 { "grey34", 87, 87, 87 },
765 { "grey35", 89, 89, 89 },
766 { "grey36", 92, 92, 92 },
767 { "grey37", 94, 94, 94 },
768 { "grey38", 97, 97, 97 },
769 { "grey39", 99, 99, 99 },
770 { "grey4", 10, 10, 10 },
771 { "grey40", 102, 102, 102 },
772 { "grey41", 105, 105, 105 },
773 { "grey42", 107, 107, 107 },
774 { "grey43", 110, 110, 110 },
775 { "grey44", 112, 112, 112 },
776 { "grey45", 115, 115, 115 },
777 { "grey46", 117, 117, 117 },
778 { "grey47", 120, 120, 120 },
779 { "grey48", 122, 122, 122 },
780 { "grey49", 125, 125, 125 },
781 { "grey5", 13, 13, 13 },
782 { "grey50", 127, 127, 127 },
783 { "grey51", 130, 130, 130 },
784 { "grey52", 133, 133, 133 },
785 { "grey53", 135, 135, 135 },
786 { "grey54", 138, 138, 138 },
787 { "grey55", 140, 140, 140 },
788 { "grey56", 143, 143, 143 },
789 { "grey57", 145, 145, 145 },
790 { "grey58", 148, 148, 148 },
791 { "grey59", 150, 150, 150 },
792 { "grey6", 15, 15, 15 },
793 { "grey60", 153, 153, 153 },
794 { "grey61", 156, 156, 156 },
795 { "grey62", 158, 158, 158 },
796 { "grey63", 161, 161, 161 },
797 { "grey64", 163, 163, 163 },
798 { "grey65", 166, 166, 166 },
799 { "grey66", 168, 168, 168 },
800 { "grey67", 171, 171, 171 },
801 { "grey68", 173, 173, 173 },
802 { "grey69", 176, 176, 176 },
803 { "grey7", 18, 18, 18 },
804 { "grey70", 179, 179, 179 },
805 { "grey71", 181, 181, 181 },
806 { "grey72", 184, 184, 184 },
807 { "grey73", 186, 186, 186 },
808 { "grey74", 189, 189, 189 },
809 { "grey75", 191, 191, 191 },
810 { "grey76", 194, 194, 194 },
811 { "grey77", 196, 196, 196 },
812 { "grey78", 199, 199, 199 },
813 { "grey79", 201, 201, 201 },
814 { "grey8", 20, 20, 20 },
815 { "grey80", 204, 204, 204 },
816 { "grey81", 207, 207, 207 },
817 { "grey82", 209, 209, 209 },
818 { "grey83", 212, 212, 212 },
819 { "grey84", 214, 214, 214 },
820 { "grey85", 217, 217, 217 },
821 { "grey86", 219, 219, 219 },
822 { "grey87", 222, 222, 222 },
823 { "grey88", 224, 224, 224 },
824 { "grey89", 227, 227, 227 },
825 { "grey9", 23, 23, 23 },
826 { "grey90", 229, 229, 229 },
827 { "grey91", 232, 232, 232 },
828 { "grey92", 235, 235, 235 },
829 { "grey93", 237, 237, 237 },
830 { "grey94", 240, 240, 240 },
831 { "grey95", 242, 242, 242 },
832 { "grey96", 245, 245, 245 },
833 { "grey97", 247, 247, 247 },
834 { "grey98", 250, 250, 250 },
835 { "grey99", 252, 252, 252 },
836 { "honeydew", 240, 255, 240 },
837 { "honeydew1", 240, 255, 240 },
838 { "honeydew2", 224, 238, 224 },
839 { "honeydew3", 193, 205, 193 },
840 { "honeydew4", 131, 139, 131 },
841 { "hot pink", 255, 105, 180 },
842 { "HotPink", 255, 105, 180 },
843 { "HotPink1", 255, 110, 180 },
844 { "HotPink2", 238, 106, 167 },
845 { "HotPink3", 205, 96, 144 },
846 { "HotPink4", 139, 58, 98 },
847 { "indian red", 205, 92, 92 },
848 { "IndianRed", 205, 92, 92 },
849 { "IndianRed1", 255, 106, 106 },
850 { "IndianRed2", 238, 99, 99 },
851 { "IndianRed3", 205, 85, 85 },
852 { "IndianRed4", 139, 58, 58 },
853 { "ivory", 255, 255, 240 },
854 { "ivory1", 255, 255, 240 },
855 { "ivory2", 238, 238, 224 },
856 { "ivory3", 205, 205, 193 },
857 { "ivory4", 139, 139, 131 },
858 { "khaki", 240, 230, 140 },
859 { "khaki1", 255, 246, 143 },
860 { "khaki2", 238, 230, 133 },
861 { "khaki3", 205, 198, 115 },
862 { "khaki4", 139, 134, 78 },
863 { "lavender", 230, 230, 250 },
864 { "lavender blush", 255, 240, 245 },
865 { "LavenderBlush", 255, 240, 245 },
866 { "LavenderBlush1", 255, 240, 245 },
867 { "LavenderBlush2", 238, 224, 229 },
868 { "LavenderBlush3", 205, 193, 197 },
869 { "LavenderBlush4", 139, 131, 134 },
870 { "lawn green", 124, 252, 0 },
871 { "LawnGreen", 124, 252, 0 },
872 { "lemon chiffon", 255, 250, 205 },
873 { "LemonChiffon", 255, 250, 205 },
874 { "LemonChiffon1", 255, 250, 205 },
875 { "LemonChiffon2", 238, 233, 191 },
876 { "LemonChiffon3", 205, 201, 165 },
877 { "LemonChiffon4", 139, 137, 112 },
878 { "light blue", 173, 216, 230 },
879 { "light coral", 240, 128, 128 },
880 { "light cyan", 224, 255, 255 },
881 { "light goldenrod", 238, 221, 130 },
882 { "light goldenrod yellow", 250, 250, 210 },
883 { "light gray", 211, 211, 211 },
884 { "light green", 144, 238, 144 },
885 { "light grey", 211, 211, 211 },
886 { "light pink", 255, 182, 193 },
887 { "light salmon", 255, 160, 122 },
888 { "light sea green", 32, 178, 170 },
889 { "light sky blue", 135, 206, 250 },
890 { "light slate blue", 132, 112, 255 },
891 { "light slate gray", 119, 136, 153 },
892 { "light slate grey", 119, 136, 153 },
893 { "light steel blue", 176, 196, 222 },
894 { "light yellow", 255, 255, 224 },
895 { "LightBlue", 173, 216, 230 },
896 { "LightBlue1", 191, 239, 255 },
897 { "LightBlue2", 178, 223, 238 },
898 { "LightBlue3", 154, 192, 205 },
899 { "LightBlue4", 104, 131, 139 },
900 { "LightCoral", 240, 128, 128 },
901 { "LightCyan", 224, 255, 255 },
902 { "LightCyan1", 224, 255, 255 },
903 { "LightCyan2", 209, 238, 238 },
904 { "LightCyan3", 180, 205, 205 },
905 { "LightCyan4", 122, 139, 139 },
906 { "LightGoldenrod", 238, 221, 130 },
907 { "LightGoldenrod1", 255, 236, 139 },
908 { "LightGoldenrod2", 238, 220, 130 },
909 { "LightGoldenrod3", 205, 190, 112 },
910 { "LightGoldenrod4", 139, 129, 76 },
911 { "LightGoldenrodYellow", 250, 250, 210 },
912 { "LightGray", 211, 211, 211 },
913 { "LightGreen", 144, 238, 144 },
914 { "LightGrey", 211, 211, 211 },
915 { "LightPink", 255, 182, 193 },
916 { "LightPink1", 255, 174, 185 },
917 { "LightPink2", 238, 162, 173 },
918 { "LightPink3", 205, 140, 149 },
919 { "LightPink4", 139, 95, 101 },
920 { "LightSalmon", 255, 160, 122 },
921 { "LightSalmon1", 255, 160, 122 },
922 { "LightSalmon2", 238, 149, 114 },
923 { "LightSalmon3", 205, 129, 98 },
924 { "LightSalmon4", 139, 87, 66 },
925 { "LightSeaGreen", 32, 178, 170 },
926 { "LightSkyBlue", 135, 206, 250 },
927 { "LightSkyBlue1", 176, 226, 255 },
928 { "LightSkyBlue2", 164, 211, 238 },
929 { "LightSkyBlue3", 141, 182, 205 },
930 { "LightSkyBlue4", 96, 123, 139 },
931 { "LightSlateBlue", 132, 112, 255 },
932 { "LightSlateGray", 119, 136, 153 },
933 { "LightSlateGrey", 119, 136, 153 },
934 { "LightSteelBlue", 176, 196, 222 },
935 { "LightSteelBlue1", 202, 225, 255 },
936 { "LightSteelBlue2", 188, 210, 238 },
937 { "LightSteelBlue3", 162, 181, 205 },
938 { "LightSteelBlue4", 110, 123, 139 },
939 { "LightYellow", 255, 255, 224 },
940 { "LightYellow1", 255, 255, 224 },
941 { "LightYellow2", 238, 238, 209 },
942 { "LightYellow3", 205, 205, 180 },
943 { "LightYellow4", 139, 139, 122 },
944 { "lime green", 50, 205, 50 },
945 { "LimeGreen", 50, 205, 50 },
946 { "linen", 250, 240, 230 },
947 { "magenta", 255, 0, 255 },
948 { "magenta1", 255, 0, 255 },
949 { "magenta2", 238, 0, 238 },
950 { "magenta3", 205, 0, 205 },
951 { "magenta4", 139, 0, 139 },
952 { "maroon", 176, 48, 96 },
953 { "maroon1", 255, 52, 179 },
954 { "maroon2", 238, 48, 167 },
955 { "maroon3", 205, 41, 144 },
956 { "maroon4", 139, 28, 98 },
957 { "medium aquamarine", 102, 205, 170 },
958 { "medium blue", 0, 0, 205 },
959 { "medium orchid", 186, 85, 211 },
960 { "medium purple", 147, 112, 219 },
961 { "medium sea green", 60, 179, 113 },
962 { "medium slate blue", 123, 104, 238 },
963 { "medium spring green", 0, 250, 154 },
964 { "medium turquoise", 72, 209, 204 },
965 { "medium violet red", 199, 21, 133 },
966 { "MediumAquamarine", 102, 205, 170 },
967 { "MediumBlue", 0, 0, 205 },
968 { "MediumOrchid", 186, 85, 211 },
969 { "MediumOrchid1", 224, 102, 255 },
970 { "MediumOrchid2", 209, 95, 238 },
971 { "MediumOrchid3", 180, 82, 205 },
972 { "MediumOrchid4", 122, 55, 139 },
973 { "MediumPurple", 147, 112, 219 },
974 { "MediumPurple1", 171, 130, 255 },
975 { "MediumPurple2", 159, 121, 238 },
976 { "MediumPurple3", 137, 104, 205 },
977 { "MediumPurple4", 93, 71, 139 },
978 { "MediumSeaGreen", 60, 179, 113 },
979 { "MediumSlateBlue", 123, 104, 238 },
980 { "MediumSpringGreen", 0, 250, 154 },
981 { "MediumTurquoise", 72, 209, 204 },
982 { "MediumVioletRed", 199, 21, 133 },
983 { "midnight blue", 25, 25, 112 },
984 { "MidnightBlue", 25, 25, 112 },
985 { "mint cream", 245, 255, 250 },
986 { "MintCream", 245, 255, 250 },
987 { "misty rose", 255, 228, 225 },
988 { "MistyRose", 255, 228, 225 },
989 { "MistyRose1", 255, 228, 225 },
990 { "MistyRose2", 238, 213, 210 },
991 { "MistyRose3", 205, 183, 181 },
992 { "MistyRose4", 139, 125, 123 },
993 { "moccasin", 255, 228, 181 },
994 { "navajo white", 255, 222, 173 },
995 { "NavajoWhite", 255, 222, 173 },
996 { "NavajoWhite1", 255, 222, 173 },
997 { "NavajoWhite2", 238, 207, 161 },
998 { "NavajoWhite3", 205, 179, 139 },
999 { "NavajoWhite4", 139, 121, 94 },
1000 { "navy", 0, 0, 128 },
1001 { "navy blue", 0, 0, 128 },
1002 { "NavyBlue", 0, 0, 128 },
1003 { "old lace", 253, 245, 230 },
1004 { "OldLace", 253, 245, 230 },
1005 { "olive drab", 107, 142, 35 },
1006 { "OliveDrab", 107, 142, 35 },
1007 { "OliveDrab1", 192, 255, 62 },
1008 { "OliveDrab2", 179, 238, 58 },
1009 { "OliveDrab3", 154, 205, 50 },
1010 { "OliveDrab4", 105, 139, 34 },
1011 { "orange", 255, 165, 0 },
1012 { "orange red", 255, 69, 0 },
1013 { "orange1", 255, 165, 0 },
1014 { "orange2", 238, 154, 0 },
1015 { "orange3", 205, 133, 0 },
1016 { "orange4", 139, 90, 0 },
1017 { "OrangeRed", 255, 69, 0 },
1018 { "OrangeRed1", 255, 69, 0 },
1019 { "OrangeRed2", 238, 64, 0 },
1020 { "OrangeRed3", 205, 55, 0 },
1021 { "OrangeRed4", 139, 37, 0 },
1022 { "orchid", 218, 112, 214 },
1023 { "orchid1", 255, 131, 250 },
1024 { "orchid2", 238, 122, 233 },
1025 { "orchid3", 205, 105, 201 },
1026 { "orchid4", 139, 71, 137 },
1027 { "pale goldenrod", 238, 232, 170 },
1028 { "pale green", 152, 251, 152 },
1029 { "pale turquoise", 175, 238, 238 },
1030 { "pale violet red", 219, 112, 147 },
1031 { "PaleGoldenrod", 238, 232, 170 },
1032 { "PaleGreen", 152, 251, 152 },
1033 { "PaleGreen1", 154, 255, 154 },
1034 { "PaleGreen2", 144, 238, 144 },
1035 { "PaleGreen3", 124, 205, 124 },
1036 { "PaleGreen4", 84, 139, 84 },
1037 { "PaleTurquoise", 175, 238, 238 },
1038 { "PaleTurquoise1", 187, 255, 255 },
1039 { "PaleTurquoise2", 174, 238, 238 },
1040 { "PaleTurquoise3", 150, 205, 205 },
1041 { "PaleTurquoise4", 102, 139, 139 },
1042 { "PaleVioletRed", 219, 112, 147 },
1043 { "PaleVioletRed1", 255, 130, 171 },
1044 { "PaleVioletRed2", 238, 121, 159 },
1045 { "PaleVioletRed3", 205, 104, 137 },
1046 { "PaleVioletRed4", 139, 71, 93 },
1047 { "papaya whip", 255, 239, 213 },
1048 { "PapayaWhip", 255, 239, 213 },
1049 { "peach puff", 255, 218, 185 },
1050 { "PeachPuff", 255, 218, 185 },
1051 { "PeachPuff1", 255, 218, 185 },
1052 { "PeachPuff2", 238, 203, 173 },
1053 { "PeachPuff3", 205, 175, 149 },
1054 { "PeachPuff4", 139, 119, 101 },
1055 { "peru", 205, 133, 63 },
1056 { "pink", 255, 192, 203 },
1057 { "pink1", 255, 181, 197 },
1058 { "pink2", 238, 169, 184 },
1059 { "pink3", 205, 145, 158 },
1060 { "pink4", 139, 99, 108 },
1061 { "plum", 221, 160, 221 },
1062 { "plum1", 255, 187, 255 },
1063 { "plum2", 238, 174, 238 },
1064 { "plum3", 205, 150, 205 },
1065 { "plum4", 139, 102, 139 },
1066 { "powder blue", 176, 224, 230 },
1067 { "PowderBlue", 176, 224, 230 },
1068 { "purple", 160, 32, 240 },
1069 { "purple1", 155, 48, 255 },
1070 { "purple2", 145, 44, 238 },
1071 { "purple3", 125, 38, 205 },
1072 { "purple4", 85, 26, 139 },
1073 { "red", 255, 0, 0 },
1074 { "red1", 255, 0, 0 },
1075 { "red2", 238, 0, 0 },
1076 { "red3", 205, 0, 0 },
1077 { "red4", 139, 0, 0 },
1078 { "rosy brown", 188, 143, 143 },
1079 { "RosyBrown", 188, 143, 143 },
1080 { "RosyBrown1", 255, 193, 193 },
1081 { "RosyBrown2", 238, 180, 180 },
1082 { "RosyBrown3", 205, 155, 155 },
1083 { "RosyBrown4", 139, 105, 105 },
1084 { "royal blue", 65, 105, 225 },
1085 { "RoyalBlue", 65, 105, 225 },
1086 { "RoyalBlue1", 72, 118, 255 },
1087 { "RoyalBlue2", 67, 110, 238 },
1088 { "RoyalBlue3", 58, 95, 205 },
1089 { "RoyalBlue4", 39, 64, 139 },
1090 { "saddle brown", 139, 69, 19 },
1091 { "SaddleBrown", 139, 69, 19 },
1092 { "salmon", 250, 128, 114 },
1093 { "salmon1", 255, 140, 105 },
1094 { "salmon2", 238, 130, 98 },
1095 { "salmon3", 205, 112, 84 },
1096 { "salmon4", 139, 76, 57 },
1097 { "sandy brown", 244, 164, 96 },
1098 { "SandyBrown", 244, 164, 96 },
1099 { "sea green", 46, 139, 87 },
1100 { "SeaGreen", 46, 139, 87 },
1101 { "SeaGreen1", 84, 255, 159 },
1102 { "SeaGreen2", 78, 238, 148 },
1103 { "SeaGreen3", 67, 205, 128 },
1104 { "SeaGreen4", 46, 139, 87 },
1105 { "seashell", 255, 245, 238 },
1106 { "seashell1", 255, 245, 238 },
1107 { "seashell2", 238, 229, 222 },
1108 { "seashell3", 205, 197, 191 },
1109 { "seashell4", 139, 134, 130 },
1110 { "sienna", 160, 82, 45 },
1111 { "sienna1", 255, 130, 71 },
1112 { "sienna2", 238, 121, 66 },
1113 { "sienna3", 205, 104, 57 },
1114 { "sienna4", 139, 71, 38 },
1115 { "sky blue", 135, 206, 235 },
1116 { "SkyBlue", 135, 206, 235 },
1117 { "SkyBlue1", 135, 206, 255 },
1118 { "SkyBlue2", 126, 192, 238 },
1119 { "SkyBlue3", 108, 166, 205 },
1120 { "SkyBlue4", 74, 112, 139 },
1121 { "slate blue", 106, 90, 205 },
1122 { "slate gray", 112, 128, 144 },
1123 { "slate grey", 112, 128, 144 },
1124 { "SlateBlue", 106, 90, 205 },
1125 { "SlateBlue1", 131, 111, 255 },
1126 { "SlateBlue2", 122, 103, 238 },
1127 { "SlateBlue3", 105, 89, 205 },
1128 { "SlateBlue4", 71, 60, 139 },
1129 { "SlateGray", 112, 128, 144 },
1130 { "SlateGray1", 198, 226, 255 },
1131 { "SlateGray2", 185, 211, 238 },
1132 { "SlateGray3", 159, 182, 205 },
1133 { "SlateGray4", 108, 123, 139 },
1134 { "SlateGrey", 112, 128, 144 },
1135 { "snow", 255, 250, 250 },
1136 { "snow1", 255, 250, 250 },
1137 { "snow2", 238, 233, 233 },
1138 { "snow3", 205, 201, 201 },
1139 { "snow4", 139, 137, 137 },
1140 { "spring green", 0, 255, 127 },
1141 { "SpringGreen", 0, 255, 127 },
1142 { "SpringGreen1", 0, 255, 127 },
1143 { "SpringGreen2", 0, 238, 118 },
1144 { "SpringGreen3", 0, 205, 102 },
1145 { "SpringGreen4", 0, 139, 69 },
1146 { "steel blue", 70, 130, 180 },
1147 { "SteelBlue", 70, 130, 180 },
1148 { "SteelBlue1", 99, 184, 255 },
1149 { "SteelBlue2", 92, 172, 238 },
1150 { "SteelBlue3", 79, 148, 205 },
1151 { "SteelBlue4", 54, 100, 139 },
1152 { "tan", 210, 180, 140 },
1153 { "tan1", 255, 165, 79 },
1154 { "tan2", 238, 154, 73 },
1155 { "tan3", 205, 133, 63 },
1156 { "tan4", 139, 90, 43 },
1157 { "thistle", 216, 191, 216 },
1158 { "thistle1", 255, 225, 255 },
1159 { "thistle2", 238, 210, 238 },
1160 { "thistle3", 205, 181, 205 },
1161 { "thistle4", 139, 123, 139 },
1162 { "tomato", 255, 99, 71 },
1163 { "tomato1", 255, 99, 71 },
1164 { "tomato2", 238, 92, 66 },
1165 { "tomato3", 205, 79, 57 },
1166 { "tomato4", 139, 54, 38 },
1167 { "turquoise", 64, 224, 208 },
1168 { "turquoise1", 0, 245, 255 },
1169 { "turquoise2", 0, 229, 238 },
1170 { "turquoise3", 0, 197, 205 },
1171 { "turquoise4", 0, 134, 139 },
1172 { "violet", 238, 130, 238 },
1173 { "violet red", 208, 32, 144 },
1174 { "VioletRed", 208, 32, 144 },
1175 { "VioletRed1", 255, 62, 150 },
1176 { "VioletRed2", 238, 58, 140 },
1177 { "VioletRed3", 205, 50, 120 },
1178 { "VioletRed4", 139, 34, 82 },
1179 { "wheat", 245, 222, 179 },
1180 { "wheat1", 255, 231, 186 },
1181 { "wheat2", 238, 216, 174 },
1182 { "wheat3", 205, 186, 150 },
1183 { "wheat4", 139, 126, 102 },
1184 { "white", 255, 255, 255 },
1185 { "white smoke", 245, 245, 245 },
1186 { "WhiteSmoke", 245, 245, 245 },
1187 { "yellow", 255, 255, 0 },
1188 { "yellow green", 154, 205, 50 },
1189 { "yellow1", 255, 255, 0 },
1190 { "yellow2", 238, 238, 0 },
1191 { "yellow3", 205, 205, 0 },
1192 { "yellow4", 139, 139, 0 },
1193 { "YellowGreen", 154, 205, 50 }
1196 #define numXColors (sizeof (xColors) / sizeof (*xColors))
1199 *----------------------------------------------------------------------
1203 * This routine finds the color entry that corresponds to the
1207 * Returns non-zero on success. The RGB values of the XColor
1208 * will be initialized to the proper values on success.
1213 *----------------------------------------------------------------------
1217 compare_xcolor_entries (const void *a, const void *b)
1219 return strcasecmp ((const char *) a, ((const XColorEntry *) b)->name);
1223 FindColor(const char *name,
1228 found = bsearch (name, xColors, numXColors, sizeof (XColorEntry),
1229 compare_xcolor_entries);
1233 colorPtr->red = (found->red * 65535) / 255;
1234 colorPtr->green = (found->green * 65535) / 255;
1235 colorPtr->blue = (found->blue * 65535) / 255;
1240 *----------------------------------------------------------------------
1244 * Partial implementation of X color name parsing interface.
1247 * Returns non-zero on success.
1252 *----------------------------------------------------------------------
1256 parse_color(Colormap map,
1260 if (spec[0] == '#') {
1262 int i, red, green, blue;
1264 if ((i = strlen(spec+1))%3) {
1269 sprintf(fmt, "%%%dx%%%dx%%%dx", i, i, i);
1270 if (sscanf(spec+1, fmt, &red, &green, &blue) != 3) {
1275 colorPtr->red = red;
1276 colorPtr->green = green;
1277 colorPtr->blue = blue;
1281 colorPtr->red = (red * 65535) / 15;
1282 colorPtr->green = (green * 65535) / 15;
1283 colorPtr->blue = (blue * 65535) / 15;
1287 colorPtr->red = (red * 65535) / 255;
1288 colorPtr->green = (green * 65535) / 255;
1289 colorPtr->blue = (blue * 65535) / 255;
1291 else /* if (i == 3) */
1293 colorPtr->red = (red * 65535) / 4095;
1294 colorPtr->green = (green * 65535) / 4095;
1295 colorPtr->blue = (blue * 65535) / 4095;
1298 if (!FindColor(spec, colorPtr)) {
1305 /* End of code from Tk8.0 */
1310 static Colormap colormap;
1316 colormap = create_colormap ( NULL, NULL, AllocNone);
1322 gdk_colormap_new (GdkVisual *visual,
1325 GdkColormap *colormap;
1326 GdkColormapPrivate *private;
1331 g_return_val_if_fail (visual != NULL, NULL);
1333 private = g_new (GdkColormapPrivate, 1);
1334 colormap = (GdkColormap*) private;
1336 private->visual = visual;
1337 private->ref_count = 1;
1339 private->hash = NULL;
1340 private->last_sync_time = 0;
1341 private->info = NULL;
1343 xvisual = ((GdkVisualPrivate*) visual)->xvisual;
1345 colormap->size = visual->colormap_size;
1346 colormap->colors = g_new (GdkColor, colormap->size);
1348 switch (visual->type)
1350 case GDK_VISUAL_GRAYSCALE:
1351 case GDK_VISUAL_PSEUDO_COLOR:
1352 private->info = g_new0 (GdkColorInfo, colormap->size);
1354 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
1355 (GCompareFunc) gdk_color_equal);
1357 private->private_val = private_cmap;
1358 private->xcolormap = create_colormap (gdk_root_window, xvisual,
1359 (private_cmap) ? (AllocAll) : (AllocNone));
1363 PALETTEENTRY pal[256];
1366 npal = GetPaletteEntries (private->xcolormap->palette, 0, colormap->size, pal);
1367 for (i = 0; i < colormap->size; i++)
1369 colormap->colors[i].pixel = i;
1372 colormap->colors[i].red =
1373 colormap->colors[i].green =
1374 colormap->colors[i].blue = 0;
1378 colormap->colors[i].red = (pal[i].peRed * 65535) / 255;
1379 colormap->colors[i].green = (pal[i].peGreen * 65525) / 255;
1380 colormap->colors[i].blue = (pal[i].peBlue * 65535) / 255;
1383 gdk_colormap_change (colormap, colormap->size);
1387 case GDK_VISUAL_STATIC_GRAY:
1388 case GDK_VISUAL_STATIC_COLOR:
1389 case GDK_VISUAL_TRUE_COLOR:
1390 private->private_val = FALSE;
1391 private->xcolormap = create_colormap (gdk_root_window,
1392 xvisual, AllocNone);
1396 gdk_colormap_add (colormap);
1402 gdk_colormap_real_destroy (GdkColormap *colormap)
1404 GdkColormapPrivate *private = (GdkColormapPrivate*) colormap;
1406 g_return_if_fail (colormap != NULL);
1407 g_return_if_fail (private->ref_count == 0);
1409 gdk_colormap_remove (colormap);
1410 XFreeColormap (private->xcolormap);
1413 g_hash_table_destroy (private->hash);
1415 g_free (private->info);
1416 g_free (colormap->colors);
1421 gdk_colormap_ref (GdkColormap *cmap)
1423 GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
1425 g_return_val_if_fail (cmap != NULL, NULL);
1427 private->ref_count += 1;
1432 gdk_colormap_unref (GdkColormap *cmap)
1434 GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
1436 g_return_if_fail (cmap != NULL);
1437 g_return_if_fail (private->ref_count > 0);
1439 private->ref_count -= 1;
1440 if (private->ref_count == 0)
1441 gdk_colormap_real_destroy (cmap);
1444 #define MIN_SYNC_TIME 2
1447 gdk_colormap_get_visual (GdkColormap *colormap)
1449 GdkColormapPrivate *private;
1451 g_return_val_if_fail (colormap != NULL, NULL);
1453 private = (GdkColormapPrivate *)colormap;
1455 return private->visual;
1459 gdk_colormap_sync (GdkColormap *colormap,
1462 time_t current_time;
1463 GdkColormapPrivate *private = (GdkColormapPrivate *)colormap;
1468 g_return_if_fail (colormap != NULL);
1470 current_time = time (NULL);
1471 if (!force && ((current_time - private->last_sync_time) < MIN_SYNC_TIME))
1474 private->last_sync_time = current_time;
1477 xpalette = g_new (XColor, colormap->size);
1479 nlookup = GetPaletteEntries (private->xcolormap->palette,
1480 0, colormap->size, xpalette);
1482 for (i = 0; i < nlookup; i++)
1484 colormap->colors[i].pixel = i;
1485 colormap->colors[i].red = (xpalette[i].peRed * 65535) / 255;
1486 colormap->colors[i].green = (xpalette[i].peGreen * 65535) / 255;
1487 colormap->colors[i].blue = (xpalette[i].peBlue * 65535) / 255;
1490 for ( ; i < colormap->size; i++)
1492 colormap->colors[i].pixel = i;
1493 colormap->colors[i].red = 0;
1494 colormap->colors[i].green = 0;
1495 colormap->colors[i].blue = 0;
1503 gdk_colormap_get_system (void)
1505 static GdkColormap *colormap = NULL;
1506 GdkColormapPrivate *private;
1511 private = g_new (GdkColormapPrivate, 1);
1512 colormap = (GdkColormap*) private;
1514 private->xcolormap = DefaultColormap ();
1515 private->visual = gdk_visual_get_system ();
1516 private->private_val = FALSE;
1517 private->ref_count = 1;
1519 private->hash = NULL;
1520 private->last_sync_time = 0;
1521 private->info = NULL;
1523 colormap->colors = NULL;
1524 colormap->size = private->visual->colormap_size;
1526 if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
1527 (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
1529 private->info = g_new0 (GdkColorInfo, colormap->size);
1530 colormap->colors = g_new (GdkColor, colormap->size);
1532 private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
1533 (GCompareFunc) gdk_color_equal);
1535 gdk_colormap_sync (colormap, TRUE);
1537 gdk_colormap_add (colormap);
1544 gdk_colormap_get_system_size (void)
1548 bitspixel = GetDeviceCaps (gdk_DC, BITSPIXEL);
1552 else if (bitspixel == 4)
1554 else if (bitspixel == 8)
1556 else if (bitspixel == 12)
1558 else if (bitspixel == 16)
1560 else /* if (bitspixel >= 24) */
1565 gdk_colormap_change (GdkColormap *colormap,
1568 GdkColormapPrivate *private;
1576 g_return_if_fail (colormap != NULL);
1578 palette = g_new (XColor, ncolors);
1580 private = (GdkColormapPrivate*) colormap;
1581 switch (private->visual->type)
1583 case GDK_VISUAL_GRAYSCALE:
1584 case GDK_VISUAL_PSEUDO_COLOR:
1585 for (i = 0; i < ncolors; i++)
1587 palette[i].peRed = (colormap->colors[i].red >> 8);
1588 palette[i].peGreen = (colormap->colors[i].green >> 8);
1589 palette[i].peBlue = (colormap->colors[i].blue >> 8);
1590 palette[i].peFlags = 0;
1593 if (SetPaletteEntries (private->xcolormap->palette,
1594 0, ncolors, palette) == 0)
1595 g_warning ("gdk_colormap_change: SetPaletteEntries failed");
1596 private->xcolormap->stale = TRUE;
1607 gdk_colors_store (GdkColormap *colormap,
1613 for (i = 0; i < ncolors; i++)
1615 colormap->colors[i].pixel = colors[i].pixel;
1616 colormap->colors[i].red = colors[i].red;
1617 colormap->colors[i].green = colors[i].green;
1618 colormap->colors[i].blue = colors[i].blue;
1621 gdk_colormap_change (colormap, ncolors);
1625 gdk_colors_alloc (GdkColormap *colormap,
1632 GdkColormapPrivate *private;
1636 g_return_val_if_fail (colormap != NULL, 0);
1638 private = (GdkColormapPrivate*) colormap;
1640 return_val = alloc_color_cells (private->xcolormap, contiguous,
1641 planes, nplanes, pixels, npixels);
1645 for (i=0; i<npixels; i++)
1647 private->info[pixels[i]].ref_count++;
1648 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
1655 /* This is almost identical to gdk_colormap_free_colors.
1656 * Keep them in sync!
1659 gdk_colors_free (GdkColormap *colormap,
1664 GdkColormapPrivate *private;
1669 g_return_if_fail (colormap != NULL);
1670 g_return_if_fail (in_pixels != NULL);
1672 private = (GdkColormapPrivate*) colormap;
1674 if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
1675 (private->visual->type != GDK_VISUAL_GRAYSCALE))
1678 pixels = g_new (gulong, in_npixels);
1680 for (i=0; i<in_npixels; i++)
1682 gulong pixel = in_pixels[i];
1684 if (private->info[pixel].ref_count)
1686 private->info[pixel].ref_count--;
1688 if (private->info[pixel].ref_count == 0)
1690 pixels[npixels++] = pixel;
1691 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
1692 g_hash_table_remove (private->hash, &colormap->colors[in_pixels[i]]);
1693 private->info[pixel].flags = 0;
1700 XFreeColors (private->xcolormap, pixels, npixels, planes);
1706 *--------------------------------------------------------------
1709 * Copy a color structure into new storage.
1712 * "color" is the color struct to copy.
1715 * A new color structure. Free it with gdk_color_free.
1717 *--------------------------------------------------------------
1720 static GMemChunk *color_chunk;
1723 gdk_color_copy (GdkColor *color)
1725 GdkColor *new_color;
1727 g_return_val_if_fail (color != NULL, NULL);
1729 if (color_chunk == NULL)
1730 color_chunk = g_mem_chunk_new ("colors",
1735 new_color = g_chunk_new (GdkColor, color_chunk);
1736 *new_color = *color;
1741 *--------------------------------------------------------------
1744 * Free a color structure obtained from gdk_color_copy. Do not use
1745 * with other color structures.
1748 * "color" is the color struct to free.
1750 *-------------------------------------------------------------- */
1753 gdk_color_free (GdkColor *color)
1755 g_assert (color_chunk != NULL);
1756 g_return_if_fail (color != NULL);
1758 g_mem_chunk_free (color_chunk, color);
1762 gdk_color_white (GdkColormap *colormap,
1767 g_return_val_if_fail (colormap != NULL, FALSE);
1772 color->green = 65535;
1773 color->blue = 65535;
1775 return_val = gdk_color_alloc (colormap, color);
1784 gdk_color_black (GdkColormap *colormap,
1789 g_return_val_if_fail (colormap != NULL, FALSE);
1797 return_val = gdk_color_alloc (colormap, color);
1806 gdk_color_parse (const gchar *spec,
1811 gboolean return_val;
1813 g_return_val_if_fail (spec != NULL, FALSE);
1814 g_return_val_if_fail (color != NULL, FALSE);
1816 xcolormap = DefaultColormap ();
1818 if (parse_color (xcolormap, spec, color))
1826 /********************
1827 * Color allocation *
1828 ********************/
1830 /* Try to allocate a single color using alloc_color. If it succeeds,
1831 * cache the result in our colormap, and store in ret.
1834 gdk_colormap_alloc1 (GdkColormap *colormap,
1838 GdkColormapPrivate *private;
1841 private = (GdkColormapPrivate*) colormap;
1843 xcolor.peRed = color->red >> 8;
1844 xcolor.peGreen = color->green >> 8;
1845 xcolor.peBlue = color->blue >> 8;
1847 if (alloc_color (private->xcolormap, &xcolor, &ret->pixel))
1849 ret->red = (xcolor.peRed * 65535) / 255;
1850 ret->green = (xcolor.peGreen * 65535) / 255;;
1851 ret->blue = (xcolor.peBlue * 65535) / 255;
1853 if ((guint) ret->pixel < colormap->size)
1855 if (private->info[ret->pixel].ref_count) /* got a duplicate */
1861 colormap->colors[ret->pixel] = *color;
1862 private->info[ret->pixel].ref_count = 1;
1864 g_hash_table_insert (private->hash,
1865 &colormap->colors[ret->pixel],
1866 &colormap->colors[ret->pixel]);
1878 gdk_colormap_alloc_colors_writeable (GdkColormap *colormap,
1882 gboolean best_match,
1885 GdkColormapPrivate *private;
1890 private = (GdkColormapPrivate*) colormap;
1892 if (private->private_val)
1895 for (i=0; i<ncolors; i++)
1897 while ((index < colormap->size) && (private->info[index].ref_count != 0))
1900 if (index < colormap->size)
1902 colors[i].pixel = index;
1904 private->info[index].ref_count++;
1905 private->info[i].flags |= GDK_COLOR_WRITEABLE;
1914 pixels = g_new (gulong, ncolors);
1916 /* Allocation of a writeable color cells */
1917 status = alloc_color_cells (private->xcolormap, FALSE, NULL,
1918 0, pixels, ncolors);
1921 for (i=0; i<ncolors; i++)
1923 colors[i].pixel = pixels[i];
1924 private->info[pixels[i]].ref_count++;
1925 private->info[pixels[i]].flags |= GDK_COLOR_WRITEABLE;
1931 return status ? ncolors : 0;
1936 gdk_colormap_alloc_colors_private (GdkColormap *colormap,
1940 gboolean best_match,
1943 GdkColormapPrivate *private;
1945 XColor *store = g_new (XColor, ncolors);
1947 gint nremaining = 0;
1949 private = (GdkColormapPrivate*) colormap;
1952 /* First, store the colors we have room for */
1955 for (i=0; i<ncolors; i++)
1959 while ((index < colormap->size) && (private->info[index].ref_count != 0))
1962 if (index < colormap->size)
1964 store[nstore].peRed = colors[i].red >> 8;
1965 store[nstore].peBlue = colors[i].blue >> 8;
1966 store[nstore].peGreen = colors[i].green >> 8;
1971 colors[i].pixel = index;
1972 private->info[index].ref_count++;
1979 if (SetPaletteEntries (private->xcolormap->palette,
1980 0, nstore, store) == 0)
1981 g_warning ("gdk_colormap_alloc_colors_private: SetPaletteEntries failed");
1982 private->xcolormap->stale = TRUE;
1986 if (nremaining > 0 && best_match)
1988 /* Get best matches for remaining colors */
1990 gchar *available = g_new (gchar, colormap->size);
1991 for (i = 0; i < colormap->size; i++)
1992 available[i] = TRUE;
1994 for (i=0; i<ncolors; i++)
1998 index = gdk_colormap_match_color (colormap,
2003 colors[i] = colormap->colors[index];
2004 private->info[index].ref_count++;
2013 return (ncolors - nremaining);
2017 gdk_colormap_alloc_colors_shared (GdkColormap *colormap,
2021 gboolean best_match,
2024 GdkColormapPrivate *private;
2026 gint nremaining = 0;
2029 private = (GdkColormapPrivate*) colormap;
2032 for (i=0; i<ncolors; i++)
2036 if (gdk_colormap_alloc1 (colormap, &colors[i], &colors[i]))
2044 if (nremaining > 0 && best_match)
2046 gchar *available = g_new (gchar, colormap->size);
2047 for (i = 0; i < colormap->size; i++)
2048 available[i] = ((private->info[i].ref_count == 0) ||
2049 !(private->info[i].flags && GDK_COLOR_WRITEABLE));
2050 gdk_colormap_sync (colormap, FALSE);
2052 while (nremaining > 0)
2054 for (i=0; i<ncolors; i++)
2058 index = gdk_colormap_match_color (colormap, &colors[i], available);
2061 if (private->info[index].ref_count)
2063 private->info[index].ref_count++;
2064 colors[i] = colormap->colors[index];
2070 if (gdk_colormap_alloc1 (colormap,
2071 &colormap->colors[index],
2080 available[index] = FALSE;
2088 success[i] = 2; /* flag as permanent failure */
2096 /* Change back the values we flagged as permanent failures */
2099 for (i=0; i<ncolors; i++)
2100 if (success[i] == 2)
2102 nremaining = nfailed;
2105 return (ncolors - nremaining);
2109 gdk_colormap_alloc_colors_pseudocolor (GdkColormap *colormap,
2113 gboolean best_match,
2116 GdkColormapPrivate *private;
2117 GdkColor *lookup_color;
2119 gint nremaining = 0;
2121 private = (GdkColormapPrivate*) colormap;
2123 /* Check for an exact match among previously allocated colors */
2125 for (i=0; i<ncolors; i++)
2129 lookup_color = g_hash_table_lookup (private->hash, &colors[i]);
2132 private->info[lookup_color->pixel].ref_count++;
2133 colors[i].pixel = lookup_color->pixel;
2141 /* If that failed, we try to allocate a new color, or approxmiate
2142 * with what we can get if best_match is TRUE.
2146 if (private->private_val)
2147 return gdk_colormap_alloc_colors_private (colormap, colors, ncolors, writeable, best_match, success);
2149 return gdk_colormap_alloc_colors_shared (colormap, colors, ncolors, writeable, best_match, success);
2156 gdk_colormap_alloc_colors (GdkColormap *colormap,
2160 gboolean best_match,
2163 GdkColormapPrivate *private;
2166 gint nremaining = 0;
2169 g_return_val_if_fail (colormap != NULL, FALSE);
2170 g_return_val_if_fail (colors != NULL, FALSE);
2172 private = (GdkColormapPrivate*) colormap;
2174 for (i=0; i<ncolors; i++)
2179 switch (private->visual->type)
2181 case GDK_VISUAL_PSEUDO_COLOR:
2182 case GDK_VISUAL_GRAYSCALE:
2184 return gdk_colormap_alloc_colors_writeable (colormap, colors, ncolors,
2185 writeable, best_match, success);
2187 return gdk_colormap_alloc_colors_pseudocolor (colormap, colors, ncolors,
2188 writeable, best_match, success);
2191 case GDK_VISUAL_TRUE_COLOR:
2192 visual = private->visual;
2194 for (i=0; i<ncolors; i++)
2196 colors[i].pixel = (((colors[i].red >> (16 - visual->red_prec)) << visual->red_shift) +
2197 ((colors[i].green >> (16 - visual->green_prec)) << visual->green_shift) +
2198 ((colors[i].blue >> (16 - visual->blue_prec)) << visual->blue_shift));
2203 case GDK_VISUAL_STATIC_GRAY:
2204 case GDK_VISUAL_STATIC_COLOR:
2205 for (i=0; i<ncolors; i++)
2207 xcolor.peRed = colors[i].red >> 8;
2208 xcolor.peGreen = colors[i].green >> 8;
2209 xcolor.peBlue = colors[i].blue >> 8;
2210 if (alloc_color (private->xcolormap, &xcolor, &colors[i].pixel))
2221 gdk_colormap_alloc_color (GdkColormap *colormap,
2224 gboolean best_match)
2228 GDK_NOTE (MISC, g_print ("gdk_colormap_alloc_color: (%.04x,%.04x,%.04x)",
2229 color->red, color->green, color->blue));
2231 gdk_colormap_alloc_colors (colormap, color, 1, writeable, best_match,
2233 GDK_NOTE (MISC, g_print (" -> %.08x\n", color->pixel));
2238 /* This is almost identical to gdk_colors_free.
2239 * Keep them in sync!
2242 gdk_colormap_free_colors (GdkColormap *colormap,
2246 GdkColormapPrivate *private;
2251 g_return_if_fail (colormap != NULL);
2252 g_return_if_fail (colors != NULL);
2254 private = (GdkColormapPrivate*) colormap;
2256 if ((private->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
2257 (private->visual->type != GDK_VISUAL_GRAYSCALE))
2260 pixels = g_new (gulong, ncolors);
2262 for (i=0; i<ncolors; i++)
2264 gulong pixel = colors[i].pixel;
2266 if (private->info[pixel].ref_count)
2268 private->info[pixel].ref_count--;
2270 if (private->info[pixel].ref_count == 0)
2272 pixels[npixels++] = pixel;
2273 if (!(private->info[pixel].flags & GDK_COLOR_WRITEABLE))
2274 g_hash_table_remove (private->hash, &colors[i]);
2275 private->info[pixel].flags = 0;
2280 XFreeColors (private->xcolormap, pixels, npixels, 0);
2285 gdk_color_alloc (GdkColormap *colormap,
2290 GDK_NOTE (MISC, g_print ("gdk_color_alloc: (%.04x,%.04x,%.04x)",
2291 color->red, color->green, color->blue));
2293 gdk_colormap_alloc_colors (colormap, color, 1, FALSE, TRUE, &success);
2295 GDK_NOTE (MISC, g_print (" -> %.08x\n", color->pixel));
2301 gdk_color_change (GdkColormap *colormap,
2304 GdkColormapPrivate *private;
2307 g_return_val_if_fail (colormap != NULL, FALSE);
2308 g_return_val_if_fail (color != NULL, FALSE);
2310 private = (GdkColormapPrivate*) colormap;
2312 xcolor.peRed = color->red >> 8;
2313 xcolor.peGreen = color->green >> 8;
2314 xcolor.peBlue = color->blue >> 8;
2316 if (SetPaletteEntries (private->xcolormap->palette,
2317 color->pixel, 1, &xcolor) == 0)
2318 g_warning ("gdk_color_change: SetPaletteEntries failed");
2319 private->xcolormap->stale = TRUE;
2325 gdk_color_hash (const GdkColor *colora)
2327 return ((colora->red) +
2328 (colora->green << 11) +
2329 (colora->blue << 22) +
2330 (colora->blue >> 6));
2334 gdk_color_equal (const GdkColor *colora,
2335 const GdkColor *colorb)
2337 g_return_val_if_fail (colora != NULL, FALSE);
2338 g_return_val_if_fail (colorb != NULL, FALSE);
2340 return ((colora->red == colorb->red) &&
2341 (colora->green == colorb->green) &&
2342 (colora->blue == colorb->blue));
2346 gdk_colormap_match_color (GdkColormap *cmap,
2348 const gchar *available)
2352 gint rdiff, gdiff, bdiff;
2355 g_return_val_if_fail (cmap != NULL, 0);
2356 g_return_val_if_fail (color != NULL, 0);
2358 colors = cmap->colors;
2362 for (i = 0; i < cmap->size; i++)
2364 if ((!available) || (available && available[i]))
2366 rdiff = (color->red - colors[i].red);
2367 gdiff = (color->green - colors[i].green);
2368 bdiff = (color->blue - colors[i].blue);
2370 sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff);
2384 gdk_colormap_lookup (Colormap xcolormap)
2391 cmap = g_hash_table_lookup (colormap_hash, &xcolormap);
2396 gdk_colormap_add (GdkColormap *cmap)
2398 GdkColormapPrivate *private;
2401 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
2402 (GCompareFunc) gdk_colormap_cmp);
2404 private = (GdkColormapPrivate*) cmap;
2406 g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
2410 gdk_colormap_remove (GdkColormap *cmap)
2412 GdkColormapPrivate *private;
2415 colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
2416 (GCompareFunc) gdk_colormap_cmp);
2418 private = (GdkColormapPrivate*) cmap;
2420 g_hash_table_remove (colormap_hash, &private->xcolormap);
2424 gdk_colormap_hash (Colormap *cmap)
2426 return (guint) *cmap;
2430 gdk_colormap_cmp (Colormap *a,
2437 gdk_color_to_string (GdkColor *color)
2439 static char buf[100];
2441 sprintf (buf, "(%.04x,%.04x,%.04x): %.06x",
2442 color->red, color->green, color->blue, color->pixel);