From 81f6de2a8f8452bc4bac3af63c7a3b939f9beaa2 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Tue, 11 Oct 2022 07:38:50 -0500 Subject: [PATCH] we really should be using round, but why is it worse? --- src/common/mod.rs | 2 +- src/qrcode/detector/alignment_pattern_finder.rs | 2 +- src/qrcode/detector/finder_pattern.rs | 2 +- src/qrcode/detector/finder_pattern_finder.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/mod.rs b/src/common/mod.rs index 25a94c3..eca541a 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -2363,7 +2363,7 @@ impl GridSampler for DefaultGridSampler { let mut x = 0; while x < max { // for (int x = 0; x < max; x += 2) { - if image.get(points[x].floor() as u32, points[x + 1].floor() as u32) { + if image.get(points[x].round() as u32, points[x + 1].round() as u32) { // Black(-ish) pixel bits.set(x as u32 / 2, y); } diff --git a/src/qrcode/detector/alignment_pattern_finder.rs b/src/qrcode/detector/alignment_pattern_finder.rs index ddb0517..2038007 100644 --- a/src/qrcode/detector/alignment_pattern_finder.rs +++ b/src/qrcode/detector/alignment_pattern_finder.rs @@ -290,7 +290,7 @@ impl AlignmentPatternFinder { let centerJ = Self::centerFromEnd(stateCount, j); let centerI = self.crossCheckVertical( i, - centerJ.floor() as u32, + centerJ.round() as u32, 2 * stateCount[1], stateCountTotal, ); diff --git a/src/qrcode/detector/finder_pattern.rs b/src/qrcode/detector/finder_pattern.rs index a79c2ad..487eed9 100644 --- a/src/qrcode/detector/finder_pattern.rs +++ b/src/qrcode/detector/finder_pattern.rs @@ -92,7 +92,7 @@ impl FinderPattern { combinedX, combinedY, combinedModuleSize, - combinedCount.floor() as usize, + combinedCount.round() as usize, ) } } diff --git a/src/qrcode/detector/finder_pattern_finder.rs b/src/qrcode/detector/finder_pattern_finder.rs index 00261a1..7d4d4d0 100755 --- a/src/qrcode/detector/finder_pattern_finder.rs +++ b/src/qrcode/detector/finder_pattern_finder.rs @@ -620,7 +620,7 @@ impl FinderPatternFinder { return (((fnp.getX() - center.getX().abs()) - (fnp.getY() - center.getY()).abs()) / 2.0) - .floor() as u32; + .round() as u32; } } }