[gimp/gimp-2-10] Issue #3041: Color Picker no longer selects Colormap entry.



commit c91d37eff23418767ba9b1b2bdf5815a639f169c
Author: Jehan <jehan girinstud io>
Date:   Thu Mar 7 18:43:05 2019 +0100

    Issue #3041: Color Picker no longer selects Colormap entry.
    
    Do not take "Sample merge" into account when picking colors in a
    single-layer image. The reason is to be able to get the index
    information on indexed image. This information is lost otherwise when
    using the whole image as a pickable.
    
    Of course, other exceptions are possible, when you'd pick exactly a
    colormap color, but I don't think it's worth making the code
    extra-complicated for these. My previous commit will anyway already
    select the right color in the colormap on common cases. Though it will
    still fail to select the right index when several indexes store the same
    color, on a multi-layer image, if you check "Sample merged" while the
    right index was not the first one amongst the duplicates.
    
    (cherry picked from commit 31b2b55b28f6dbca66dcf3421c4eae69cfdc2ed8)

 app/core/gimpimage-pick-color.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/app/core/gimpimage-pick-color.c b/app/core/gimpimage-pick-color.c
index c51fdb6022..3154712f1b 100644
--- a/app/core/gimpimage-pick-color.c
+++ b/app/core/gimpimage-pick-color.c
@@ -22,9 +22,11 @@
 
 #include "core-types.h"
 
+#include "gimpchannel.h"
 #include "gimpdrawable.h"
 #include "gimpimage.h"
 #include "gimpimage-pick-color.h"
+#include "gimplayer.h"
 #include "gimppickable.h"
 
 
@@ -48,6 +50,25 @@ gimp_image_pick_color (GimpImage     *image,
                         gimp_item_get_image (GIMP_ITEM (drawable)) == image,
                         FALSE);
 
+  if (sample_merged && drawable)
+    {
+      if ((GIMP_IS_LAYER (drawable) &&
+           gimp_image_get_n_layers (image) == 1) ||
+          (GIMP_IS_CHANNEL (drawable) &&
+           gimp_image_get_n_channels (image) == 1))
+        {
+          /* Let's add a special exception when an image has only one
+           * layer. This was useful in particular for indexed image as
+           * it allows to pick the right index value even when "Sample
+           * merged" is checked. There are more possible exceptions, but
+           * we can't just take them all in considerations unless we
+           * want to make code extra-complicated).
+           * See #3041.
+           */
+          sample_merged = FALSE;
+        }
+    }
+
   if (! sample_merged)
     {
       if (! drawable)


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