[gimp] app: fix color profile logic in gimp_image_convert_precision()



commit ce8e484764b341b5a3d777a367a34e9c327f5874
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 21 00:37:28 2016 +0200

    app: fix color profile logic in gimp_image_convert_precision()
    
    Not only the logic was broken, a local variable was also shadowing the
    "dest_profile" variable and preventing the broken logic to be applied
    at all. Double fail.

 app/core/gimpimage-convert-precision.c |   61 +++++++++++++++++--------------
 1 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/app/core/gimpimage-convert-precision.c b/app/core/gimpimage-convert-precision.c
index 082e02b..eafb428 100644
--- a/app/core/gimpimage-convert-precision.c
+++ b/app/core/gimpimage-convert-precision.c
@@ -135,37 +135,40 @@ gimp_image_convert_precision (GimpImage     *image,
 
   new_format = gimp_image_get_layer_format (image, FALSE);
 
-  if (old_profile &&
-      gimp_babl_format_get_linear (old_format) !=
-      gimp_babl_format_get_linear (new_format))
+  if (old_profile)
     {
-      GimpColorProfile *new_profile;
-
-      /* when converting between linear and gamma, we create a new
-       * profile using the original profile's chromacities and
-       * whitepoint, but a linear/sRGB-gamma TRC.
-       */
-
-      if (gimp_babl_format_get_linear (new_format))
-        {
-          new_profile =
-            gimp_color_profile_new_linear_from_color_profile (old_profile);
-        }
-      else
+      if (gimp_babl_format_get_linear (old_format) !=
+          gimp_babl_format_get_linear (new_format))
         {
-          new_profile =
-            gimp_color_profile_new_srgb_trc_from_color_profile (old_profile);
+          /* when converting between linear and gamma, we create a new
+           * profile using the original profile's chromacities and
+           * whitepoint, but a linear/sRGB-gamma TRC.
+           */
+
+          if (gimp_babl_format_get_linear (new_format))
+            {
+              new_profile =
+                gimp_color_profile_new_linear_from_color_profile (old_profile);
+            }
+          else
+            {
+              new_profile =
+                gimp_color_profile_new_srgb_trc_from_color_profile (old_profile);
+            }
+
+          /* if a new profile cannot be be generated, convert to the
+           * builtin profile, which is better than leaving the user with
+           * broken colors
+           */
+          if (! new_profile)
+            {
+              new_profile = gimp_image_get_builtin_color_profile (image);
+              g_object_ref (new_profile);
+            }
         }
 
-      /* if a new profile cannot be be generated, convert to the
-       * builtin profile, which is better than leaving the user with
-       * broken colors
-       */
       if (! new_profile)
-        {
-          new_profile = gimp_image_get_builtin_color_profile (image);
-          g_object_ref (new_profile);
-        }
+        new_profile = g_object_ref (old_profile);
     }
 
   for (list = all_drawables, nth_drawable = 0;
@@ -195,9 +198,11 @@ gimp_image_convert_precision (GimpImage     *image,
 
   g_list_free (all_drawables);
 
-  if (old_profile)
+  if (new_profile)
     {
-      gimp_image_set_color_profile (image, new_profile, NULL);
+      if (new_profile != old_profile)
+        gimp_image_set_color_profile (image, new_profile, NULL);
+
       g_object_unref (new_profile);
     }
 


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