mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
enhancement: cleanup building of QR Versions using a macro
This commit is contained in:
@@ -88,41 +88,29 @@ impl Version {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn new_micro(versionNumber: u32, ecBlocks: Vec<ECBlocks>) -> Self {
|
pub(super) fn without_alignment_patterns(versionNumber: u32, ecBlocks: Vec<ECBlocks>) -> Self {
|
||||||
let mut total = 0;
|
let mut total = 0;
|
||||||
let ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
|
let ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
|
||||||
let ecbArray = ecBlocks[0].getECBlocks();
|
let ecbArray = ecBlocks[0].getECBlocks();
|
||||||
let mut i = 0;
|
for ecb_array_element in ecbArray {
|
||||||
while i < ecbArray.len() {
|
total +=
|
||||||
total += ecbArray[i].getCount() * (ecbArray[i].getDataCodewords() + ecCodewords);
|
ecb_array_element.getCount() * (ecb_array_element.getDataCodewords() + ecCodewords);
|
||||||
i += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let symbol_type = if ecBlocks[0].getECCodewordsPerBlock() < 7
|
||||||
|
|| ecBlocks[0].getECCodewordsPerBlock() == 8
|
||||||
|
{
|
||||||
|
Type::Micro
|
||||||
|
} else {
|
||||||
|
Type::Model1
|
||||||
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
versionNumber,
|
versionNumber,
|
||||||
alignmentPatternCenters: Vec::default(),
|
alignmentPatternCenters: Vec::default(),
|
||||||
ecBlocks,
|
ecBlocks,
|
||||||
totalCodewords: total,
|
totalCodewords: total,
|
||||||
qr_type: Type::Micro,
|
qr_type: symbol_type,
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn new_model1(versionNumber: u32, ecBlocks: Vec<ECBlocks>) -> Self {
|
|
||||||
let mut total = 0;
|
|
||||||
let ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
|
|
||||||
let ecbArray = ecBlocks[0].getECBlocks();
|
|
||||||
let mut i = 0;
|
|
||||||
while i < ecbArray.len() {
|
|
||||||
total += ecbArray[i].getCount() * (ecbArray[i].getDataCodewords() + ecCodewords);
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
|
||||||
versionNumber,
|
|
||||||
alignmentPatternCenters: Vec::default(),
|
|
||||||
ecBlocks,
|
|
||||||
totalCodewords: total,
|
|
||||||
qr_type: Type::Model1,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user