[gimp/gimp-2-10] Issue #3124 - layer mask pastes as a greyscale layer/grayscale layer...



commit 52a182eaed61283ee49b2b93b9b0c1901be1af9d
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 25 17:05:49 2019 +0200

    Issue #3124 - layer mask pastes as a greyscale layer/grayscale layer...
    
    ...in a color image/colour image
    
    gimp_edit_paste_get_layer(): only use the pasted-to drawable's format
    with alpha if this is really a floating paste, use the image's layer
    format with alpha for "as new layer" cases.
    
    (cherry picked from commit 1f57675a46f71fbb77daf68357362e7bc4ae5902)

 app/core/gimp-edit.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/app/core/gimp-edit.c b/app/core/gimp-edit.c
index e2b521da9e..372ad2dcf7 100644
--- a/app/core/gimp-edit.c
+++ b/app/core/gimp-edit.c
@@ -207,6 +207,25 @@ gimp_edit_paste_is_in_place (GimpPasteType paste_type)
   g_return_val_if_reached (FALSE);
 }
 
+static gboolean
+gimp_edit_paste_is_floating (GimpPasteType paste_type)
+{
+  switch (paste_type)
+    {
+    case GIMP_PASTE_TYPE_FLOATING:
+    case GIMP_PASTE_TYPE_FLOATING_INTO:
+    case GIMP_PASTE_TYPE_FLOATING_IN_PLACE:
+    case GIMP_PASTE_TYPE_FLOATING_INTO_IN_PLACE:
+      return TRUE;
+
+    case GIMP_PASTE_TYPE_NEW_LAYER:
+    case GIMP_PASTE_TYPE_NEW_LAYER_IN_PLACE:
+      return FALSE;
+    }
+
+  g_return_val_if_reached (FALSE);
+}
+
 static GimpLayer *
 gimp_edit_paste_get_layer (GimpImage     *image,
                            GimpDrawable  *drawable,
@@ -232,7 +251,7 @@ gimp_edit_paste_get_layer (GimpImage     *image,
   /*  floating pastes always have the pasted-to drawable's format with
    *  alpha; if drawable == NULL, user is pasting into an empty image
    */
-  if (drawable)
+  if (drawable && gimp_edit_paste_is_floating (*paste_type))
     floating_format = gimp_drawable_get_format_with_alpha (drawable);
   else
     floating_format = gimp_image_get_layer_format (image, TRUE);


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