add missing to_string methods in pdf417

This commit is contained in:
Henry Schimke
2022-12-31 11:56:14 -06:00
parent da39b9fce4
commit f59507ce2a
5 changed files with 61 additions and 45 deletions

View File

@@ -9,7 +9,7 @@ exclude = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
regex = "1.6" regex = "1.7.0"
fancy-regex = "0.10" fancy-regex = "0.10"
lazy_static = "1.4.0" lazy_static = "1.4.0"
encoding = "0.2" encoding = "0.2"
@@ -18,7 +18,7 @@ urlencoding = "2.1.2"
uriparse = "0.6.4" uriparse = "0.6.4"
chrono = "0.4" chrono = "0.4"
chrono-tz = "0.4" chrono-tz = "0.4"
image = {version = "0.24.3", optional = true} image = {version = "0.24.5", optional = true}
imageproc = {version = "0.23.0", optional = true} imageproc = {version = "0.23.0", optional = true}
unicode-segmentation = "1.10.0" unicode-segmentation = "1.10.0"
codepage-437 = "0.1.0" codepage-437 = "0.1.0"

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2020 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing;
import org.junit.Assert;
import org.junit.Test;
import java.awt.image.BufferedImage;
/**
* Tests {@link InvertedLuminanceSource}.
*/
public final class InvertedLuminanceSourceTestCase extends Assert {
@Test
public void testInverted() {
BufferedImage image = new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB);
image.setRGB(0, 0, 0xFFFFFF);
LuminanceSource source = new BufferedImageLuminanceSource(image);
assertArrayEquals(new byte[] { (byte) 0xFF, 0 }, source.getRow(0, null));
LuminanceSource inverted = new InvertedLuminanceSource(source);
assertArrayEquals(new byte[] { 0, (byte) 0xFF }, inverted.getRow(0, null));
}
}

View File

@@ -648,7 +648,45 @@ impl DetectionRXingResult {
impl Display for DetectionRXingResult { impl Display for DetectionRXingResult {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!() let mut rowIndicatorColumn = &self.detectionRXingResultColumns[0];
if rowIndicatorColumn.is_none() {
rowIndicatorColumn = &self.detectionRXingResultColumns[self.barcodeColumnCount + 1];
}
// try (Formatter formatter = new Formatter()) {
for codewordsRow in 0..rowIndicatorColumn.as_ref().unwrap().getCodewords().len() {
// for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {
write!(f, "CW {0:3}", codewordsRow)?;
// formatter.format("CW %3d:", codewordsRow);
for barcodeColumn in 0..self.barcodeColumnCount + 2 {
// for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) {
if self.detectionRXingResultColumns[barcodeColumn].is_none() {
write!(f, "{}", " | ")?;
// formatter.format(" | ");
continue;
}
let codeword = self.detectionRXingResultColumns[barcodeColumn]
.as_ref()
.unwrap()
.getCodewords()[codewordsRow];
if codeword.is_none() {
write!(f, "{}", " | ")?;
// formatter.format(" | ");
continue;
}
write!(
f,
" {}|{}",
codeword.as_ref().unwrap().getRowNumber(),
codeword.as_ref().unwrap().getValue()
)?;
// formatter.format(" %3d|%3d", codeword.getRowNumber(), codeword.getValue());
}
// formatter.format("%n");
write!(f, "{}", "\n")?;
}
// return formatter.toString();
write!(f, "")
// }
} }
} }

View File

@@ -127,9 +127,26 @@ impl DetectionRXingResultColumnTrait for DetectionRXingResultColumn {
impl Display for DetectionRXingResultColumn { impl Display for DetectionRXingResultColumn {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.isLeft.is_some() { if self.isLeft.is_some() {
write!(f, "IsLeft: {} \n", self.isLeft.as_ref().unwrap()); write!(f, "IsLeft: {} \n", self.isLeft.as_ref().unwrap())?;
} }
todo!() let mut row = 0;
for codeword in &self.codewords {
// for (Codeword codeword : codewords) {
if codeword.is_none() {
write!(f, "{:3}: | \n", row)?;
row += 1;
continue;
}
write!(
f,
"{:3}: {:3}|{:3}\n",
row,
codeword.as_ref().unwrap().getRowNumber(),
codeword.as_ref().unwrap().getValue()
)?;
row += 1;
}
write!(f, "")
} }
// @Override // @Override

View File

@@ -152,7 +152,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
log::fine(format!("Starting Image Group {}", name)); log::fine(format!("Starting Image Group {}", name));
let file_base_name = name; //testImageGroup.getKey(); let file_base_name = name; //testImageGroup.getKey();
// let expectedText : String; // let expectedText : String;
let mut expected_text_file = test_base.clone().to_path_buf(); let mut expected_text_file = test_base.clone().to_path_buf();
expected_text_file.push(file_base_name); expected_text_file.push(file_base_name);
expected_text_file.set_extension("txt"); expected_text_file.set_extension("txt");