[gegl] operations/external/save-pixbuf: Simplify the stride calculation



commit 7a7b728f89c32c2e792457795780813c44dc5ab7
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Feb 23 15:39:40 2017 +0100

    operations/external/save-pixbuf: Simplify the stride calculation
    
    ... and use the same value to read the GeglBuffer as the one passed to
    GdkPixbuf. This should avoid any inadvertent mismatches.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779136

 operations/external/save-pixbuf.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/operations/external/save-pixbuf.c b/operations/external/save-pixbuf.c
index 7fdcfdf..e19d50d 100644
--- a/operations/external/save-pixbuf.c
+++ b/operations/external/save-pixbuf.c
@@ -56,6 +56,7 @@ process (GeglOperation       *operation,
       gboolean has_alpha;
       gint bpp;
       gint bps;
+      gint stride;
 
       g_object_get (input, "format", &format, NULL);
 
@@ -69,8 +70,10 @@ process (GeglOperation       *operation,
       babl = babl_format (name);
 
       bpp = babl_format_get_bytes_per_pixel (babl);
-      temp = g_malloc (rect->width * rect->height * bpp);
-      gegl_buffer_get (input, rect, 1.0, babl, temp, GEGL_AUTO_ROWSTRIDE,
+      stride = bpp * rect->width;
+
+      temp = g_malloc0 (stride * rect->height);
+      gegl_buffer_get (input, rect, 1.0, babl, temp, stride,
                        GEGL_ABYSS_NONE);
       if (temp) {
     *pixbuf = gdk_pixbuf_new_from_data (temp,
@@ -78,7 +81,7 @@ process (GeglOperation       *operation,
                         has_alpha,
                         bps,
                         rect->width, rect->height,
-                        rect->width * (has_alpha ? 4 : 3) * bps/8,
+                        stride,
                         (GdkPixbufDestroyNotify) g_free, NULL);
       }
       else {


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