[gimp] Issue #1554 - Select by Color tool does not select pixel(s) or area(s) of pixel(s)
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #1554 - Select by Color tool does not select pixel(s) or area(s) of pixel(s)
- Date: Thu, 28 Feb 2019 14:28:21 +0000 (UTC)
commit a6c79770c31cf8ec082904e570ec309315130812
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.
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 73dab9bac2..c2fc9915f9 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]