datamatrix integration passes

This commit is contained in:
Henry Schimke
2022-11-28 11:51:26 -06:00
parent ba02512695
commit 75e69bc498
14 changed files with 131 additions and 150 deletions

View File

@@ -83,10 +83,10 @@ impl BitMatrixParser {
let mut resultOffset = 0;
let mut row = 4;
let mut column = 0_usize;
let mut column = 0;
let numRows = self.mappingBitMatrix.getHeight() as usize;
let numColumns = self.mappingBitMatrix.getWidth() as usize;
let numRows = self.mappingBitMatrix.getHeight().try_into().unwrap();
let numColumns = self.mappingBitMatrix.getWidth().try_into().unwrap();
let mut corner1Read = false;
let mut corner2Read = false;
@@ -193,7 +193,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return value of the given bit in the mapping matrix
*/
fn readModule(&mut self, row: usize, column: usize, numRows: usize, numColumns: usize) -> bool {
fn readModule(&mut self, row: isize, column: isize, numRows: isize, numColumns: isize) -> bool {
let mut row = row;
let mut column = column;
// Adjust the row and column indices based on boundary wrapping
@@ -224,7 +224,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return byte from the utah shape
*/
fn readUtah(&mut self, row: usize, column: usize, numRows: usize, numColumns: usize) -> u32 {
fn readUtah(&mut self, row: isize, column: isize, numRows: isize, numColumns: isize) -> u32 {
let mut currentByte = 0;
if self.readModule(row - 2, column - 2, numRows, numColumns) {
currentByte |= 1;
@@ -269,7 +269,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 1
*/
fn readCorner1(&mut self, numRows: usize, numColumns: usize) -> u32 {
fn readCorner1(&mut self, numRows: isize, numColumns: isize) -> u32 {
let mut currentByte = 0;
if self.readModule(numRows - 1, 0, numRows, numColumns) {
currentByte |= 1;
@@ -314,7 +314,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 2
*/
fn readCorner2(&mut self, numRows: usize, numColumns: usize) -> u32 {
fn readCorner2(&mut self, numRows: isize, numColumns: isize) -> u32 {
let mut currentByte = 0;
if self.readModule(numRows - 3, 0, numRows, numColumns) {
currentByte |= 1;
@@ -359,7 +359,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 3
*/
fn readCorner3(&mut self, numRows: usize, numColumns: usize) -> u32 {
fn readCorner3(&mut self, numRows: isize, numColumns: isize) -> u32 {
let mut currentByte = 0;
if self.readModule(numRows - 1, 0, numRows, numColumns) {
currentByte |= 1;
@@ -404,7 +404,7 @@ impl BitMatrixParser {
* @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 4
*/
fn readCorner4(&mut self, numRows: usize, numColumns: usize) -> u32 {
fn readCorner4(&mut self, numRows: isize, numColumns: isize) -> u32 {
let mut currentByte = 0;
if self.readModule(numRows - 3, 0, numRows, numColumns) {
currentByte |= 1;

View File

@@ -64,7 +64,7 @@ impl DataBlock {
// Now establish DataBlocks of the appropriate size and number of data codewords
let mut result = Vec::with_capacity(totalBlocks);
let numRXingResultBlocks = 0;
let mut numRXingResultBlocks = 0;
for ecBlock in ecBlockArray {
for _i in 0..ecBlock.getCount() {
// for (int i = 0; i < ecBlock.getCount(); i++) {
@@ -75,6 +75,7 @@ impl DataBlock {
numDataCodewords as u32,
vec![0; numBlockCodewords],
));
numRXingResultBlocks +=1;
}
}

View File

@@ -693,12 +693,12 @@ fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Resu
*/
fn unrandomize255State(randomizedBase256Codeword: u32, base256CodewordPosition: usize) -> u32 {
let pseudoRandomNumber = ((149 * base256CodewordPosition as u32) % 255) + 1;
let tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
let tempVariable = randomizedBase256Codeword as i32 - pseudoRandomNumber as i32;
if tempVariable >= 0 {
tempVariable
tempVariable as u32
} else {
tempVariable + 256
(tempVariable + 256) as u32
}
}