fix missing result point callback

This commit is contained in:
Henry Schimke
2023-01-06 10:45:40 -06:00
parent 0185e80090
commit 7996f42c64
5 changed files with 21 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "rxing" name = "rxing"
version = "0.2.5" version = "0.2.6"
description="A rust port of the zxing barcode library." description="A rust port of the zxing barcode library."
license="Apache-2.0" license="Apache-2.0"
repository="https://github.com/hschimke/rxing" repository="https://github.com/hschimke/rxing"

View File

@@ -48,6 +48,8 @@ fn main() {
``` ```
## Latest Release Notes ## Latest Release Notes
v0.2.6 -> Fix missing result point callback for rss14
v0.2.4 -> Add helper functions for common cases (read a file, use raw luma8 data). v0.2.4 -> Add helper functions for common cases (read a file, use raw luma8 data).
v0.2.3 -> Implement most suggestions from clippy, as well as some simple changes, no surface changes. v0.2.3 -> Implement most suggestions from clippy, as well as some simple changes, no surface changes.

View File

@@ -23,6 +23,7 @@
* *
* @author Sean Owen * @author Sean Owen
*/ */
pub struct EANManufacturerOrgSupport { pub struct EANManufacturerOrgSupport {
ranges: Vec<Vec<u32>>, //= new ArrayList<>(); ranges: Vec<Vec<u32>>, //= new ArrayList<>();
countryIdentifiers: Vec<String>, // = new ArrayList<>(); countryIdentifiers: Vec<String>, // = new ArrayList<>();
@@ -40,13 +41,14 @@ impl Default for EANManufacturerOrgSupport {
} }
impl EANManufacturerOrgSupport { impl EANManufacturerOrgSupport {
pub fn lookupCountryIdentifier(&self, productCode: &str) -> Option<String> { pub fn lookupCountryIdentifier(&self, productCode: &str) -> Option<&str> {
let prefix = productCode[0..3].parse::<u32>().expect("must parse prefix"); let prefix = productCode[0..3].parse::<u32>().expect("must parse prefix");
// let prefix = Integer.parseInt(productCode.substring(0, 3)); // let prefix = Integer.parseInt(productCode.substring(0, 3));
let max = self.ranges.len(); let max = self.ranges.len();
for i in 0..max { for (i, range) in self.ranges.iter().enumerate().take(max) {
// for i in 0..max {
// for (int i = 0; i < max; i++) { // for (int i = 0; i < max; i++) {
let range = self.ranges.get(i).expect("must have index i or fail"); // let range = self.ranges.get(i).expect("must have index i or fail");
let start = range[0]; let start = range[0];
if prefix < start { if prefix < start {
return None; return None;
@@ -57,7 +59,7 @@ impl EANManufacturerOrgSupport {
self.countryIdentifiers self.countryIdentifiers
.get(i) .get(i)
.expect("must have index i or fail") .expect("must have index i or fail")
.clone(), // .clone(),
); );
} }
} }

View File

@@ -20,7 +20,7 @@ use crate::{
common::BitArray, common::BitArray,
oned::{one_d_reader, OneDReader}, oned::{one_d_reader, OneDReader},
BarcodeFormat, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResult, BarcodeFormat, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResult,
RXingResultMetadataType, RXingResultMetadataValue, Reader, RXingResultMetadataType, RXingResultMetadataValue, Reader, DecodeHintValue, RXingResultPoint,
}; };
use super::{ use super::{
@@ -257,24 +257,21 @@ impl RSS14Reader {
row: &BitArray, row: &BitArray,
right: bool, right: bool,
rowNumber: u32, rowNumber: u32,
_hints: &DecodingHintDictionary, hints: &DecodingHintDictionary,
) -> Option<Pair> { ) -> Option<Pair> {
let pos_pair = || -> Result<Pair, Exceptions> { let pos_pair = || -> Result<Pair, Exceptions> {
let startEnd = self.findFinderPattern(row, right)?; let startEnd = self.findFinderPattern(row, right)?;
let pattern = self.parseFoundFinderPattern(row, rowNumber, right, &startEnd)?; let pattern = self.parseFoundFinderPattern(row, rowNumber, right, &startEnd)?;
// RXingResultPointCallback resultPointCallback = hints == null ? null : if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK) {
// (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); let startEnd = pattern.getStartEnd();
let mut center :f32 = (startEnd[0] + startEnd[1] - 1) as f32 / 2.0;
// if (resultPointCallback != null) { if right {
// startEnd = pattern.getStartEnd(); // row is actually reversed
// float center = (startEnd[0] + startEnd[1] - 1) / 2.0f; center = row.getSize() as f32 - 1.0 - center;
// if (right) { }
// // row is actually reversed cb( &RXingResultPoint::new(center, rowNumber as f32));
// center = row.getSize() - 1 - center; }
// }
// resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(center, rowNumber));
// }
let outside = self.decodeDataCharacter(row, &pattern, true)?; let outside = self.decodeDataCharacter(row, &pattern, true)?;
let inside = self.decodeDataCharacter(row, &pattern, false)?; let inside = self.decodeDataCharacter(row, &pattern, false)?;

View File

@@ -294,7 +294,7 @@ pub trait UPCEANReader: OneDReader {
if let Some(cid) = countryID { if let Some(cid) = countryID {
decodeRXingResult.putMetadata( decodeRXingResult.putMetadata(
RXingResultMetadataType::POSSIBLE_COUNTRY, RXingResultMetadataType::POSSIBLE_COUNTRY,
RXingResultMetadataValue::PossibleCountry(cid), RXingResultMetadataValue::PossibleCountry(cid.to_owned()),
); );
} }
} }