diff options
author | Søren Sandmann <sandmann@redhat.com> | 2008-03-08 20:18:32 -0500 |
---|---|---|
committer | Søren Sandmann <sandmann@redhat.com> | 2008-03-08 20:18:32 -0500 |
commit | ef179174f0bf2febb89b4afb0bcb4bb413acded7 (patch) | |
tree | 822011beee90c3064f248cb7eab0efcbb2210db3 | |
parent | ba16ddcb5821f09273356115ebe98f2a2f413591 (diff) |
Better backgrounds
-rw-r--r-- | siv.c | 47 |
1 files changed, 21 insertions, 26 deletions
@@ -104,6 +104,8 @@ on_expose (GtkWidget *drawing_area, GdkEventExpose *expose, Application *app) int win_x, win_y; int window_width, window_height; GdkRectangle image; + gboolean no_background; + guint32 color1, color2; if (!app->original) return TRUE; @@ -125,34 +127,27 @@ on_expose (GtkWidget *drawing_area, GdkEventExpose *expose, Application *app) if (!gdk_rectangle_intersect (&(expose->area), &image, &dest)) return TRUE; - g_print ("dest: %d %d %d %d\n", dest.x, dest.y, dest.width, dest.height); - - /* We create a temporary pixbuf without alpha (since X is generally worthless) */ - if (gtk_check_menu_item_get_active (GET_WIDGET (app, "menu_no"))) - has_alpha = TRUE; - else - has_alpha = FALSE; - - tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, has_alpha, 8, dest.width, dest.height); + tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, dest.width, dest.height); if (gtk_check_menu_item_get_active (GET_WIDGET (app, "menu_no"))) { - g_print ("no background\n"); - /* FIXME: fill pixbuf with background color */ - - gdk_pixbuf_fill (tmp, 0x00000000); + GdkColor color = drawing_area->style->bg[GTK_STATE_NORMAL]; + + color1 = (color.red & 0xff00) << 8; + color1 |= (color.green & 0xff00); + color1 |= (color.blue & 0xff00) >> 8; + + color2 = color1; } else if (gtk_check_menu_item_get_active (GET_WIDGET (app, "menu_white"))) { - g_print ("white background\n"); - /* FIXME: fill with white */ - - gdk_pixbuf_fill (tmp, 0xffffffff); + color1 = 0x00ffffff; + color2 = 0x00ffffff; } else if (gtk_check_menu_item_get_active (GET_WIDGET (app, "menu_checkerboard"))) { - g_print ("check\n"); - /* FIXME: make checkerboard, or use composite_color */ + color1 = 0x00808080; + color2 = 0x00cccccc; } if (gtk_check_menu_item_get_active (GET_WIDGET (app, "menu_smooth_image"))) @@ -160,13 +155,13 @@ on_expose (GtkWidget *drawing_area, GdkEventExpose *expose, Application *app) else interp = GDK_INTERP_NEAREST; - g_print ("dest: %d %d\n", dest.x, dest.y); - gdk_pixbuf_composite (app->original, tmp, - 0, 0, dest.width, dest.height, - -(dest.x - image.x), -(dest.y - image.y), - get_scale (app), get_scale (app), - interp, 0xFF); - g_print ("asdf\n"); + gdk_pixbuf_composite_color (app->original, tmp, + 0, 0, dest.width, dest.height, + -(dest.x - image.x), -(dest.y - image.y), + get_scale (app), get_scale (app), + interp, 0xff, + dest.x - image.x, dest.y - image.y, + 16, color1, color2); gdk_draw_pixbuf (drawing_area->window, NULL, tmp, 0, 0, dest.x, dest.y, dest.width, dest.height, GDK_RGB_DITHER_NONE, 0, 0); |