[gimp] gimp_layer_transform_color(): don't assume the dest region has alpha



commit 0c57e8c68e256b81cda1de7b8aca66cdfd4afe04
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 8 20:54:51 2009 +0200

    gimp_layer_transform_color(): don't assume the dest region has alpha
    
    Don't blindly fill the dest region's alpha channel even if it has
    none. Fixes longstanding bug that made things without alpha dropped
    to indexed images to arrive broken.

 app/core/gimplayer.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 2e4fca4..dff0e3b 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -950,8 +950,9 @@ gimp_layer_transform_color (GimpImage     *image,
                             PixelRegion   *destPR,
                             GimpImageType  dest_type)
 {
-  GimpImageBaseType base_type = GIMP_IMAGE_TYPE_BASE_TYPE (src_type);
-  gboolean          alpha     = GIMP_IMAGE_TYPE_HAS_ALPHA (src_type);
+  GimpImageBaseType base_type  = GIMP_IMAGE_TYPE_BASE_TYPE (src_type);
+  gboolean          src_alpha  = GIMP_IMAGE_TYPE_HAS_ALPHA (src_type);
+  gboolean          dest_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (dest_type);
   gpointer          pr;
 
   for (pr = pixel_regions_register (2, srcPR, destPR);
@@ -972,9 +973,9 @@ gimp_layer_transform_color (GimpImage     *image,
             {
               gimp_image_transform_color (image, dest_type, d, base_type, s);
 
-              /*  alpha channel  */
-              d[destPR->bytes - 1] = (alpha ?
-                                      s[srcPR->bytes - 1] : OPAQUE_OPACITY);
+              if (dest_alpha)
+                d[destPR->bytes - 1] = (src_alpha ?
+                                        s[srcPR->bytes - 1] : OPAQUE_OPACITY);
 
               s += srcPR->bytes;
               d += destPR->bytes;



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