mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
checkin
This commit is contained in:
@@ -41,7 +41,7 @@ use crate::{qrcode::decoder::{Version, ErrorCorrectionLevel}, Exceptions};
|
||||
let version = version.unwrap();
|
||||
assert_eq!(number, version.getVersionNumber());
|
||||
// assertNotNull(version.getAlignmentPatternCenters());
|
||||
if (number > 1) {
|
||||
if number > 1 {
|
||||
assert!(version.getAlignmentPatternCenters().len() > 0);
|
||||
}
|
||||
assert_eq!(dimension, version.getDimensionForVersion());
|
||||
@@ -49,7 +49,7 @@ use crate::{qrcode::decoder::{Version, ErrorCorrectionLevel}, Exceptions};
|
||||
let _tmp = version.getECBlocksForLevel(ErrorCorrectionLevel::L);
|
||||
let _tmp = version.getECBlocksForLevel(ErrorCorrectionLevel::M);
|
||||
let _tmp = version.getECBlocksForLevel(ErrorCorrectionLevel::Q);
|
||||
let _tmp = version.buildFunctionPattern();
|
||||
assert!(version.buildFunctionPattern().is_ok());
|
||||
|
||||
// assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel::H));
|
||||
// assertNotNull(version.getECBlocksForLevel(ErrorCorrectionLevel::L));
|
||||
|
||||
@@ -155,16 +155,16 @@ impl Version {
|
||||
/**
|
||||
* See ISO 18004:2006 Annex E
|
||||
*/
|
||||
pub fn buildFunctionPattern(&self) -> BitMatrix {
|
||||
pub fn buildFunctionPattern(&self) -> Result<BitMatrix,Exceptions> {
|
||||
let dimension = self.getDimensionForVersion();
|
||||
let mut bitMatrix = BitMatrix::with_single_dimension(dimension);
|
||||
|
||||
// Top left finder pattern + separator + format
|
||||
bitMatrix.setRegion(0, 0, 9, 9);
|
||||
bitMatrix.setRegion(0, 0, 9, 9)?;
|
||||
// Top right finder pattern + separator + format
|
||||
bitMatrix.setRegion(dimension - 8, 0, 8, 9);
|
||||
bitMatrix.setRegion(dimension - 8, 0, 8, 9)?;
|
||||
// Bottom left finder pattern + separator + format
|
||||
bitMatrix.setRegion(0, dimension - 8, 9, 8);
|
||||
bitMatrix.setRegion(0, dimension - 8, 9, 8)?;
|
||||
|
||||
// Alignment patterns
|
||||
let max = self.alignmentPatternCenters.len();
|
||||
@@ -174,25 +174,25 @@ impl Version {
|
||||
for y in 0..max {
|
||||
// for (int y = 0; y < max; y++) {
|
||||
if (x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0) {
|
||||
bitMatrix.setRegion(self.alignmentPatternCenters[y] - 2, i, 5, 5);
|
||||
bitMatrix.setRegion(self.alignmentPatternCenters[y] - 2, i, 5, 5)?;
|
||||
}
|
||||
// else no o alignment patterns near the three finder patterns
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical timing pattern
|
||||
bitMatrix.setRegion(6, 9, 1, dimension - 17);
|
||||
bitMatrix.setRegion(6, 9, 1, dimension - 17)?;
|
||||
// Horizontal timing pattern
|
||||
bitMatrix.setRegion(9, 6, dimension - 17, 1);
|
||||
bitMatrix.setRegion(9, 6, dimension - 17, 1)?;
|
||||
|
||||
if self.versionNumber > 6 {
|
||||
// Version info, top right
|
||||
bitMatrix.setRegion(dimension - 11, 0, 3, 6);
|
||||
bitMatrix.setRegion(dimension - 11, 0, 3, 6)?;
|
||||
// Version info, bottom left
|
||||
bitMatrix.setRegion(0, dimension - 11, 6, 3);
|
||||
bitMatrix.setRegion(0, dimension - 11, 6, 3)?;
|
||||
}
|
||||
|
||||
bitMatrix
|
||||
Ok(bitMatrix)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -403,7 +403,7 @@ fn testGS1ModeHeaderWithECI() {
|
||||
#[test]
|
||||
fn testAppendModeInfo() {
|
||||
let mut bits = BitArray::new();
|
||||
encoder::appendModeInfo(Mode::NUMERIC, &mut bits);
|
||||
assert!(encoder::appendModeInfo(Mode::NUMERIC, &mut bits).is_ok());
|
||||
assert_eq!(" ...X", bits.to_string());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user