[gtk+/gtk-2-22] demos: Use Cairo instead of gdk_draw_pixbuf()



commit 970ae51e386ff6a585b469ae92846b876d892bb1
Author: Benjamin Otte <otte redhat com>
Date:   Mon Jul 12 16:48:53 2010 +0200

    demos: Use Cairo instead of gdk_draw_pixbuf()

 demos/testpixbuf-scale.c |   13 ++++++++-----
 demos/testpixbuf.c       |   13 ++++++++-----
 2 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/demos/testpixbuf-scale.c b/demos/testpixbuf-scale.c
index d512513..6d335e1 100644
--- a/demos/testpixbuf-scale.c
+++ b/demos/testpixbuf-scale.c
@@ -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;
diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c
index 64357c1..2c4ee01 100644
--- a/demos/testpixbuf.c
+++ b/demos/testpixbuf.c
@@ -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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]