[gimp] app: fix Alpha to Selection for single selected layer.



commit 74d09904566a284c4f3cdee4530a050f6fa6a0d5
Author: Jehan <jehan girinstud io>
Date:   Mon Jul 6 23:15:12 2020 +0200

    app: fix Alpha to Selection for single selected layer.
    
    By adding support for multiple selected layers, it seems I broke the
    single selected layer case. Fixed now!

 app/core/gimpchannel-combine.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c
index 2d87078f57..db8ccab7c9 100644
--- a/app/core/gimpchannel-combine.c
+++ b/app/core/gimpchannel-combine.c
@@ -549,15 +549,28 @@ gimp_channel_combine_items (GimpChannel    *mask,
   if (! channel)
     {
       channel = gimp_channel_new (image,
-                                      gimp_image_get_width (image),
-                                      gimp_image_get_height (image),
-                                      NULL, NULL);
+                                  gimp_image_get_width (image),
+                                  gimp_image_get_height (image),
+                                  NULL, NULL);
       gimp_channel_clear (channel, NULL, FALSE);
 
       if (g_list_length (layers) == 1)
-        gimp_channel_combine_buffer (channel,
-                                     gimp_drawable_get_buffer (GIMP_DRAWABLE (layers->data)),
-                                     GIMP_CHANNEL_OP_REPLACE, 0, 0);
+        {
+          if (gimp_drawable_has_alpha (layers->data))
+            {
+              GimpChannel *alpha;
+
+              alpha = gimp_channel_new_from_alpha (image,
+                                                   layers->data, NULL, NULL);
+              gimp_channel_combine_mask (channel, alpha,
+                                         GIMP_CHANNEL_OP_REPLACE, 0, 0);
+              g_object_unref (alpha);
+            }
+          else
+            {
+              gimp_channel_all (channel, FALSE);
+            }
+        }
     }
 
   for (iter = items; iter; iter = iter->next)


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