demos: Use Cairo instead of gdk_draw_pixbuf()

This commit is contained in:
Benjamin Otte 2010-07-12 16:48:53 +02:00
parent 0ba97c7aae
commit 970ae51e38
2 changed files with 16 additions and 10 deletions

View File

@ -35,6 +35,7 @@ gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *dest;
cairo_t *cr;
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
@ -48,11 +49,13 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
interp_type, overall_alpha,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_draw_pixbuf (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], dest,
0, 0, event->area.x, event->area.y,
event->area.width, event->area.height,
GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
cr = gdk_cairo_create (event->window);
gdk_cairo_set_source_pixbuf (cr, dest, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
cairo_fill (cr);
cairo_destroy (cr);
g_object_unref (dest);
return TRUE;

View File

@ -322,6 +322,7 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
GdkPixbuf *dest;
cairo_t *cr;
gdk_window_set_back_pixmap (drawing_area->window, NULL, FALSE);
@ -335,11 +336,13 @@ expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
GDK_INTERP_BILINEAR, 255,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_draw_pixbuf (drawing_area->window, drawing_area->style->fg_gc[GTK_STATE_NORMAL], dest,
0, 0, event->area.x, event->area.y,
event->area.width, event->area.height,
GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
cr = gdk_cairo_create (drawing_area->window);
gdk_cairo_set_source_pixbuf (cr, dest, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
cairo_fill (cr);
cairo_destroy (cr);
g_object_unref (dest);
} else {
gdk_draw_rgb_image (drawing_area->window,