[gimp/gimp-2-10] Issue #2617 - Export to C image artifacts



commit ffbe7282be9a5278adbf31d19e6e510f52080fc4
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jan 2 21:25:07 2019 +0100

    Issue #2617 - Export to C image artifacts
    
    As correctly spotted by Royce Pipkins, the buffer for the drawable's
    pixel lines was too small.
    
    Also fix the plug-in to hardcode "R'G'B'[A] u8" so it won't misbehave
    on high bit-depth images, and make it work on all sorts of drawables,
    not only "RGB*" (it will still always export RGB images).
    
    (cherry picked from commit 74c9d835e8bd28f31663a41fc0e668dc9da7483d)

 plug-ins/common/file-csource.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/common/file-csource.c b/plug-ins/common/file-csource.c
index 9258e875e5..2b79148afb 100644
--- a/plug-ins/common/file-csource.c
+++ b/plug-ins/common/file-csource.c
@@ -109,7 +109,7 @@ query (void)
                           "Tim Janik",
                           "1999",
                           N_("C source code"),
-                          "RGB*",
+                          "*",
                           GIMP_PLUGIN,
                           G_N_ELEMENTS (save_args), 0,
                           save_args, NULL);
@@ -466,6 +466,7 @@ save_image (GFile   *file,
   gint           width;
   gint           height;
   gint           x, y, pad, n_bytes, bpp;
+  const Babl    *drawable_format;
   gint           drawable_bpp;
 
   output = G_OUTPUT_STREAM (g_file_replace (file,
@@ -490,11 +491,16 @@ save_image (GFile   *file,
   width  = gegl_buffer_get_width  (buffer);
   height = gegl_buffer_get_height (buffer);
 
-  drawable_bpp = gimp_drawable_bpp (drawable_ID);
+  if (gimp_drawable_has_alpha (drawable_ID))
+    drawable_format = babl_format ("R'G'B'A u8");
+  else
+    drawable_format = babl_format ("R'G'B' u8");
+
+  drawable_bpp = babl_format_get_bytes_per_pixel (drawable_format);
 
   bpp = config->rgb565 ? 2 : (config->alpha ? 4 : 3);
   n_bytes = width * height * bpp;
-  pad = width * bpp;
+  pad = width * drawable_bpp;
   if (config->use_rle)
     pad = MAX (pad, 130 + n_bytes / 127);
 
@@ -504,7 +510,7 @@ save_image (GFile   *file,
   for (y = 0; y < height; y++)
     {
       gegl_buffer_get (buffer, GEGL_RECTANGLE (0, y, width, 1), 1.0,
-                       NULL, data,
+                       drawable_format, data,
                        GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
 
       if (bpp == 2)


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