qrcode encoder pass

This commit is contained in:
Henry Schimke
2022-10-05 13:44:51 -05:00
parent 9c27185f7b
commit 4c51e2611c
3 changed files with 50 additions and 31 deletions

View File

@@ -60,6 +60,15 @@ impl ErrorCorrectionLevel {
ErrorCorrectionLevel::H => 0x02,
}
}
pub fn get_ordinal(&self) -> u8 {
match self {
ErrorCorrectionLevel::L => 0,
ErrorCorrectionLevel::M => 1,
ErrorCorrectionLevel::Q => 2,
ErrorCorrectionLevel::H => 3,
}
}
}
impl TryFrom<u8> for ErrorCorrectionLevel {

View File

@@ -90,7 +90,7 @@ impl Version {
}
pub fn getECBlocksForLevel(&self, ecLevel: ErrorCorrectionLevel) -> &ECBlocks {
&self.ecBlocks[ecLevel.get_value() as usize]
&self.ecBlocks[ecLevel.get_ordinal() as usize]
}
/**