mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
demos: Convert testpixbuf-save to Cairo
This commit is contained in:
parent
d7a1973f9f
commit
244fc05cff
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user