From 36327480d841d1021722b9df9ef5572256e61e2a Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Sun, 15 Jan 2023 15:53:09 -0600 Subject: [PATCH] prepare for v0.2.18 (wasm) --- Cargo.toml | 3 ++- src/aztec/aztec_reader.rs | 7 ++----- src/datamatrix/decoder/bit_matrix_parser.rs | 9 +++++++++ src/qrcode/detector/qrcode_detector.rs | 2 +- src/rxing_result.rs | 11 ++--------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 07d0ce8..57c6df5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rxing" -version = "0.2.17" +version = "0.2.18" description="A rust port of the zxing barcode library." license="Apache-2.0" repository="https://github.com/hschimke/rxing" @@ -42,3 +42,4 @@ image = ["dep:image", "dep:imageproc"] allow_forced_iso_ied_18004_compliance = [] svg_write = ["dep:svg"] svg_read = ["dep:resvg", "image"] +wasm_support = ["chrono/wasmbind"] diff --git a/src/aztec/aztec_reader.rs b/src/aztec/aztec_reader.rs index 3c36460..cfa8986 100644 --- a/src/aztec/aztec_reader.rs +++ b/src/aztec/aztec_reader.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use std::{collections::HashMap, time::UNIX_EPOCH}; +use std::collections::HashMap; use crate::{ common::{DecoderRXingResult, DetectorRXingResult}, @@ -103,10 +103,7 @@ impl Reader for AztecReader { decoderRXingResult.getNumBits(), points.to_vec(), BarcodeFormat::AZTEC, - std::time::SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("Time went backwards") - .as_millis(), + chrono::Utc::now().timestamp_millis() as u128, ); let byteSegments = decoderRXingResult.getByteSegments(); diff --git a/src/datamatrix/decoder/bit_matrix_parser.rs b/src/datamatrix/decoder/bit_matrix_parser.rs index 278a04f..9bbaf5f 100644 --- a/src/datamatrix/decoder/bit_matrix_parser.rs +++ b/src/datamatrix/decoder/bit_matrix_parser.rs @@ -451,6 +451,7 @@ impl BitMatrixParser { bitMatrix: &BitMatrix, version: VersionRef, ) -> Result { + // dbg!(bitMatrix.to_string()); let symbolSizeRows = version.getSymbolSizeRows(); let symbolSizeColumns = version.getSymbolSizeColumns(); @@ -496,3 +497,11 @@ impl BitMatrixParser { Ok(bitMatrixWithoutAlignment) } } + +// const IS_MOSTLY_BLACK_RATIO : f32= 0.5; + +// fn is_mostly_black(array: &[bool]) -> bool { +// let array_len = array.len() as f32; +// let true_count = array.iter().fold(0, |acc,b| acc + i32::from(*b)) as f32; +// (array_len / true_count ) > IS_MOSTLY_BLACK_RATIO +// } diff --git a/src/qrcode/detector/qrcode_detector.rs b/src/qrcode/detector/qrcode_detector.rs index a3dda4e..1f1c36e 100644 --- a/src/qrcode/detector/qrcode_detector.rs +++ b/src/qrcode/detector/qrcode_detector.rs @@ -237,7 +237,7 @@ impl<'a> Detector<'_> { transform: &PerspectiveTransform, dimension: u32, ) -> Result { - let sampler = DefaultGridSampler {}; + let sampler = DefaultGridSampler::default(); sampler.sample_grid(image, dimension, dimension, transform) } diff --git a/src/rxing_result.rs b/src/rxing_result.rs index a6769e6..6225e78 100644 --- a/src/rxing_result.rs +++ b/src/rxing_result.rs @@ -19,11 +19,7 @@ //import java.util.EnumMap; //import java.util.Map; -use std::{ - collections::HashMap, - fmt, - time::{SystemTime, UNIX_EPOCH}, -}; +use std::{collections::HashMap, fmt}; use crate::{BarcodeFormat, RXingResultMetadataType, RXingResultMetadataValue, RXingResultPoint}; @@ -54,10 +50,7 @@ impl RXingResult { rawBytes, resultPoints, format, - SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("Time went backwards") - .as_millis(), + chrono::Utc::now().timestamp_millis() as u128, ) }