From 9b41224ebc8b2dbc60558aa9f0d2281be1a74935 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 30 Nov 2015 21:59:50 +1100 Subject: [PATCH] Fix floating point comparison. Former-commit-id: 07e46b47420a5f8d951fa42d67e8773d37e3ca6c Former-commit-id: 759ab68a95a18a31a5a53458a21a7b3cc24b5f40 Former-commit-id: ba4905924bac7bd9ac751eafc4c2322a96c88d05 --- src/ImageProcessor/Common/Helpers/ImageMaths.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ImageProcessor/Common/Helpers/ImageMaths.cs b/src/ImageProcessor/Common/Helpers/ImageMaths.cs index 04689c2ec..6722d1dc1 100644 --- a/src/ImageProcessor/Common/Helpers/ImageMaths.cs +++ b/src/ImageProcessor/Common/Helpers/ImageMaths.cs @@ -216,19 +216,19 @@ namespace ImageProcessor switch (channel) { case RgbaComponent.R: - delegateFunc = (imageBase, x, y, b) => imageBase[x, y].R != b; + delegateFunc = (imageBase, x, y, b) => Math.Abs(imageBase[x, y].R - b) > Epsilon; break; case RgbaComponent.G: - delegateFunc = (imageBase, x, y, b) => imageBase[x, y].G != b; + delegateFunc = (imageBase, x, y, b) => Math.Abs(imageBase[x, y].G - b) > Epsilon; break; case RgbaComponent.A: - delegateFunc = (imageBase, x, y, b) => imageBase[x, y].A != b; + delegateFunc = (imageBase, x, y, b) => Math.Abs(imageBase[x, y].A - b) > Epsilon; break; default: - delegateFunc = (imageBase, x, y, b) => imageBase[x, y].B != b; + delegateFunc = (imageBase, x, y, b) => Math.Abs(imageBase[x, y].B - b) > Epsilon; break; } @@ -240,8 +240,6 @@ namespace ImageProcessor { if (delegateFunc(imageBase, x, y, componentValue)) { - var c = imageBase[x, y]; - return y; } }