mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
porting formatinformation and eclevel
This commit is contained in:
27
src/common/cpp_essentials/base_extentions/qr_ec_level.rs
Normal file
27
src/common/cpp_essentials/base_extentions/qr_ec_level.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use crate::common::Result;
|
||||
use crate::qrcode::decoder::ErrorCorrectionLevel;
|
||||
|
||||
impl ErrorCorrectionLevel {
|
||||
pub fn ECLevelFromBits(bits: u8, isMicro: bool) -> Self {
|
||||
if (isMicro) {
|
||||
let LEVEL_FOR_BITS: [ErrorCorrectionLevel; 8] = [
|
||||
ErrorCorrectionLevel::L,
|
||||
ErrorCorrectionLevel::L,
|
||||
ErrorCorrectionLevel::M,
|
||||
ErrorCorrectionLevel::L,
|
||||
ErrorCorrectionLevel::M,
|
||||
ErrorCorrectionLevel::L,
|
||||
ErrorCorrectionLevel::M,
|
||||
ErrorCorrectionLevel::Q,
|
||||
];
|
||||
return LEVEL_FOR_BITS[bits as usize & 0x07];
|
||||
}
|
||||
let LEVEL_FOR_BITS: [ErrorCorrectionLevel; 4] = [
|
||||
ErrorCorrectionLevel::M,
|
||||
ErrorCorrectionLevel::L,
|
||||
ErrorCorrectionLevel::H,
|
||||
ErrorCorrectionLevel::Q,
|
||||
];
|
||||
return LEVEL_FOR_BITS[bits as usize & 0x3];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user