[eog] Use cairo recommended rowstride for the surface in EogPrintPreview



commit 8a9237692a572ef230ffc25593b3d673b15de9f1
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Thu Aug 12 22:08:00 2010 +0300

    Use cairo recommended rowstride for the surface in EogPrintPreview

 src/eog-print-preview.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/eog-print-preview.c b/src/eog-print-preview.c
index 0a8d0f7..30de4cf 100644
--- a/src/eog-print-preview.c
+++ b/src/eog-print-preview.c
@@ -704,6 +704,7 @@ create_surface_from_pixbuf (GdkPixbuf *pixbuf)
   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;
@@ -715,10 +716,11 @@ create_surface_from_pixbuf (GdkPixbuf *pixbuf)
   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);
+						 width, height, cairo_stride);
   cairo_surface_set_user_data (surface, &key,
 			       cairo_pixels, (cairo_destroy_func_t)g_free);
 
@@ -775,7 +777,7 @@ create_surface_from_pixbuf (GdkPixbuf *pixbuf)
 	}
 
       gdk_pixels += gdk_rowstride;
-      cairo_pixels += 4 * width;
+      cairo_pixels += cairo_stride;
     }
 
   return surface;



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