From 890fb4901ff4eb41ec0a686d29458206f25ffefb Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Tue, 21 Mar 2023 10:16:46 -0500 Subject: [PATCH] v0.4.3 --- Cargo.toml | 2 +- src/common/bit_matrix.rs | 5 +++++ src/maxicode/detector.rs | 7 ++----- tests/github_issues.rs | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 19ee34c..ba44b95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rxing" -version = "0.4.2" +version = "0.4.3" description="A rust port of the zxing barcode library." license="Apache-2.0" repository="https://github.com/rxing-core/rxing" diff --git a/src/common/bit_matrix.rs b/src/common/bit_matrix.rs index e22e357..dfaa60e 100644 --- a/src/common/bit_matrix.rs +++ b/src/common/bit_matrix.rs @@ -265,6 +265,11 @@ impl BitMatrix { (self.get_offset(y, x)) >= self.bits.len() } + /// Confusingly returns true if the requested element is out of bounds + pub fn check_point_in_bounds(&self, point: Point) -> bool { + self.check_in_bounds(point.x as u32, point.y as u32) + } + /** *

Sets the given bit to true.

* diff --git a/src/maxicode/detector.rs b/src/maxicode/detector.rs index f22c00f..8f6546a 100644 --- a/src/maxicode/detector.rs +++ b/src/maxicode/detector.rs @@ -281,9 +281,7 @@ impl Circle<'_> { // count left while { let point = get_point(self.center, (x, y), rotation); - !self.image.check_in_bounds(point.x as u32, point.y as u32) - && !self.image.get(point.x as u32, point.y as u32) - && x > 0 + !self.image.check_point_in_bounds(point) && !self.image.get_point(point) && x > 0 } { x -= 1; length += 1; @@ -295,8 +293,7 @@ impl Circle<'_> { // count right while { let point = get_point(self.center, (x, y), rotation); - !self.image.check_in_bounds(point.x as u32, point.y as u32) - && !self.image.get(point.x as u32, point.y as u32) + !self.image.check_point_in_bounds(point) && !self.image.get_point(point) } { x += 1; length += 1; diff --git a/tests/github_issues.rs b/tests/github_issues.rs index 75179c5..0a6db83 100644 --- a/tests/github_issues.rs +++ b/tests/github_issues.rs @@ -5,7 +5,7 @@ use rxing::DecodingHintDictionary; #[test] fn issue_27_part_2() { let mut data = Vec::new(); - std::fs::File::open("test_resources/blackbox/github_issue_cases/226611447-be6041dc-5b21-42fe-827b-068ccc59082c.png") + std::fs::File::open("test_resources/blackbox/github_issue_cases/panic_data2_issue_27.bin") .unwrap() .read_to_end(&mut data) .unwrap();