mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
fixed issue with ec results not being used
This commit is contained in:
@@ -197,8 +197,11 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<()
|
||||
// for (int i = 0; i < numCodewords; i++) {
|
||||
codewordsInts[i] = codewordBytes[i]; // & 0xFF;
|
||||
}
|
||||
|
||||
let mut sending_code_words : Vec<i32> = codewordsInts.iter().map(|x| *x as i32).collect();
|
||||
|
||||
if let Err(e) = rsDecoder.decode(
|
||||
&mut codewordsInts.iter().map(|x| *x as i32).collect(),
|
||||
&mut sending_code_words,
|
||||
(codewordBytes.len() - numDataCodewords) as i32,
|
||||
) {
|
||||
if let Exceptions::ReedSolomonException(error_str) = e {
|
||||
@@ -210,7 +213,7 @@ fn correctErrors(codewordBytes: &mut [u8], numDataCodewords: usize) -> Result<()
|
||||
// We don't care about errors in the error-correction codewords
|
||||
for i in 0..numDataCodewords {
|
||||
// for (int i = 0; i < numDataCodewords; i++) {
|
||||
codewordBytes[i] = codewordsInts[i];
|
||||
codewordBytes[i] = sending_code_words[i] as u8;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ impl AlignmentPatternFinder {
|
||||
let centerJ = Self::centerFromEnd(stateCount, j);
|
||||
let centerI = self.crossCheckVertical(
|
||||
i,
|
||||
centerJ.floor() as u32,
|
||||
centerJ.round() as u32,
|
||||
2 * stateCount[1],
|
||||
stateCountTotal,
|
||||
);
|
||||
|
||||
@@ -462,13 +462,13 @@ impl Detector {
|
||||
// Look for an alignment pattern (3 modules in size) around where it
|
||||
// should be
|
||||
let allowance = (allowanceFactor * overallEstModuleSize) as u32;
|
||||
let alignmentAreaLeftX = 0.max(estAlignmentX - allowance);
|
||||
let alignmentAreaLeftX = 0.max(estAlignmentX as i32- allowance as i32) as u32;
|
||||
let alignmentAreaRightX = (self.image.getWidth() - 1).min(estAlignmentX + allowance);
|
||||
if ((alignmentAreaRightX - alignmentAreaLeftX) as f32) < overallEstModuleSize * 3.0 {
|
||||
return Err(Exceptions::NotFoundException("not found".to_owned()));
|
||||
}
|
||||
|
||||
let alignmentAreaTopY = 0.max(estAlignmentY - allowance);
|
||||
let alignmentAreaTopY = 0.max(estAlignmentY as i32 - allowance as i32) as u32;
|
||||
let alignmentAreaBottomY = (self.image.getHeight() - 1).min(estAlignmentY + allowance);
|
||||
if alignmentAreaBottomY - alignmentAreaTopY < overallEstModuleSize as u32 * 3 {
|
||||
return Err(Exceptions::NotFoundException("not found".to_owned()));
|
||||
|
||||
@@ -92,7 +92,7 @@ impl FinderPattern {
|
||||
combinedX,
|
||||
combinedY,
|
||||
combinedModuleSize,
|
||||
combinedCount.floor() as usize,
|
||||
combinedCount.round() as usize,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ impl FinderPatternFinder {
|
||||
// Skip by rowSkip, but back off by stateCount[2] (size of last center
|
||||
// of pattern we saw) to be conservative, and also back off by iSkip which
|
||||
// is about to be re-added
|
||||
i += rowSkip - stateCount[2] - iSkip;
|
||||
i += (rowSkip as i32 - stateCount[2] as i32 - iSkip as i32).max(0) as u32;
|
||||
j = maxJ - 1;
|
||||
}
|
||||
}
|
||||
@@ -620,7 +620,7 @@ impl FinderPatternFinder {
|
||||
return (((fnp.getX() - center.getX().abs())
|
||||
- (fnp.getY() - center.getY()).abs())
|
||||
/ 2.0)
|
||||
.floor() as u32;
|
||||
.round() as u32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user