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



commit 3b3ab0aa1195a65484480b93cc21190039cb66fa
Author: Jacob Boerema <jgboerema gmail com>
Date:   Wed May 19 17:36:58 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.

 plug-ins/common/file-gif-save.c | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/common/file-gif-save.c b/plug-ins/common/file-gif-save.c
index dfbb2aff7c..161e850d4c 100644
--- a/plug-ins/common/file-gif-save.c
+++ b/plug-ins/common/file-gif-save.c
@@ -814,7 +814,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 (config_save_comment)
     is_gif89 = TRUE;
@@ -850,11 +872,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:
@@ -973,6 +990,15 @@ save_image (GFile         *file,
       GimpDrawable *drawable = list->data;
 
       drawable_type = gimp_drawable_type (drawable);
+      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 (drawable);
       gimp_drawable_get_offsets (drawable, &offset_x, &offset_y);
       cols = gimp_drawable_get_width (drawable);


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