diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2008-05-26 04:25:25 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2008-05-26 04:25:25 +0000 |
commit | 9ec6a65901aa1e4a494c09341f5a6ffbed8a8415 (patch) | |
tree | e08411d22b1b856a23c0d31a0e3e6877ebc8a04e /gdk/gdkcairo.c | |
parent | 4d734c0e6a8ae9ed2fe623c563047626f9ddec62 (diff) | |
download | gtk+-9ec6a65901aa1e4a494c09341f5a6ffbed8a8415.tar.gz |
Bug 513811 – Use cairo_format_stride_for_width()
* gtk/gtkhsv.c (paint_ring, paint_triangle):
* gdk/gdkcairo.c (gdk_cairo_set_source_pixbuf): Use
cairo_format_stride_for_width, proposed by Behdad Esfahbod.
* configure.in: Bump cairo requirement to 1.6.0
* INSTALL.in: Update required versions
svn path=/trunk/; revision=20170
Diffstat (limited to 'gdk/gdkcairo.c')
-rw-r--r-- | gdk/gdkcairo.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index f887627e65..4c2d91ac0b 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -146,6 +146,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, guchar *gdk_pixels = gdk_pixbuf_get_pixels (pixbuf); int gdk_rowstride = gdk_pixbuf_get_rowstride (pixbuf); int n_channels = gdk_pixbuf_get_n_channels (pixbuf); + int cairo_stride; guchar *cairo_pixels; cairo_format_t format; cairo_surface_t *surface; @@ -157,10 +158,12 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, else format = CAIRO_FORMAT_ARGB32; - cairo_pixels = g_malloc (4 * width * height); + cairo_stride = cairo_format_stride_for_width (format, width); + cairo_pixels = g_malloc (height * cairo_stride); surface = cairo_image_surface_create_for_data ((unsigned char *)cairo_pixels, - format, - width, height, 4 * width); + format, + width, height, cairo_stride); + cairo_surface_set_user_data (surface, &key, cairo_pixels, (cairo_destroy_func_t)g_free); @@ -217,7 +220,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr, } gdk_pixels += gdk_rowstride; - cairo_pixels += 4 * width; + cairo_pixels += cairo_stride; } cairo_set_source_surface (cr, surface, pixbuf_x, pixbuf_y); |