all tests but 7 (SA) and inverted pass

This commit is contained in:
Henry Schimke
2023-04-28 13:25:49 -05:00
parent 6aee7a66b9
commit 4d703c4e51
8 changed files with 72 additions and 42 deletions

View File

@@ -70,7 +70,7 @@ pub fn DecodeHanziSegment(
// Each character will require 2 bytes, decode as GB2312
// There is no ECI value for GB2312, use GB18030 which is a superset
result.switch_encoding(CharacterSet::GB18030);
result.switch_encoding(CharacterSet::GB18030, false);
result.reserve(2 * count as usize);
while (count > 0) {
@@ -99,7 +99,7 @@ pub fn DecodeKanjiSegment(
let mut count = count;
// Each character will require 2 bytes. Read the characters as 2-byte pairs
// and decode as Shift_JIS afterwards
result.switch_encoding(CharacterSet::Shift_JIS);
result.switch_encoding(CharacterSet::Shift_JIS, false);
result.reserve(2 * count as usize);
while (count > 0) {
@@ -125,7 +125,7 @@ pub fn DecodeByteSegment(
count: u32,
result: &mut ECIStringBuilder,
) -> Result<()> {
result.switch_encoding(CharacterSet::Unknown);
result.switch_encoding(CharacterSet::Unknown, false);
result.reserve(count as usize);
for _i in 0..count {
@@ -205,7 +205,7 @@ pub fn DecodeAlphanumericSegment(
}
}
result.switch_encoding(CharacterSet::ISO8859_1);
result.switch_encoding(CharacterSet::ISO8859_1, false);
*result += buffer;
Ok(())
@@ -218,7 +218,7 @@ pub fn DecodeNumericSegment(
) -> Result<()> {
let mut count = count;
result.switch_encoding(CharacterSet::ISO8859_1);
result.switch_encoding(CharacterSet::ISO8859_1, false);
result.reserve(count as usize);
while (count > 0) {
@@ -351,7 +351,7 @@ pub fn DecodeBitStream(
}
Mode::ECI => {
// Count doesn't apply to ECI
result.switch_encoding(ParseECIValue(&mut bits)?.into());
result.switch_encoding(ParseECIValue(&mut bits)?.into(), true);
}
Mode::HANZI => {
// First handle Hanzi mode which does not start with character count

View File

@@ -430,7 +430,7 @@ pub fn LocateAlignmentPattern(
// #endif
let cor = CenterOfRing(
image,
estimate + moduleSize as f32 * 2.25 * d,
(estimate + moduleSize as f32 * 2.25 * d).floor(),
moduleSize * 3,
1,
false,
@@ -441,7 +441,7 @@ pub fn LocateAlignmentPattern(
continue;
}
if let Some(cor1) = CenterOfRing(image, cor.unwrap(), moduleSize, 1, true) {
if let Some(cor1) = CenterOfRing(image, cor.unwrap().floor(), moduleSize, 1, true) {
if let Some(cor2) = CenterOfRing(image, cor.unwrap().floor(), moduleSize * 3, -2, true)
{
if Point::distance(cor1, cor2) < moduleSize as f32 / 2.0 {

View File

@@ -207,16 +207,26 @@ impl Reader for QrReader {
let decoderResult = Decode(detectorResult.getBits())?;
let position = detectorResult.getPoints();
Ok(RXingResult::new(
&decoderResult.content().to_string(),
decoderResult.content().bytes().to_vec(),
position.to_vec(),
Ok(RXingResult::with_decoder_result(
decoderResult,
position,
if detectorResult.getBits().width() < 21 {
BarcodeFormat::MICRO_QR_CODE
} else {
BarcodeFormat::QR_CODE
},
))
// Ok(RXingResult::new(
// &decoderResult.content().to_string(),
// decoderResult.content().bytes().to_vec(),
// position.to_vec(),
// if detectorResult.getBits().width() < 21 {
// BarcodeFormat::MICRO_QR_CODE
// } else {
// BarcodeFormat::QR_CODE
// },
// ))
// return Result(std::move(decoderResult), std::move(position),
// detectorResult.bits().width() < 21 ? BarcodeFormat::MICRO_QR_CODE : BarcodeFormat::QR_CODE);
}
@@ -342,12 +352,17 @@ impl QrReader {
let position = detectorResult.getPoints();
if let Ok(decoderResult) = decoderResult {
if (decoderResult.isValid()) {
results.push(RXingResult::new(
&decoderResult.content().to_string(),
decoderResult.content().bytes().to_vec(),
position.to_vec(),
results.push(RXingResult::with_decoder_result(
decoderResult,
position,
BarcodeFormat::MICRO_QR_CODE,
));
// results.push(RXingResult::new(
// &decoderResult.content().to_string(),
// decoderResult.content().bytes().to_vec(),
// position.to_vec(),
// BarcodeFormat::MICRO_QR_CODE,
// ));
// results.emplace_back(std::move(decoderResult), std::move(position), BarcodeFormat::MICRO_QR_CODE);
if (maxSymbols != 0 && (results.len() as u32) == maxSymbols) {