[gimp] plug-ins: add support for extra layer mask



commit 969b71f78d5754e67844f84124da1d984af88026
Author: Jacob Boerema <jgboerema gmail com>
Date:   Thu Aug 4 13:32:43 2022 -0400

    plug-ins: add support for extra layer mask
    
    According to the specs the extra mask (which they call real user supplied
    layer mask) is used "when both a user mask and a vector mask are present".
    
    I haven't seen an example that has the extra mask, so not sure which of
    the masks would appear first.
    
    For now assuming that the extra mask will be first. The advantage of
    adding this here now, is that we won't try to add a mask channel as a
    normal channel.

 plug-ins/file-psd/psd-load.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index cd41f23eb2..5a3c69de8e 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -1867,10 +1867,25 @@ add_layers (GimpImage     *image,
           for (cidx = 0; cidx < lyr_a[lidx]->num_channels; ++cidx)
             {
               IFDBG(3) g_debug ("Channel: %d - id: %d", cidx, lyr_chn[cidx]->id);
-              if (lyr_chn[cidx]->id == PSD_CHANNEL_MASK)
+              if (lyr_chn[cidx]->id == PSD_CHANNEL_MASK ||
+                  lyr_chn[cidx]->id == PSD_CHANNEL_EXTRA_MASK)
                 {
-                  user_mask = TRUE;
-                  user_mask_chn = cidx;
+                  /* According to the specs the extra mask (which they call
+                   * real user supplied layer mask) is used "when both a user
+                   * mask and a vector mask are present".
+                   * I haven't seen an example that has the extra mask, so not
+                   * sure which of the masks would appear first.
+                   * For now assuming that the extra mask will be first. */
+                  if (! user_mask)
+                    {
+                      user_mask = TRUE;
+                      user_mask_chn = cidx;
+                    }
+                  else
+                    {
+                      /* Not using this mask, make sure it gets freed. */
+                      g_free (lyr_chn[cidx]->data);
+                    }
                 }
               else if (lyr_chn[cidx]->id == PSD_CHANNEL_ALPHA)
                 {


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