summaryrefslogtreecommitdiff
path: root/gtk/gtkpixmap.c
diff options
context:
space:
mode:
authorCST 1998 Shawn T. Amundson <amundson@gtk.org>1998-12-03 05:52:19 +0000
committerShawn Amundson <amundson@src.gnome.org>1998-12-03 05:52:19 +0000
commit7cc3040412061f147c21c3c701bd211458029f9d (patch)
tree3cb8053aa6a0c3c1fc6ad1913290e4306a136f5a /gtk/gtkpixmap.c
parent8285f4fc6f705e72d16f4c6b24b7587f7c6cf9ab (diff)
downloadgdk-pixbuf-7cc3040412061f147c21c3c701bd211458029f9d.tar.gz
Fixes for low-color displays and a slight enhancement for true-color
Wed Dec 2 17:45:21 CST 1998 Shawn T. Amundson <amundson@gtk.org> * gtk/gtkpixmap.c: Fixes for low-color displays and a slight enhancement for true-color displays. * INSTALL: README: configure.in: gtk+.spec: docs/gtk-config.1: up to version 1.1.6
Diffstat (limited to 'gtk/gtkpixmap.c')
-rw-r--r--gtk/gtkpixmap.c98
1 files changed, 60 insertions, 38 deletions
diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c
index f1e662535..2b00d04d1 100644
--- a/gtk/gtkpixmap.c
+++ b/gtk/gtkpixmap.c
@@ -263,63 +263,85 @@ build_insensitive_pixmap(GtkPixmap *gtkpixmap)
gint32 red, green, blue;
GtkStyle *style;
GtkWidget *window;
+ GdkColor c;
+ int failed;
window = GTK_WIDGET (gtkpixmap);
g_return_if_fail(window != NULL);
gdk_window_get_size(pixmap, &w, &h);
- visual = gtk_widget_get_visual(GTK_WIDGET(gtkpixmap));
- cmap = gtk_widget_get_colormap(GTK_WIDGET(gtkpixmap));
+ image = gdk_image_get(pixmap, 0, 0, w, h);
+ insensitive = gdk_pixmap_new(GTK_WIDGET (gtkpixmap)->window, w, h, -1);
gc = gdk_gc_new (pixmap);
+ visual = gtk_widget_get_visual(GTK_WIDGET(gtkpixmap));
+ cmap = gtk_widget_get_colormap(GTK_WIDGET(gtkpixmap));
cc = gdk_color_context_new(visual, cmap);
+
if ((cc->mode != GDK_CC_MODE_TRUE) && (cc->mode != GDK_CC_MODE_MY_GRAY))
{
- gdk_color_context_free(cc);
+ gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
+
style = gtk_widget_get_style(window);
color = style->bg[0];
gdk_gc_set_foreground (gc, &color);
- for (y = 0; y < h; y ++)
+ for (y = 0; y < h; y++)
{
for (x = y % 2; x < w; x += 2)
{
- gdk_draw_point(pixmap, gc, x, y);
+ gdk_draw_point(insensitive, gc, x, y);
}
}
- gdk_gc_destroy(gc);
- return;
- }
-
- image = gdk_image_get(pixmap, 0, 0, w, h);
- gdk_gc_get_values(gc, &vals);
- style = gtk_widget_get_style(window);
- color = style->bg[0];
- red = color.red;
- green = color.green;
- blue = color.blue;
- for (y = 0; y < h; y++)
- {
- for (x = 0; x < w; x++)
- {
- GdkColor c;
- int failed;
- c.pixel = gdk_image_get_pixel(image, x, y);
- gdk_color_context_query_color(cc, &c);
- c.red = (((gint32)c.red - red) >> 1) + red;
- c.green = (((gint32)c.green - green) >> 1) + green;
- c.blue = (((gint32)c.blue - blue) >> 1) + blue;
- c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
- &failed);
- gdk_image_put_pixel(image, x, y, c.pixel);
- }
- }
- insensitive = gdk_pixmap_new(GTK_WIDGET (gtkpixmap)->window, w, h, -1);
- gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
- gtkpixmap->pixmap_insensitive = insensitive;
- gdk_image_destroy(image);
- gdk_gc_destroy(gc);
- gdk_color_context_free(cc);
+ }
+ else
+ {
+ gdk_gc_get_values(gc, &vals);
+ style = gtk_widget_get_style(window);
+
+ color = style->bg[0];
+ red = color.red;
+ green = color.green;
+ blue = color.blue;
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ c.pixel = gdk_image_get_pixel(image, x, y);
+ gdk_color_context_query_color(cc, &c);
+ c.red = (((gint32)c.red - red) >> 1) + red;
+ c.green = (((gint32)c.green - green) >> 1) + green;
+ c.blue = (((gint32)c.blue - blue) >> 1) + blue;
+ c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
+ &failed);
+ gdk_image_put_pixel(image, x, y, c.pixel);
+ }
+ }
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = y % 2; x < w; x += 2)
+ {
+ c.pixel = gdk_image_get_pixel(image, x, y);
+ gdk_color_context_query_color(cc, &c);
+ c.red = (((gint32)c.red - red) >> 1) + red;
+ c.green = (((gint32)c.green - green) >> 1) + green;
+ c.blue = (((gint32)c.blue - blue) >> 1) + blue;
+ c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
+ &failed);
+ gdk_image_put_pixel(image, x, y, c.pixel);
+ }
+ }
+
+ gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
+ }
+
+ gtkpixmap->pixmap_insensitive = insensitive;
+
+ gdk_image_destroy(image);
+ gdk_color_context_free(cc);
+ gdk_gc_destroy(gc);
}