Fixes to allow GTK to work with colormaps that aren't 256 entries long.

Sun Mar 22 19:01:36 1998  Owen Taylor  <owt1@cornell.edu>

	* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
	  that aren't 256 entries long. (colormap->colors is
	  now dynamically allocated)
This commit is contained in:
Owen Taylor 1998-03-23 00:16:13 +00:00 committed by Owen Taylor
parent 16aa9c1964
commit dac3ffed60
10 changed files with 154 additions and 51 deletions

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -1,3 +1,9 @@
Sun Mar 22 19:01:36 1998 Owen Taylor <owt1@cornell.edu>
* gdk/gdkcolor.c: Fixes to allow GTK to work with colormaps
that aren't 256 entries long. (colormap->colors is
now dynamically allocated)
Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu> Sun Mar 22 16:25:46 1998 Owen Taylor <owt1@cornell.edu>
* gtk/gtkmain.c (gtk_init): fixes to locale checks * gtk/gtkmain.c (gtk_init): fixes to locale checks

View File

@ -40,7 +40,6 @@ gdk_colormap_new (GdkVisual *visual,
GdkColormap *colormap; GdkColormap *colormap;
GdkColormapPrivate *private; GdkColormapPrivate *private;
Visual *xvisual; Visual *xvisual;
XColor default_colors[256];
int size; int size;
int i; int i;
@ -55,6 +54,9 @@ gdk_colormap_new (GdkVisual *visual,
private->ref_count = 1; private->ref_count = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual; xvisual = ((GdkVisualPrivate*) visual)->xvisual;
colormap->size = visual->colormap_size;
colormap->colors = g_new (GdkColor, colormap->size);
switch (visual->type) switch (visual->type)
{ {
case GDK_VISUAL_GRAYSCALE: case GDK_VISUAL_GRAYSCALE:
@ -65,14 +67,18 @@ gdk_colormap_new (GdkVisual *visual,
if (private_cmap) if (private_cmap)
{ {
for (i = 0; i < 256; i++) XColor *default_colors;
default_colors = g_new (XColor, colormap->size);
for (i = 0; i < colormap->size; i++)
default_colors[i].pixel = i; default_colors[i].pixel = i;
XQueryColors (private->xdisplay, XQueryColors (private->xdisplay,
DefaultColormap (private->xdisplay, gdk_screen), DefaultColormap (private->xdisplay, gdk_screen),
default_colors, visual->colormap_size); default_colors, colormap->size);
for (i = 0; i < visual->colormap_size; i++) for (i = 0; i < colormap->size; i++)
{ {
colormap->colors[i].pixel = default_colors[i].pixel; colormap->colors[i].pixel = default_colors[i].pixel;
colormap->colors[i].red = default_colors[i].red; colormap->colors[i].red = default_colors[i].red;
@ -80,7 +86,9 @@ gdk_colormap_new (GdkVisual *visual,
colormap->colors[i].blue = default_colors[i].blue; colormap->colors[i].blue = default_colors[i].blue;
} }
gdk_colormap_change (colormap, visual->colormap_size); gdk_colormap_change (colormap, colormap->size);
g_free (default_colors);
} }
break; break;
@ -101,7 +109,7 @@ gdk_colormap_new (GdkVisual *visual,
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
colormap->colors[i].blue = i * 65535 / (size - 1); colormap->colors[i].blue = i * 65535 / (size - 1);
gdk_colormap_change (colormap, visual->colormap_size); gdk_colormap_change (colormap, colormap->size);
break; break;
case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_STATIC_GRAY:
@ -130,6 +138,7 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
gdk_colormap_remove (colormap); gdk_colormap_remove (colormap);
XFreeColormap (private->xdisplay, private->xcolormap); XFreeColormap (private->xdisplay, private->xcolormap);
g_free (colormap->colors);
g_free (colormap); g_free (colormap);
} }
@ -159,7 +168,7 @@ gdk_colormap_get_system (void)
{ {
static GdkColormap *colormap = NULL; static GdkColormap *colormap = NULL;
GdkColormapPrivate *private; GdkColormapPrivate *private;
XColor xpalette[256]; XColor *xpalette;
gint i; gint i;
if (!colormap) if (!colormap)
@ -174,10 +183,15 @@ gdk_colormap_get_system (void)
private->next_color = 0; private->next_color = 0;
private->ref_count = 1; private->ref_count = 1;
colormap->size = private->visual->colormap_size;
colormap->colors = g_new (GdkColor, colormap->size);
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) || if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR)) (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{ {
for (i = 0; i < 256; i++) xpalette = g_new (XColor, colormap->size);
for (i = 0; i < colormap->size; i++)
{ {
xpalette[i].pixel = i; xpalette[i].pixel = i;
xpalette[i].red = 0; xpalette[i].red = 0;
@ -186,15 +200,17 @@ gdk_colormap_get_system (void)
} }
XQueryColors (gdk_display, private->xcolormap, xpalette, XQueryColors (gdk_display, private->xcolormap, xpalette,
MIN (private->visual->colormap_size, 256)); colormap->size);
for (i = 0; i < 256; i++) for (i = 0; i < colormap->size; i++)
{ {
colormap->colors[i].pixel = xpalette[i].pixel; colormap->colors[i].pixel = xpalette[i].pixel;
colormap->colors[i].red = xpalette[i].red; colormap->colors[i].red = xpalette[i].red;
colormap->colors[i].green = xpalette[i].green; colormap->colors[i].green = xpalette[i].green;
colormap->colors[i].blue = xpalette[i].blue; colormap->colors[i].blue = xpalette[i].blue;
} }
g_free (xpalette);
} }
gdk_colormap_add (colormap); gdk_colormap_add (colormap);
@ -215,7 +231,7 @@ gdk_colormap_change (GdkColormap *colormap,
{ {
GdkColormapPrivate *private; GdkColormapPrivate *private;
GdkVisual *visual; GdkVisual *visual;
XColor palette[256]; XColor *palette;
gint shift; gint shift;
int max_colors; int max_colors;
int size; int size;
@ -223,6 +239,8 @@ gdk_colormap_change (GdkColormap *colormap,
g_return_if_fail (colormap != NULL); g_return_if_fail (colormap != NULL);
palette = g_new (XColor, ncolors);
private = (GdkColormapPrivate*) colormap; private = (GdkColormapPrivate*) colormap;
switch (private->visual->type) switch (private->visual->type)
{ {
@ -287,6 +305,8 @@ gdk_colormap_change (GdkColormap *colormap,
default: default:
break; break;
} }
g_free (palette);
} }
void void
@ -423,8 +443,7 @@ gdk_color_alloc (GdkColormap *colormap,
GdkColormapPrivate *private; GdkColormapPrivate *private;
GdkVisual *visual; GdkVisual *visual;
XColor xcolor; XColor xcolor;
gchar available[256]; gchar *available = NULL;
gint available_init;
gint return_val; gint return_val;
gint i, index; gint i, index;
@ -446,9 +465,10 @@ gdk_color_alloc (GdkColormap *colormap,
case GDK_VISUAL_PSEUDO_COLOR: case GDK_VISUAL_PSEUDO_COLOR:
if (private->private_val) if (private->private_val)
{ {
if (private->next_color > 255) if (private->next_color >= colormap->size)
{ {
for (i = 0; i < 256; i++) available = g_new (gchar, colormap->size);
for (i = 0; i < colormap->size; i++)
available[i] = TRUE; available[i] = TRUE;
index = gdk_colormap_match_color (colormap, color, available); index = gdk_colormap_match_color (colormap, color, available);
@ -465,7 +485,7 @@ gdk_color_alloc (GdkColormap *colormap,
} }
else else
{ {
xcolor.pixel = 255 - private->next_color; xcolor.pixel = colormap->size - 1 -private->next_color;
color->pixel = xcolor.pixel; color->pixel = xcolor.pixel;
private->next_color += 1; private->next_color += 1;
@ -475,8 +495,6 @@ gdk_color_alloc (GdkColormap *colormap,
} }
else else
{ {
available_init = 1;
while (1) while (1)
{ {
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor)) if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
@ -486,17 +504,18 @@ gdk_color_alloc (GdkColormap *colormap,
color->green = xcolor.green; color->green = xcolor.green;
color->blue = xcolor.blue; color->blue = xcolor.blue;
colormap->colors[color->pixel] = *color; if (color->pixel < colormap->size)
colormap->colors[color->pixel] = *color;
return_val = TRUE; return_val = TRUE;
break; break;
} }
else else
{ {
if (available_init) if (available == NULL)
{ {
available_init = 0; available = g_new (gchar, colormap->size);
for (i = 0; i < 256; i++) for (i = 0; i < colormap->size; i++)
available[i] = TRUE; available[i] = TRUE;
} }
@ -540,6 +559,9 @@ gdk_color_alloc (GdkColormap *colormap,
break; break;
} }
if (available)
g_free (available);
return return_val; return return_val;
} }
@ -582,8 +604,6 @@ gdkx_colormap_get (Colormap xcolormap)
{ {
GdkColormap *colormap; GdkColormap *colormap;
GdkColormapPrivate *private; GdkColormapPrivate *private;
XColor xpalette[256];
gint i;
colormap = gdk_colormap_lookup (xcolormap); colormap = gdk_colormap_lookup (xcolormap);
if (colormap) if (colormap)
@ -601,6 +621,12 @@ gdkx_colormap_get (Colormap xcolormap)
private->private_val = TRUE; private->private_val = TRUE;
private->next_color = 0; private->next_color = 0;
/* To do the following safely, we would have to have some way of finding
* out what the size or visual of the given colormap is. It seems
* X doesn't allow this
*/
#if 0
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
xpalette[i].pixel = i; xpalette[i].pixel = i;
@ -618,6 +644,10 @@ gdkx_colormap_get (Colormap xcolormap)
colormap->colors[i].green = xpalette[i].green; colormap->colors[i].green = xpalette[i].green;
colormap->colors[i].blue = xpalette[i].blue; colormap->colors[i].blue = xpalette[i].blue;
} }
#endif
colormap->colors = NULL;
colormap->size = 0;
gdk_colormap_add (colormap); gdk_colormap_add (colormap);
@ -642,7 +672,7 @@ gdk_colormap_match_color (GdkColormap *cmap,
max = 3 * (65536); max = 3 * (65536);
index = -1; index = -1;
for (i = 0; i < 256; i++) for (i = 0; i < cmap->size; i++)
{ {
if ((!available) || (available && available[i])) if ((!available) || (available && available[i]))
{ {

View File

@ -672,7 +672,8 @@ struct _GdkColor
*/ */
struct _GdkColormap struct _GdkColormap
{ {
GdkColor colors[256]; gint size;
GdkColor *colors;
}; };
/* The visual type. /* The visual type.

View File

@ -40,7 +40,6 @@ gdk_colormap_new (GdkVisual *visual,
GdkColormap *colormap; GdkColormap *colormap;
GdkColormapPrivate *private; GdkColormapPrivate *private;
Visual *xvisual; Visual *xvisual;
XColor default_colors[256];
int size; int size;
int i; int i;
@ -55,6 +54,9 @@ gdk_colormap_new (GdkVisual *visual,
private->ref_count = 1; private->ref_count = 1;
xvisual = ((GdkVisualPrivate*) visual)->xvisual; xvisual = ((GdkVisualPrivate*) visual)->xvisual;
colormap->size = visual->colormap_size;
colormap->colors = g_new (GdkColor, colormap->size);
switch (visual->type) switch (visual->type)
{ {
case GDK_VISUAL_GRAYSCALE: case GDK_VISUAL_GRAYSCALE:
@ -65,14 +67,18 @@ gdk_colormap_new (GdkVisual *visual,
if (private_cmap) if (private_cmap)
{ {
for (i = 0; i < 256; i++) XColor *default_colors;
default_colors = g_new (XColor, colormap->size);
for (i = 0; i < colormap->size; i++)
default_colors[i].pixel = i; default_colors[i].pixel = i;
XQueryColors (private->xdisplay, XQueryColors (private->xdisplay,
DefaultColormap (private->xdisplay, gdk_screen), DefaultColormap (private->xdisplay, gdk_screen),
default_colors, visual->colormap_size); default_colors, colormap->size);
for (i = 0; i < visual->colormap_size; i++) for (i = 0; i < colormap->size; i++)
{ {
colormap->colors[i].pixel = default_colors[i].pixel; colormap->colors[i].pixel = default_colors[i].pixel;
colormap->colors[i].red = default_colors[i].red; colormap->colors[i].red = default_colors[i].red;
@ -80,7 +86,9 @@ gdk_colormap_new (GdkVisual *visual,
colormap->colors[i].blue = default_colors[i].blue; colormap->colors[i].blue = default_colors[i].blue;
} }
gdk_colormap_change (colormap, visual->colormap_size); gdk_colormap_change (colormap, colormap->size);
g_free (default_colors);
} }
break; break;
@ -101,7 +109,7 @@ gdk_colormap_new (GdkVisual *visual,
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
colormap->colors[i].blue = i * 65535 / (size - 1); colormap->colors[i].blue = i * 65535 / (size - 1);
gdk_colormap_change (colormap, visual->colormap_size); gdk_colormap_change (colormap, colormap->size);
break; break;
case GDK_VISUAL_STATIC_GRAY: case GDK_VISUAL_STATIC_GRAY:
@ -130,6 +138,7 @@ gdk_colormap_real_destroy (GdkColormap *colormap)
gdk_colormap_remove (colormap); gdk_colormap_remove (colormap);
XFreeColormap (private->xdisplay, private->xcolormap); XFreeColormap (private->xdisplay, private->xcolormap);
g_free (colormap->colors);
g_free (colormap); g_free (colormap);
} }
@ -159,7 +168,7 @@ gdk_colormap_get_system (void)
{ {
static GdkColormap *colormap = NULL; static GdkColormap *colormap = NULL;
GdkColormapPrivate *private; GdkColormapPrivate *private;
XColor xpalette[256]; XColor *xpalette;
gint i; gint i;
if (!colormap) if (!colormap)
@ -174,10 +183,15 @@ gdk_colormap_get_system (void)
private->next_color = 0; private->next_color = 0;
private->ref_count = 1; private->ref_count = 1;
colormap->size = private->visual->colormap_size;
colormap->colors = g_new (GdkColor, colormap->size);
if ((private->visual->type == GDK_VISUAL_GRAYSCALE) || if ((private->visual->type == GDK_VISUAL_GRAYSCALE) ||
(private->visual->type == GDK_VISUAL_PSEUDO_COLOR)) (private->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{ {
for (i = 0; i < 256; i++) xpalette = g_new (XColor, colormap->size);
for (i = 0; i < colormap->size; i++)
{ {
xpalette[i].pixel = i; xpalette[i].pixel = i;
xpalette[i].red = 0; xpalette[i].red = 0;
@ -186,15 +200,17 @@ gdk_colormap_get_system (void)
} }
XQueryColors (gdk_display, private->xcolormap, xpalette, XQueryColors (gdk_display, private->xcolormap, xpalette,
MIN (private->visual->colormap_size, 256)); colormap->size);
for (i = 0; i < 256; i++) for (i = 0; i < colormap->size; i++)
{ {
colormap->colors[i].pixel = xpalette[i].pixel; colormap->colors[i].pixel = xpalette[i].pixel;
colormap->colors[i].red = xpalette[i].red; colormap->colors[i].red = xpalette[i].red;
colormap->colors[i].green = xpalette[i].green; colormap->colors[i].green = xpalette[i].green;
colormap->colors[i].blue = xpalette[i].blue; colormap->colors[i].blue = xpalette[i].blue;
} }
g_free (xpalette);
} }
gdk_colormap_add (colormap); gdk_colormap_add (colormap);
@ -215,7 +231,7 @@ gdk_colormap_change (GdkColormap *colormap,
{ {
GdkColormapPrivate *private; GdkColormapPrivate *private;
GdkVisual *visual; GdkVisual *visual;
XColor palette[256]; XColor *palette;
gint shift; gint shift;
int max_colors; int max_colors;
int size; int size;
@ -223,6 +239,8 @@ gdk_colormap_change (GdkColormap *colormap,
g_return_if_fail (colormap != NULL); g_return_if_fail (colormap != NULL);
palette = g_new (XColor, ncolors);
private = (GdkColormapPrivate*) colormap; private = (GdkColormapPrivate*) colormap;
switch (private->visual->type) switch (private->visual->type)
{ {
@ -287,6 +305,8 @@ gdk_colormap_change (GdkColormap *colormap,
default: default:
break; break;
} }
g_free (palette);
} }
void void
@ -423,8 +443,7 @@ gdk_color_alloc (GdkColormap *colormap,
GdkColormapPrivate *private; GdkColormapPrivate *private;
GdkVisual *visual; GdkVisual *visual;
XColor xcolor; XColor xcolor;
gchar available[256]; gchar *available = NULL;
gint available_init;
gint return_val; gint return_val;
gint i, index; gint i, index;
@ -446,9 +465,10 @@ gdk_color_alloc (GdkColormap *colormap,
case GDK_VISUAL_PSEUDO_COLOR: case GDK_VISUAL_PSEUDO_COLOR:
if (private->private_val) if (private->private_val)
{ {
if (private->next_color > 255) if (private->next_color >= colormap->size)
{ {
for (i = 0; i < 256; i++) available = g_new (gchar, colormap->size);
for (i = 0; i < colormap->size; i++)
available[i] = TRUE; available[i] = TRUE;
index = gdk_colormap_match_color (colormap, color, available); index = gdk_colormap_match_color (colormap, color, available);
@ -465,7 +485,7 @@ gdk_color_alloc (GdkColormap *colormap,
} }
else else
{ {
xcolor.pixel = 255 - private->next_color; xcolor.pixel = colormap->size - 1 -private->next_color;
color->pixel = xcolor.pixel; color->pixel = xcolor.pixel;
private->next_color += 1; private->next_color += 1;
@ -475,8 +495,6 @@ gdk_color_alloc (GdkColormap *colormap,
} }
else else
{ {
available_init = 1;
while (1) while (1)
{ {
if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor)) if (XAllocColor (private->xdisplay, private->xcolormap, &xcolor))
@ -486,17 +504,18 @@ gdk_color_alloc (GdkColormap *colormap,
color->green = xcolor.green; color->green = xcolor.green;
color->blue = xcolor.blue; color->blue = xcolor.blue;
colormap->colors[color->pixel] = *color; if (color->pixel < colormap->size)
colormap->colors[color->pixel] = *color;
return_val = TRUE; return_val = TRUE;
break; break;
} }
else else
{ {
if (available_init) if (available == NULL)
{ {
available_init = 0; available = g_new (gchar, colormap->size);
for (i = 0; i < 256; i++) for (i = 0; i < colormap->size; i++)
available[i] = TRUE; available[i] = TRUE;
} }
@ -540,6 +559,9 @@ gdk_color_alloc (GdkColormap *colormap,
break; break;
} }
if (available)
g_free (available);
return return_val; return return_val;
} }
@ -582,8 +604,6 @@ gdkx_colormap_get (Colormap xcolormap)
{ {
GdkColormap *colormap; GdkColormap *colormap;
GdkColormapPrivate *private; GdkColormapPrivate *private;
XColor xpalette[256];
gint i;
colormap = gdk_colormap_lookup (xcolormap); colormap = gdk_colormap_lookup (xcolormap);
if (colormap) if (colormap)
@ -601,6 +621,12 @@ gdkx_colormap_get (Colormap xcolormap)
private->private_val = TRUE; private->private_val = TRUE;
private->next_color = 0; private->next_color = 0;
/* To do the following safely, we would have to have some way of finding
* out what the size or visual of the given colormap is. It seems
* X doesn't allow this
*/
#if 0
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
xpalette[i].pixel = i; xpalette[i].pixel = i;
@ -618,6 +644,10 @@ gdkx_colormap_get (Colormap xcolormap)
colormap->colors[i].green = xpalette[i].green; colormap->colors[i].green = xpalette[i].green;
colormap->colors[i].blue = xpalette[i].blue; colormap->colors[i].blue = xpalette[i].blue;
} }
#endif
colormap->colors = NULL;
colormap->size = 0;
gdk_colormap_add (colormap); gdk_colormap_add (colormap);
@ -642,7 +672,7 @@ gdk_colormap_match_color (GdkColormap *cmap,
max = 3 * (65536); max = 3 * (65536);
index = -1; index = -1;
for (i = 0; i < 256; i++) for (i = 0; i < cmap->size; i++)
{ {
if ((!available) || (available && available[i])) if ((!available) || (available && available[i]))
{ {