[gimp/gimp-2-10] plug-ins: fix #6116 grayscale gif animation hangs on export.



commit 815e6248511d67ccdde36fd8111bf22c77d71cd0
Author: Jacob Boerema <jgboerema gmail com>
Date:   Wed May 19 17:49:01 2021 -0400

    plug-ins: fix #6116 grayscale gif animation hangs on export.
    
    GIF export was not taking into account that there can be
    both grayscale layers with and without alpha in an image.
    
    We make sure that the GEGL buffer knows the type of
    drawable for the current layer.
    
    (cherry picked from commit 3b3ab0aa1195a65484480b93cc21190039cb66fa)
    
    # Conflicts:
    #       plug-ins/common/file-gif-save.c

 plug-ins/common/file-gif-save.c | 37 +++++++++++++++++++++++++++++++------
 1 file changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/common/file-gif-save.c b/plug-ins/common/file-gif-save.c
index cd849be262..43d7dd92d5 100644
--- a/plug-ins/common/file-gif-save.c
+++ b/plug-ins/common/file-gif-save.c
@@ -791,7 +791,29 @@ save_image (GFile   *file,
    * file, not a vanilla GIF87a.
    */
   if (nlayers > 1)
-    is_gif89 = TRUE;
+    {
+      is_gif89 = TRUE;
+
+      /* Layers can be with or without alpha channel. Make sure we set
+       * alpha if there is at least one layer with alpha channel. */
+      if (drawable_type == GIMP_GRAY_IMAGE ||
+          drawable_type == GIMP_INDEXED_IMAGE)
+        {
+          for (list = layers, i = nlayers - 1;
+              list && i >= 0;
+              list = g_list_next (list), i--, cur_progress = (nlayers - i) * rows)
+            {
+              GimpImageType dr_type = gimp_drawable_type (drawable);
+
+              if (dr_type == GIMP_GRAYA_IMAGE ||
+                  dr_type == GIMP_INDEXEDA_IMAGE)
+                {
+                  drawable_type = dr_type;
+                  break;
+                }
+            }
+        }
+    }
 
   if (gsvals.save_comment)
     is_gif89 = TRUE;
@@ -827,11 +849,6 @@ save_image (GFile   *file,
         {
           Red[i] = Green[i] = Blue[i] = i;
         }
-
-      if (drawable_type == GIMP_GRAYA_IMAGE)
-        format = babl_format ("Y'A u8");
-      else
-        format = babl_format ("Y' u8");
       break;
 
     default:
@@ -944,6 +961,14 @@ save_image (GFile   *file,
   for (i = nlayers - 1; i >= 0; i--, cur_progress = (nlayers - i) * rows)
     {
       drawable_type = gimp_drawable_type (layers[i]);
+      if (drawable_type == GIMP_GRAYA_IMAGE)
+        {
+          format = babl_format ("Y'A u8");
+        }
+      else if (drawable_type == GIMP_GRAY_IMAGE)
+        {
+          format = babl_format ("Y' u8");
+        }
       buffer = gimp_drawable_get_buffer (layers[i]);
       gimp_drawable_offsets (layers[i], &offset_x, &offset_y);
       cols = gimp_drawable_width (layers[i]);


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