mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fix missing result point callback
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rxing"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
description="A rust port of the zxing barcode library."
|
||||
license="Apache-2.0"
|
||||
repository="https://github.com/hschimke/rxing"
|
||||
|
||||
@@ -48,6 +48,8 @@ fn main() {
|
||||
```
|
||||
|
||||
## 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.3 -> Implement most suggestions from clippy, as well as some simple changes, no surface changes.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
|
||||
pub struct EANManufacturerOrgSupport {
|
||||
ranges: Vec<Vec<u32>>, //= new ArrayList<>();
|
||||
countryIdentifiers: Vec<String>, // = new ArrayList<>();
|
||||
@@ -40,13 +41,14 @@ impl Default for 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 = Integer.parseInt(productCode.substring(0, 3));
|
||||
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++) {
|
||||
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];
|
||||
if prefix < start {
|
||||
return None;
|
||||
@@ -57,7 +59,7 @@ impl EANManufacturerOrgSupport {
|
||||
self.countryIdentifiers
|
||||
.get(i)
|
||||
.expect("must have index i or fail")
|
||||
.clone(),
|
||||
// .clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::{
|
||||
common::BitArray,
|
||||
oned::{one_d_reader, OneDReader},
|
||||
BarcodeFormat, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResult,
|
||||
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||
RXingResultMetadataType, RXingResultMetadataValue, Reader, DecodeHintValue, RXingResultPoint,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -257,24 +257,21 @@ impl RSS14Reader {
|
||||
row: &BitArray,
|
||||
right: bool,
|
||||
rowNumber: u32,
|
||||
_hints: &DecodingHintDictionary,
|
||||
hints: &DecodingHintDictionary,
|
||||
) -> Option<Pair> {
|
||||
let pos_pair = || -> Result<Pair, Exceptions> {
|
||||
let startEnd = self.findFinderPattern(row, right)?;
|
||||
let pattern = self.parseFoundFinderPattern(row, rowNumber, right, &startEnd)?;
|
||||
|
||||
// RXingResultPointCallback resultPointCallback = hints == null ? null :
|
||||
// (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
|
||||
// if (resultPointCallback != null) {
|
||||
// startEnd = pattern.getStartEnd();
|
||||
// float center = (startEnd[0] + startEnd[1] - 1) / 2.0f;
|
||||
// if (right) {
|
||||
// // row is actually reversed
|
||||
// center = row.getSize() - 1 - center;
|
||||
// }
|
||||
// resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(center, rowNumber));
|
||||
// }
|
||||
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = 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 right {
|
||||
// row is actually reversed
|
||||
center = row.getSize() as f32 - 1.0 - center;
|
||||
}
|
||||
cb( &RXingResultPoint::new(center, rowNumber as f32));
|
||||
}
|
||||
|
||||
let outside = self.decodeDataCharacter(row, &pattern, true)?;
|
||||
let inside = self.decodeDataCharacter(row, &pattern, false)?;
|
||||
|
||||
@@ -294,7 +294,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
if let Some(cid) = countryID {
|
||||
decodeRXingResult.putMetadata(
|
||||
RXingResultMetadataType::POSSIBLE_COUNTRY,
|
||||
RXingResultMetadataValue::PossibleCountry(cid),
|
||||
RXingResultMetadataValue::PossibleCountry(cid.to_owned()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user