diff --git a/src/qrcode/detector/detector.rs b/src/qrcode/detector/detector.rs index a711b3e..99f5882 100644 --- a/src/qrcode/detector/detector.rs +++ b/src/qrcode/detector/detector.rs @@ -344,7 +344,7 @@ impl Detector { scale = (self.image.getWidth() as i32 - 1 - fromX as i32) as f32 / (otherToX - fromX as i32) as f32; otherToX = self.image.getWidth() as i32 - 1; } - let mut otherToY = fromY as i32 - (toY as i32 - fromY as i32) * scale.floor() as i32; + let mut otherToY = (fromY as f32 - (toY as f32 - fromY as f32) * scale).floor() as i32; scale = 1.0; if otherToY < 0 { @@ -354,7 +354,7 @@ impl Detector { scale = (self.image.getHeight() as i32 - 1 - fromY as i32) as f32 / (otherToY - fromY as i32) as f32; otherToY = self.image.getHeight() as i32 - 1; } - otherToX = fromX as i32+ (otherToX - fromX as i32) * scale.floor() as i32; + otherToX = (fromX as f32+ (otherToX as f32 - fromX as f32) * scale).floor() as i32; result += self.sizeOfBlackWhiteBlackRun(fromX as u32, fromY as u32, otherToX as u32, otherToY as u32); diff --git a/src/qrcode/detector/finder_pattern_finder.rs b/src/qrcode/detector/finder_pattern_finder.rs index 0f9fc5e..27509c3 100755 --- a/src/qrcode/detector/finder_pattern_finder.rs +++ b/src/qrcode/detector/finder_pattern_finder.rs @@ -622,7 +622,7 @@ impl FinderPatternFinder { // This is the case where you find top left last. self.hasSkipped = true; let fnp = firstConfirmedCenter.unwrap(); - return (((fnp.getX() - center.getX().abs()) + return (((fnp.getX() - center.getX()).abs() - (fnp.getY() - center.getY()).abs()) / 2.0) .floor() as u32; diff --git a/tests/QRCodeBlackBox3TestCase.rs b/tests/QRCodeBlackBox3TestCase.rs index ddf9d9e..7406fb1 100644 --- a/tests/QRCodeBlackBox3TestCase.rs +++ b/tests/QRCodeBlackBox3TestCase.rs @@ -33,3 +33,5 @@ fn QRCodeBlackBox3TestCase() { tester.testBlackBox(); } +// 11 - 90 +// 13 - 90