summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-07-13 17:49:33 +0200
committerBenjamin Otte <otte@redhat.com>2010-08-10 21:02:26 +0200
commit17b8bee168ad255d8d9c157a03adf1a2a1c64bda (patch)
tree5c3266abec012e1f90a0aa61a59899fcb59be59d /demos
parent46794cc65cf3514a6b042dffdd129091b1af6a4c (diff)
downloadgtk+-17b8bee168ad255d8d9c157a03adf1a2a1c64bda.tar.gz
demos: Convert testpixbuf-save to Cairo
Diffstat (limited to 'demos')
-rw-r--r--demos/testpixbuf-save.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/demos/testpixbuf-save.c b/demos/testpixbuf-save.c
index 3929c7eaf1..c8a6679ce2 100644
--- a/demos/testpixbuf-save.c
+++ b/demos/testpixbuf-save.c
@@ -311,32 +311,18 @@ static int
expose_cb (GtkWidget *drawing_area, GdkEventExpose *evt, gpointer data)
{
GdkPixbuf *pixbuf;
+ cairo_t *cr;
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area),
"pixbuf");
- if (gdk_pixbuf_get_has_alpha (pixbuf)) {
- gdk_draw_rgb_32_image (drawing_area->window,
- drawing_area->style->black_gc,
- evt->area.x, evt->area.y,
- evt->area.width,
- evt->area.height,
- GDK_RGB_DITHER_MAX,
- gdk_pixbuf_get_pixels (pixbuf) +
- (evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
- (evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
- gdk_pixbuf_get_rowstride (pixbuf));
- } else {
- gdk_draw_rgb_image (drawing_area->window,
- drawing_area->style->black_gc,
- evt->area.x, evt->area.y,
- evt->area.width,
- evt->area.height,
- GDK_RGB_DITHER_NORMAL,
- gdk_pixbuf_get_pixels (pixbuf) +
- (evt->area.y * gdk_pixbuf_get_rowstride (pixbuf)) +
- (evt->area.x * gdk_pixbuf_get_n_channels (pixbuf)),
- gdk_pixbuf_get_rowstride (pixbuf));
- }
+
+ cr = gdk_cairo_create (evt->window);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ gdk_cairo_rectangle (cr, &evt->area);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
return FALSE;
}
@@ -374,8 +360,6 @@ main (int argc, char **argv)
gtk_init (&argc, &argv);
- gtk_widget_set_default_colormap (gdk_rgb_get_colormap ());
-
root = gdk_get_default_root_window ();
pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
0, 0, 0, 0, 150, 160);