From 0836d3f582ad456a31b7a78ab49771475905da76 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Sat, 14 Jan 2023 12:01:30 -0600 Subject: [PATCH] small cleanup --- src/common/default_grid_sampler.rs | 12 ++++++------ src/datamatrix/detector/datamatrix_detector.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/default_grid_sampler.rs b/src/common/default_grid_sampler.rs index 9e8335a..4c89443 100644 --- a/src/common/default_grid_sampler.rs +++ b/src/common/default_grid_sampler.rs @@ -70,15 +70,15 @@ impl GridSampler for DefaultGridSampler { return Err(Exceptions::NotFoundException(None)); } let mut bits = BitMatrix::new(dimensionX, dimensionY)?; - let mut points = vec![0_f32; 2 * dimensionX as usize]; + let mut points = vec![0.0; 2 * dimensionX as usize]; for y in 0..dimensionY { // for (int y = 0; y < dimensionY; y++) { let max = points.len(); - let i_value = y as f32 + 0.5f32; + let i_value = y as f32 + 0.5; let mut x = 0; while x < max { // for (int x = 0; x < max; x += 2) { - points[x] = (x as f32 / 2.0) + 0.5f32; + points[x] = (x as f32 / 2.0) + 0.5; points[x + 1] = i_value; x += 2; } @@ -90,14 +90,14 @@ impl GridSampler for DefaultGridSampler { let mut x = 0; while x < max { // for (int x = 0; x < max; x += 2) { - if points[x].floor() as u32 >= image.getWidth() - || points[x + 1].floor() as u32 >= image.getHeight() + if points[x] as u32 >= image.getWidth() + || points[x + 1] as u32 >= image.getHeight() { return Err(Exceptions::NotFoundException(Some( "index out of bounds, see documentation in file for explanation".to_owned(), ))); } - if image.get(points[x].floor() as u32, points[x + 1].floor() as u32) { + if image.get(points[x] as u32, points[x + 1] as u32) { // Black(-ish) pixel bits.set(x as u32 / 2, y); } diff --git a/src/datamatrix/detector/datamatrix_detector.rs b/src/datamatrix/detector/datamatrix_detector.rs index 251e294..6db2c97 100644 --- a/src/datamatrix/detector/datamatrix_detector.rs +++ b/src/datamatrix/detector/datamatrix_detector.rs @@ -332,7 +332,7 @@ impl<'a> Detector<'_> { dimensionX: u32, dimensionY: u32, ) -> Result { - let sampler = DefaultGridSampler {}; + let sampler = DefaultGridSampler::default(); sampler.sample_grid_detailed( image,