[gimp/gimp-2-10] Issue #1554 - Select by Color tool does not select pixel(s) or area(s) of pixel(s)



commit 3f43c2ea12de4ef89bd2d4e1ad556a278bc9d7fb
Author: Ell <ell_se yahoo com>
Date:   Thu Feb 28 09:19:55 2019 -0500

    Issue #1554 - Select by Color tool does not select pixel(s) or area(s) of pixel(s)
    
    In gimp_pickable_contiguous_region_by_color(), add a small epsilon
    to the threshold value, to allow for small errors due to the input
    color and pickable pixel-colors being converted to the common
    format through different paths.
    
    While we *could* special-case threshold == 0 when the input color
    comes from the same pickable, as is the case for the select-by-
    color tool, and perform an exact comparison in the original format,
    in the more general case the input color can come from an arbitrary
    source, such as a plug-in.
    
    (cherry picked from commit a6c79770c31cf8ec082904e570ec309315130812)

 app/core/gimppickable-contiguous-region.cc | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/app/core/gimppickable-contiguous-region.cc b/app/core/gimppickable-contiguous-region.cc
index a2daf30566..15217ae215 100644
--- a/app/core/gimppickable-contiguous-region.cc
+++ b/app/core/gimppickable-contiguous-region.cc
@@ -41,6 +41,8 @@ extern "C"
 #include "gimppickable-contiguous-region.h"
 
 
+#define EPSILON 1e-6
+
 #define PIXELS_PER_THREAD \
   (/* each thread costs as much as */ 64.0 * 64.0 /* pixels */)
 
@@ -209,6 +211,14 @@ gimp_pickable_contiguous_region_by_color (GimpPickable        *pickable,
   g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
   g_return_val_if_fail (color != NULL, NULL);
 
+  /* increase the threshold by EPSILON, to allow for conversion errors,
+   * especially when threshold == 0 (see issue #1554.)  we need to do this
+   * here, but not in the other functions, since the input color gets converted
+   * to the format in which we perform the comparison through a different path
+   * than the pickable's pixels, which can introduce error.
+   */
+  threshold += EPSILON;
+
   gimp_pickable_flush (pickable);
 
   src_buffer = gimp_pickable_get_buffer (pickable);


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