mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
removed todo!() from qrcode_version.rs
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::qrcode::decoder::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
|
||||
*/
|
||||
* @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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::common::Result;
|
||||
use crate::qrcode::decoder::{Version, VersionRef, VERSION_DECODE_INFO};
|
||||
use crate::qrcode::decoder::{Version, VersionRef, MICRO_VERSIONS, VERSIONS, VERSION_DECODE_INFO};
|
||||
use crate::Exceptions;
|
||||
|
||||
// const Version* Version::AllMicroVersions()
|
||||
@@ -17,13 +17,28 @@ use crate::Exceptions;
|
||||
|
||||
impl Version {
|
||||
pub fn FromDimension(dimension: u32) -> Result<VersionRef> {
|
||||
todo!()
|
||||
// bool isMicro = dimension < 21;
|
||||
// if (dimension % DimensionStep(isMicro) != 1) {
|
||||
// //throw std::invalid_argument("Unexpected dimension");
|
||||
// return nullptr;
|
||||
// }
|
||||
// return FromNumber((dimension - DimensionOffset(isMicro)) / DimensionStep(isMicro), isMicro);
|
||||
let isMicro = dimension < 21;
|
||||
if (dimension % Self::DimensionStep(isMicro) != 1) {
|
||||
//throw std::invalid_argument("Unexpected dimension");
|
||||
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||
}
|
||||
return Self::FromNumber(
|
||||
(dimension - Self::DimensionOffset(isMicro)) / Self::DimensionStep(isMicro),
|
||||
isMicro,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn FromNumber(versionNumber: u32, is_micro: bool) -> Result<VersionRef> {
|
||||
if (versionNumber < 1 || versionNumber > (if is_micro { 4 } else { 40 })) {
|
||||
//throw std::invalid_argument("Version should be in range [1-40].");
|
||||
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||
}
|
||||
|
||||
Ok(if is_micro {
|
||||
&MICRO_VERSIONS[versionNumber as usize - 1]
|
||||
} else {
|
||||
&VERSIONS[versionNumber as usize - 1]
|
||||
})
|
||||
}
|
||||
|
||||
pub fn DimensionOfVersion(version: u32, is_micro: bool) -> u32 {
|
||||
|
||||
Reference in New Issue
Block a user