continued removal of todo!()

This commit is contained in:
Henry Schimke
2023-03-29 12:10:58 -05:00
parent 4ccfeddf4e
commit 6a1c5c568a
2 changed files with 71 additions and 35 deletions

View File

@@ -1,8 +1,28 @@
use crate::qrcode::decoder::FormatInformation; use crate::qrcode::decoder::FormatInformation;
impl FormatInformation { impl FormatInformation {
/**
* @param formatInfoBits1 format info indicator, with mask still applied
* @param formatInfoBits2 second copy of same info; both are checked at the same time to establish best match
*/
pub fn DecodeQR(formatInfoBits1: u32, formatInfoBits2: u32) -> Self {
todo!()
// // maks out the 'Dark Module' for mirrored and non-mirrored case (see Figure 25 in ISO/IEC 18004:2015)
// uint32_t mirroredFormatInfoBits2 = MirrorBits(((formatInfoBits2 >> 1) & 0b111111110000000) | (formatInfoBits2 & 0b1111111));
// formatInfoBits2 = ((formatInfoBits2 >> 1) & 0b111111100000000) | (formatInfoBits2 & 0b11111111);
// auto fi = FindBestFormatInfo(FORMAT_INFO_MASK_QR, FORMAT_INFO_DECODE_LOOKUP,
// {formatInfoBits1, formatInfoBits2, MirrorBits(formatInfoBits1), mirroredFormatInfoBits2});
// // Use bits 3/4 for error correction, and 0-2 for mask.
// fi.ecLevel = ECLevelFromBits((fi.index >> 3) & 0x03);
// fi.dataMask = static_cast<uint8_t>(fi.index & 0x07);
// fi.isMirrored = fi.bitsIndex > 1;
// return fi;
}
pub fn DecodeMQR(formatInfoBits: u32) -> Self { pub fn DecodeMQR(formatInfoBits: u32) -> Self {
unimplemented!() todo!()
// // We don't use the additional masking (with 0x4445) to work around potentially non complying MicroQRCode encoders // // We don't use the additional masking (with 0x4445) to work around potentially non complying MicroQRCode encoders
// auto fi = FindBestFormatInfo(0, FORMAT_INFO_DECODE_LOOKUP_MICRO, {formatInfoBits, MirrorBits(formatInfoBits)}); // auto fi = FindBestFormatInfo(0, FORMAT_INFO_DECODE_LOOKUP_MICRO, {formatInfoBits, MirrorBits(formatInfoBits)});
@@ -16,7 +36,8 @@ impl FormatInformation {
// return fi; // return fi;
} }
pub fn isValid(&self) -> bool { pub fn isValid(&self) -> bool {
unimplemented!() todo!()
} }
} }

View File

@@ -61,44 +61,59 @@ pub fn ReadVersion(bitMatrix: &BitMatrix) -> Result<VersionRef> {
} }
pub fn ReadFormatInformation(bitMatrix: &BitMatrix, isMicro: bool) -> Result<FormatInformation> { pub fn ReadFormatInformation(bitMatrix: &BitMatrix, isMicro: bool) -> Result<FormatInformation> {
todo!() if (!hasValidDimension(bitMatrix, isMicro)) {
// if (!hasValidDimension(bitMatrix, isMicro)) return Err(Exceptions::FORMAT);
// return {}; }
// if (isMicro) { if (isMicro) {
// // Read top-left format info bits // Read top-left format info bits
// int formatInfoBits = 0; let mut formatInfoBits = 0;
// for (int x = 1; x < 9; x++) for x in 1..9 {
// AppendBit(formatInfoBits, getBit(bitMatrix, x, 8)); // for (int x = 1; x < 9; x++)
// for (int y = 7; y >= 1; y--) AppendBit(&mut formatInfoBits, getBit(bitMatrix, x, 8, None));
// AppendBit(formatInfoBits, getBit(bitMatrix, 8, y)); }
for y in (1..=7).rev() {
// for (int y = 7; y >= 1; y--)
AppendBit(&mut formatInfoBits, getBit(bitMatrix, 8, y, None));
}
// return FormatInformation::DecodeMQR(formatInfoBits); return Ok(FormatInformation::DecodeMQR(formatInfoBits as u32));
// } }
// // Read top-left format info bits // Read top-left format info bits
// int formatInfoBits1 = 0; let mut formatInfoBits1 = 0;
// for (int x = 0; x < 6; x++) for x in 0..6 {
// AppendBit(formatInfoBits1, getBit(bitMatrix, x, 8)); // for (int x = 0; x < 6; x++)
// // .. and skip a bit in the timing pattern ... AppendBit(&mut formatInfoBits1, getBit(bitMatrix, x, 8, None));
// AppendBit(formatInfoBits1, getBit(bitMatrix, 7, 8)); }
// AppendBit(formatInfoBits1, getBit(bitMatrix, 8, 8)); // .. and skip a bit in the timing pattern ...
// AppendBit(formatInfoBits1, getBit(bitMatrix, 8, 7)); AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 7, 8, None));
// // .. and skip a bit in the timing pattern ... AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, 8, None));
// for (int y = 5; y >= 0; y--) AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, 7, None));
// AppendBit(formatInfoBits1, getBit(bitMatrix, 8, y)); // .. and skip a bit in the timing pattern ...
for y in (0..=6).rev() {
// for (int y = 5; y >= 0; y--)
AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, y, None));
}
// // Read the top-right/bottom-left pattern including the 'Dark Module' from the bottom-left // Read the top-right/bottom-left pattern including the 'Dark Module' from the bottom-left
// // part that has to be considered separately when looking for mirrored symbols. // part that has to be considered separately when looking for mirrored symbols.
// // See also FormatInformation::DecodeQR // See also FormatInformation::DecodeQR
// int dimension = bitMatrix.height(); let dimension = bitMatrix.height();
// int formatInfoBits2 = 0; let mut formatInfoBits2 = 0;
// for (int y = dimension - 1; y >= dimension - 8; y--) for y in ((dimension - 8)..=(dimension - 1)).rev() {
// AppendBit(formatInfoBits2, getBit(bitMatrix, 8, y)); // for (int y = dimension - 1; y >= dimension - 8; y--)
// for (int x = dimension - 8; x < dimension; x++) AppendBit(&mut formatInfoBits2, getBit(bitMatrix, 8, y, None));
// AppendBit(formatInfoBits2, getBit(bitMatrix, x, 8)); }
for x in (dimension - 8)..dimension {
// for (int x = dimension - 8; x < dimension; x++)
AppendBit(&mut formatInfoBits2, getBit(bitMatrix, x, 8, None));
}
// return FormatInformation::DecodeQR(formatInfoBits1, formatInfoBits2); return Ok(FormatInformation::DecodeQR(
formatInfoBits1 as u32,
formatInfoBits2 as u32,
));
} }
pub fn ReadQRCodewords( pub fn ReadQRCodewords(