diff --git a/src/qrcode/decoder/FormatInformation.java b/src/qrcode/decoder/FormatInformation.java
deleted file mode 100644
index 95ee701..0000000
--- a/src/qrcode/decoder/FormatInformation.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.zxing.qrcode.decoder;
-
-/**
- *
Encapsulates a QR Code's format information, including the data mask used and
- * error correction level.
- *
- * @author Sean Owen
- * @see DataMask
- * @see ErrorCorrectionLevel
- */
-final class FormatInformation {
-
- private static final int FORMAT_INFO_MASK_QR = 0x5412;
-
- /**
- * See ISO 18004:2006, Annex C, Table C.1
- */
- private static final int[][] FORMAT_INFO_DECODE_LOOKUP = {
- {0x5412, 0x00},
- {0x5125, 0x01},
- {0x5E7C, 0x02},
- {0x5B4B, 0x03},
- {0x45F9, 0x04},
- {0x40CE, 0x05},
- {0x4F97, 0x06},
- {0x4AA0, 0x07},
- {0x77C4, 0x08},
- {0x72F3, 0x09},
- {0x7DAA, 0x0A},
- {0x789D, 0x0B},
- {0x662F, 0x0C},
- {0x6318, 0x0D},
- {0x6C41, 0x0E},
- {0x6976, 0x0F},
- {0x1689, 0x10},
- {0x13BE, 0x11},
- {0x1CE7, 0x12},
- {0x19D0, 0x13},
- {0x0762, 0x14},
- {0x0255, 0x15},
- {0x0D0C, 0x16},
- {0x083B, 0x17},
- {0x355F, 0x18},
- {0x3068, 0x19},
- {0x3F31, 0x1A},
- {0x3A06, 0x1B},
- {0x24B4, 0x1C},
- {0x2183, 0x1D},
- {0x2EDA, 0x1E},
- {0x2BED, 0x1F},
- };
-
- private final ErrorCorrectionLevel errorCorrectionLevel;
- private final byte dataMask;
-
- private FormatInformation(int formatInfo) {
- // Bits 3,4
- errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
- // Bottom 3 bits
- dataMask = (byte) (formatInfo & 0x07);
- }
-
- static int numBitsDiffering(int a, int b) {
- return Integer.bitCount(a ^ b);
- }
-
- /**
- * @param maskedFormatInfo1 format info indicator, with mask still applied
- * @param maskedFormatInfo2 second copy of same info; both are checked at the same time
- * to establish best match
- * @return information about the format it specifies, or {@code null}
- * if doesn't seem to match any known pattern
- */
- static FormatInformation decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) {
- FormatInformation formatInfo = doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2);
- if (formatInfo != null) {
- return formatInfo;
- }
- // Should return null, but, some QR codes apparently
- // do not mask this info. Try again by actually masking the pattern
- // first
- return doDecodeFormatInformation(maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR,
- maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR);
- }
-
- private static FormatInformation doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) {
- // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
- int bestDifference = Integer.MAX_VALUE;
- int bestFormatInfo = 0;
- for (int[] decodeInfo : FORMAT_INFO_DECODE_LOOKUP) {
- int targetInfo = decodeInfo[0];
- if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2) {
- // Found an exact match
- return new FormatInformation(decodeInfo[1]);
- }
- int bitsDifference = numBitsDiffering(maskedFormatInfo1, targetInfo);
- if (bitsDifference < bestDifference) {
- bestFormatInfo = decodeInfo[1];
- bestDifference = bitsDifference;
- }
- if (maskedFormatInfo1 != maskedFormatInfo2) {
- // also try the other option
- bitsDifference = numBitsDiffering(maskedFormatInfo2, targetInfo);
- if (bitsDifference < bestDifference) {
- bestFormatInfo = decodeInfo[1];
- bestDifference = bitsDifference;
- }
- }
- }
- // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
- // differing means we found a match
- if (bestDifference <= 3) {
- return new FormatInformation(bestFormatInfo);
- }
- return null;
- }
-
- ErrorCorrectionLevel getErrorCorrectionLevel() {
- return errorCorrectionLevel;
- }
-
- byte getDataMask() {
- return dataMask;
- }
-
- @Override
- public int hashCode() {
- return (errorCorrectionLevel.ordinal() << 3) | dataMask;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof FormatInformation)) {
- return false;
- }
- FormatInformation other = (FormatInformation) o;
- return this.errorCorrectionLevel == other.errorCorrectionLevel &&
- this.dataMask == other.dataMask;
- }
-
-}
diff --git a/src/qrcode/decoder/error_correction_level.rs b/src/qrcode/decoder/error_correction_level.rs
index 79064d6..7030cd4 100644
--- a/src/qrcode/decoder/error_correction_level.rs
+++ b/src/qrcode/decoder/error_correction_level.rs
@@ -22,7 +22,7 @@ use crate::Exceptions;
*
* @author Sean Owen
*/
-#[derive(Debug, PartialEq, Eq, Clone, Copy)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
pub enum ErrorCorrectionLevel {
/** L = ~7% correction */
L, //0x01
diff --git a/src/qrcode/decoder/format_information.rs b/src/qrcode/decoder/format_information.rs
new file mode 100644
index 0000000..415f704
--- /dev/null
+++ b/src/qrcode/decoder/format_information.rs
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+use super::ErrorCorrectionLevel;
+
+const FORMAT_INFO_MASK_QR: u32 = 0x5412;
+
+/**
+ * See ISO 18004:2006, Annex C, Table C.1
+ */
+const FORMAT_INFO_DECODE_LOOKUP: [[u32; 2]; 32] = [
+ [0x5412, 0x00],
+ [0x5125, 0x01],
+ [0x5E7C, 0x02],
+ [0x5B4B, 0x03],
+ [0x45F9, 0x04],
+ [0x40CE, 0x05],
+ [0x4F97, 0x06],
+ [0x4AA0, 0x07],
+ [0x77C4, 0x08],
+ [0x72F3, 0x09],
+ [0x7DAA, 0x0A],
+ [0x789D, 0x0B],
+ [0x662F, 0x0C],
+ [0x6318, 0x0D],
+ [0x6C41, 0x0E],
+ [0x6976, 0x0F],
+ [0x1689, 0x10],
+ [0x13BE, 0x11],
+ [0x1CE7, 0x12],
+ [0x19D0, 0x13],
+ [0x0762, 0x14],
+ [0x0255, 0x15],
+ [0x0D0C, 0x16],
+ [0x083B, 0x17],
+ [0x355F, 0x18],
+ [0x3068, 0x19],
+ [0x3F31, 0x1A],
+ [0x3A06, 0x1B],
+ [0x24B4, 0x1C],
+ [0x2183, 0x1D],
+ [0x2EDA, 0x1E],
+ [0x2BED, 0x1F],
+];
+
+/**
+ * Encapsulates a QR Code's format information, including the data mask used and
+ * error correction level.
+ *
+ * @author Sean Owen
+ * @see DataMask
+ * @see ErrorCorrectionLevel
+ */
+#[derive(Hash, Eq, PartialEq)]
+pub struct FormatInformation {
+ error_correction_level: ErrorCorrectionLevel,
+ data_mask: u8,
+}
+
+impl FormatInformation {
+ fn new(format_info: u8) -> Self {
+ // Bits 3,4
+ let errorCorrectionLevel =
+ ErrorCorrectionLevel::forBits((format_info >> 3) & 0x03).expect("pass in valid bits");
+ // Bottom 3 bits
+ let dataMask = format_info & 0x07;
+ Self {
+ error_correction_level: errorCorrectionLevel,
+ data_mask: dataMask,
+ }
+ }
+
+ pub fn numBitsDiffering(a: u32, b: u32) -> u32 {
+ (a ^ b).count_ones()
+ // return Integer.bitCount(a ^ b);
+ }
+
+ /**
+ * @param maskedFormatInfo1 format info indicator, with mask still applied
+ * @param maskedFormatInfo2 second copy of same info; both are checked at the same time
+ * to establish best match
+ * @return information about the format it specifies, or {@code null}
+ * if doesn't seem to match any known pattern
+ */
+ fn decodeFormatInformation(
+ maskedFormatInfo1: u32,
+ maskedFormatInfo2: u32,
+ ) -> FormatInformation {
+ let formatInfo = Self::doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2);
+ if formatInfo.is_some() {
+ return formatInfo.unwrap();
+ }
+ // Should return null, but, some QR codes apparently
+ // do not mask this info. Try again by actually masking the pattern
+ // first
+ return Self::doDecodeFormatInformation(
+ maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR,
+ maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR,
+ )
+ .unwrap();
+ }
+
+ fn doDecodeFormatInformation(
+ masked_format_info1: u32,
+ masked_format_info2: u32,
+ ) -> Option {
+ // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
+ let best_difference = u32::MAX;
+ let best_format_info = 0;
+ for decodeInfo in FORMAT_INFO_DECODE_LOOKUP {
+ // for (int[] decodeInfo : FORMAT_INFO_DECODE_LOOKUP) {
+ let targetInfo = decodeInfo[0];
+ if targetInfo == masked_format_info1 || targetInfo == masked_format_info2 {
+ // Found an exact match
+ return Some(FormatInformation::new(decodeInfo[1] as u8));
+ }
+ let bits_difference = Self::numBitsDiffering(masked_format_info1, targetInfo);
+ if bits_difference < best_difference {
+ best_format_info = decodeInfo[1] as u8;
+ best_difference = bits_difference;
+ }
+ if masked_format_info1 != masked_format_info2 {
+ // also try the other option
+ bits_difference = Self::numBitsDiffering(masked_format_info2, targetInfo);
+ if (bits_difference < best_difference) {
+ best_format_info = decodeInfo[1] as u8;
+ best_difference = bits_difference;
+ }
+ }
+ }
+ // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits
+ // differing means we found a match
+ if best_difference <= 3 {
+ return Some(FormatInformation::new(best_format_info));
+ }
+ None
+ }
+
+ pub fn getErrorCorrectionLevel(&self) -> &ErrorCorrectionLevel {
+ &self.error_correction_level
+ }
+
+ pub fn getDataMask(&self) -> u8 {
+ self.data_mask
+ }
+
+ // @Override
+ // public int hashCode() {
+ // return (errorCorrectionLevel.ordinal() << 3) | dataMask;
+ // }
+
+ // @Override
+ // public boolean equals(Object o) {
+ // if (!(o instanceof FormatInformation)) {
+ // return false;
+ // }
+ // FormatInformation other = (FormatInformation) o;
+ // return this.errorCorrectionLevel == other.errorCorrectionLevel &&
+ // this.dataMask == other.dataMask;
+ // }
+}
diff --git a/src/qrcode/decoder/mod.rs b/src/qrcode/decoder/mod.rs
index c6e7c47..6a3891f 100644
--- a/src/qrcode/decoder/mod.rs
+++ b/src/qrcode/decoder/mod.rs
@@ -1,10 +1,12 @@
mod version;
mod mode;
mod error_correction_level;
+mod format_information;
#[cfg(test)]
mod ErrorCorrectionLevelTestCase;
pub use version::*;
pub use mode::*;
-pub use error_correction_level::*;
\ No newline at end of file
+pub use error_correction_level::*;
+pub use format_information::*;
\ No newline at end of file
diff --git a/src/qrcode/decoder/mode.rs b/src/qrcode/decoder/mode.rs
index cce25e3..1c4e624 100644
--- a/src/qrcode/decoder/mode.rs
+++ b/src/qrcode/decoder/mode.rs
@@ -16,6 +16,8 @@
use crate::Exceptions;
+use super::Version;
+
/**
* See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which
* data can be encoded to bits in the QR code standard.
diff --git a/src/qrcode/decoder/version.rs b/src/qrcode/decoder/version.rs
index e1ea522..f507ff4 100755
--- a/src/qrcode/decoder/version.rs
+++ b/src/qrcode/decoder/version.rs
@@ -16,588 +16,972 @@
use std::fmt;
-use crate::{Exceptions, common::BitMatrix};
+use crate::{common::BitMatrix, Exceptions};
-use super::ErrorCorrectionLevel;
+use super::{ErrorCorrectionLevel, FormatInformation};
- /**
- * See ISO 18004:2006 Annex D.
- * Element i represents the raw version bits that specify version i + 7
- */
- const VERSION_DECODE_INFO : [u32;34] = [
- 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6,
- 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78,
- 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683,
- 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB,
- 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250,
- 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B,
- 0x2542E, 0x26A64, 0x27541, 0x28C69
- ];
+/**
+ * See ISO 18004:2006 Annex D.
+ * Element i represents the raw version bits that specify version i + 7
+ */
+const VERSION_DECODE_INFO: [u32; 34] = [
+ 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78,
+ 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB,
+ 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B,
+ 0x2542E, 0x26A64, 0x27541, 0x28C69,
+];
- const VERSIONS :Vec = Version::buildVersions();
+const VERSIONS: Vec = Version::buildVersions();
/**
* See ISO 18004:2006 Annex D
*
* @author Sean Owen
*/
pub struct Version {
-
-// private static final Version[] VERSIONS = buildVersions();
-
- versionNumber: u32,
- alignmentPatternCenters: Vec,
- ecBlocks:Vec,
- totalCodewords:u32,
-
+ // private static final Version[] VERSIONS = buildVersions();
+ versionNumber: u32,
+ alignmentPatternCenters: Vec,
+ ecBlocks: Vec,
+ totalCodewords: u32,
}
impl Version {
- const fn new( versionNumber:u32,
- alignmentPatternCenters:Vec,
- ecBlocks:Vec) -> Self {
-
- let total = 0;
- let ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
- let ecbArray = ecBlocks[0].getECBlocks();
- let mut i = 0;
- while i < ecbArray.len() {
-// for ecBlock in ecbArray {
- // for (ECB ecBlock : ecbArray) {
- total += ecbArray[i].getCount() * (ecbArray[i].getDataCodewords() + ecCodewords);
- i+=1;
- }
-
- Self {
- versionNumber,
- alignmentPatternCenters,
- ecBlocks,
- totalCodewords: total,
- }
- }
-
- pub fn getVersionNumber(&self) -> u32 {
- self. versionNumber
- }
-
- pub fn getAlignmentPatternCenters(&self) -> &[u32]{
- &self. alignmentPatternCenters
- }
-
- pub fn getTotalCodewords(&self) -> u32{
- self.totalCodewords
- }
-
- pub fn getDimensionForVersion(&self)->u32 {
- 17 + 4 * self.versionNumber
- }
-
- pub fn getECBlocksForLevel(&self, ecLevel:ErrorCorrectionLevel) -> &ECBlocks{
- &self.ecBlocks[ecLevel.get_value() as usize]
- }
-
- /**
- * Deduces version information purely from QR Code dimensions.
- *
- * @param dimension dimension in modules
- * @return Version for a QR Code of that dimension
- * @throws FormatException if dimension is not 1 mod 4
- */
- pub fn getProvisionalVersionForDimension( dimension:u32) -> Result {
- if dimension % 4 != 1 {
- return Err(Exceptions::FormatException("dimension incorrect".to_owned()));
- }
- Self::getVersionForNumber((dimension - 17) / 4)
- // try {
- // return getVersionForNumber((dimension - 17) / 4);
- // } catch (IllegalArgumentException ignored) {
- // throw FormatException.getFormatInstance();
- // }
- }
-
- pub fn getVersionForNumber( versionNumber:u32) -> Result{
- if versionNumber < 1 || versionNumber > 40 {
- return Err(Exceptions::IllegalArgumentException("version out of spec".to_owned()))
- }
- Ok(VERSIONS[versionNumber as usize - 1])
- }
-
- pub fn decodeVersionInformation( versionBits:u32) -> Result {
- let bestDifference = u32::MAX;
- let bestVersion = 0;
- for i in 0..VERSION_DECODE_INFO.len() as u32 {
- // for (int i = 0; i < VERSION_DECODE_INFO.length; i++) {
- let targetVersion = VERSION_DECODE_INFO[i];
- // Do the version info bits match exactly? done.
- if (targetVersion == versionBits) {
- return Self::getVersionForNumber(i + 7);
- }
- // Otherwise see if this is the closest to a real version info bit string
- // we have seen so far
- let bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion);
- if bitsDifference < bestDifference {
- bestVersion = i + 7;
- bestDifference = bitsDifference;
- }
- }
- // We can tolerate up to 3 bits of error since no two version info codewords will
- // differ in less than 8 bits.
- if bestDifference <= 3 {
- return Self::getVersionForNumber(bestVersion);
- }
- // If we didn't find a close enough match, fail
- Err(Exceptions::NotFoundException("could not find".to_owned()))
- }
-
- /**
- * See ISO 18004:2006 Annex E
- */
- pub fn buildFunctionPattern(&self) -> BitMatrix{
- let dimension = self.getDimensionForVersion();
- let bitMatrix = BitMatrix::with_single_dimension(dimension);
-
- // Top left finder pattern + separator + format
- bitMatrix.setRegion(0, 0, 9, 9);
- // Top right finder pattern + separator + format
- bitMatrix.setRegion(dimension - 8, 0, 8, 9);
- // Bottom left finder pattern + separator + format
- bitMatrix.setRegion(0, dimension - 8, 9, 8);
-
- // Alignment patterns
- let max = self.alignmentPatternCenters.len();
- for x in 0..max {
- // for (int x = 0; x < max; x++) {
- let i = self.alignmentPatternCenters[x] - 2;
- for y in 0..max {
- // for (int y = 0; y < max; y++) {
- if (x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0) {
- bitMatrix.setRegion(self.alignmentPatternCenters[y] - 2, i, 5, 5);
+ const fn new(
+ versionNumber: u32,
+ alignmentPatternCenters: Vec,
+ ecBlocks: Vec,
+ ) -> Self {
+ let total = 0;
+ let ecCodewords = ecBlocks[0].getECCodewordsPerBlock();
+ let ecbArray = ecBlocks[0].getECBlocks();
+ let mut i = 0;
+ while i < ecbArray.len() {
+ // for ecBlock in ecbArray {
+ // for (ECB ecBlock : ecbArray) {
+ total += ecbArray[i].getCount() * (ecbArray[i].getDataCodewords() + ecCodewords);
+ i += 1;
+ }
+
+ Self {
+ versionNumber,
+ alignmentPatternCenters,
+ ecBlocks,
+ totalCodewords: total,
}
- // else no o alignment patterns near the three finder patterns
- }
}
- // Vertical timing pattern
- bitMatrix.setRegion(6, 9, 1, dimension - 17);
- // Horizontal timing pattern
- bitMatrix.setRegion(9, 6, dimension - 17, 1);
-
- if self.versionNumber > 6 {
- // Version info, top right
- bitMatrix.setRegion(dimension - 11, 0, 3, 6);
- // Version info, bottom left
- bitMatrix.setRegion(0, dimension - 11, 6, 3);
+ pub fn getVersionNumber(&self) -> u32 {
+ self.versionNumber
}
- bitMatrix
- }
+ pub fn getAlignmentPatternCenters(&self) -> &[u32] {
+ &self.alignmentPatternCenters
+ }
- /**
- * See ISO 18004:2006 6.5.1 Table 9
- */
- pub const fn buildVersions() -> Vec {
- [
- Version::new(1, [],Vec::from([
- ECBlocks::new(7, ECB::new(1, 19)),
- ECBlocks::new(10, ECB::new(1, 16)),
- ECBlocks::new(13, ECB::new(1, 13)),
- ECBlocks::new(17, ECB::new(1, 9))])),
- Version::new(2, [6, 18], Vec::from([
- ECBlocks::new(10, ECB::new(1, 34)),
- ECBlocks::new(16, ECB::new(1, 28)),
- ECBlocks::new(22, ECB::new(1, 22)),
- ECBlocks::new(28, ECB::new(1, 16))])),
- Version::new(3, [6, 22], Vec::from([
- ECBlocks::new(15, ECB::new(1, 55)),
- ECBlocks::new(26, ECB::new(1, 44)),
- ECBlocks::new(18, ECB::new(2, 17)),
- ECBlocks::new(22, ECB::new(2, 13))])),
- new Version(4, new int[]{6, 26},
- new ECBlocks(20, new ECB(1, 80)),
- new ECBlocks(18, new ECB(2, 32)),
- new ECBlocks(26, new ECB(2, 24)),
- new ECBlocks(16, new ECB(4, 9))),
- new Version(5, new int[]{6, 30},
- new ECBlocks(26, new ECB(1, 108)),
- new ECBlocks(24, new ECB(2, 43)),
- new ECBlocks(18, new ECB(2, 15),
- new ECB(2, 16)),
- new ECBlocks(22, new ECB(2, 11),
- new ECB(2, 12))),
- new Version(6, new int[]{6, 34},
- new ECBlocks(18, new ECB(2, 68)),
- new ECBlocks(16, new ECB(4, 27)),
- new ECBlocks(24, new ECB(4, 19)),
- new ECBlocks(28, new ECB(4, 15))),
- new Version(7, new int[]{6, 22, 38},
- new ECBlocks(20, new ECB(2, 78)),
- new ECBlocks(18, new ECB(4, 31)),
- new ECBlocks(18, new ECB(2, 14),
- new ECB(4, 15)),
- new ECBlocks(26, new ECB(4, 13),
- new ECB(1, 14))),
- new Version(8, new int[]{6, 24, 42},
- new ECBlocks(24, new ECB(2, 97)),
- new ECBlocks(22, new ECB(2, 38),
- new ECB(2, 39)),
- new ECBlocks(22, new ECB(4, 18),
- new ECB(2, 19)),
- new ECBlocks(26, new ECB(4, 14),
- new ECB(2, 15))),
- new Version(9, new int[]{6, 26, 46},
- new ECBlocks(30, new ECB(2, 116)),
- new ECBlocks(22, new ECB(3, 36),
- new ECB(2, 37)),
- new ECBlocks(20, new ECB(4, 16),
- new ECB(4, 17)),
- new ECBlocks(24, new ECB(4, 12),
- new ECB(4, 13))),
- new Version(10, new int[]{6, 28, 50},
- new ECBlocks(18, new ECB(2, 68),
- new ECB(2, 69)),
- new ECBlocks(26, new ECB(4, 43),
- new ECB(1, 44)),
- new ECBlocks(24, new ECB(6, 19),
- new ECB(2, 20)),
- new ECBlocks(28, new ECB(6, 15),
- new ECB(2, 16))),
- new Version(11, new int[]{6, 30, 54},
- new ECBlocks(20, new ECB(4, 81)),
- new ECBlocks(30, new ECB(1, 50),
- new ECB(4, 51)),
- new ECBlocks(28, new ECB(4, 22),
- new ECB(4, 23)),
- new ECBlocks(24, new ECB(3, 12),
- new ECB(8, 13))),
- new Version(12, new int[]{6, 32, 58},
- new ECBlocks(24, new ECB(2, 92),
- new ECB(2, 93)),
- new ECBlocks(22, new ECB(6, 36),
- new ECB(2, 37)),
- new ECBlocks(26, new ECB(4, 20),
- new ECB(6, 21)),
- new ECBlocks(28, new ECB(7, 14),
- new ECB(4, 15))),
- new Version(13, new int[]{6, 34, 62},
- new ECBlocks(26, new ECB(4, 107)),
- new ECBlocks(22, new ECB(8, 37),
- new ECB(1, 38)),
- new ECBlocks(24, new ECB(8, 20),
- new ECB(4, 21)),
- new ECBlocks(22, new ECB(12, 11),
- new ECB(4, 12))),
- new Version(14, new int[]{6, 26, 46, 66},
- new ECBlocks(30, new ECB(3, 115),
- new ECB(1, 116)),
- new ECBlocks(24, new ECB(4, 40),
- new ECB(5, 41)),
- new ECBlocks(20, new ECB(11, 16),
- new ECB(5, 17)),
- new ECBlocks(24, new ECB(11, 12),
- new ECB(5, 13))),
- new Version(15, new int[]{6, 26, 48, 70},
- new ECBlocks(22, new ECB(5, 87),
- new ECB(1, 88)),
- new ECBlocks(24, new ECB(5, 41),
- new ECB(5, 42)),
- new ECBlocks(30, new ECB(5, 24),
- new ECB(7, 25)),
- new ECBlocks(24, new ECB(11, 12),
- new ECB(7, 13))),
- new Version(16, new int[]{6, 26, 50, 74},
- new ECBlocks(24, new ECB(5, 98),
- new ECB(1, 99)),
- new ECBlocks(28, new ECB(7, 45),
- new ECB(3, 46)),
- new ECBlocks(24, new ECB(15, 19),
- new ECB(2, 20)),
- new ECBlocks(30, new ECB(3, 15),
- new ECB(13, 16))),
- new Version(17, new int[]{6, 30, 54, 78},
- new ECBlocks(28, new ECB(1, 107),
- new ECB(5, 108)),
- new ECBlocks(28, new ECB(10, 46),
- new ECB(1, 47)),
- new ECBlocks(28, new ECB(1, 22),
- new ECB(15, 23)),
- new ECBlocks(28, new ECB(2, 14),
- new ECB(17, 15))),
- new Version(18, new int[]{6, 30, 56, 82},
- new ECBlocks(30, new ECB(5, 120),
- new ECB(1, 121)),
- new ECBlocks(26, new ECB(9, 43),
- new ECB(4, 44)),
- new ECBlocks(28, new ECB(17, 22),
- new ECB(1, 23)),
- new ECBlocks(28, new ECB(2, 14),
- new ECB(19, 15))),
- new Version(19, new int[]{6, 30, 58, 86},
- new ECBlocks(28, new ECB(3, 113),
- new ECB(4, 114)),
- new ECBlocks(26, new ECB(3, 44),
- new ECB(11, 45)),
- new ECBlocks(26, new ECB(17, 21),
- new ECB(4, 22)),
- new ECBlocks(26, new ECB(9, 13),
- new ECB(16, 14))),
- new Version(20, new int[]{6, 34, 62, 90},
- new ECBlocks(28, new ECB(3, 107),
- new ECB(5, 108)),
- new ECBlocks(26, new ECB(3, 41),
- new ECB(13, 42)),
- new ECBlocks(30, new ECB(15, 24),
- new ECB(5, 25)),
- new ECBlocks(28, new ECB(15, 15),
- new ECB(10, 16))),
- new Version(21, new int[]{6, 28, 50, 72, 94},
- new ECBlocks(28, new ECB(4, 116),
- new ECB(4, 117)),
- new ECBlocks(26, new ECB(17, 42)),
- new ECBlocks(28, new ECB(17, 22),
- new ECB(6, 23)),
- new ECBlocks(30, new ECB(19, 16),
- new ECB(6, 17))),
- new Version(22, new int[]{6, 26, 50, 74, 98},
- new ECBlocks(28, new ECB(2, 111),
- new ECB(7, 112)),
- new ECBlocks(28, new ECB(17, 46)),
- new ECBlocks(30, new ECB(7, 24),
- new ECB(16, 25)),
- new ECBlocks(24, new ECB(34, 13))),
- new Version(23, new int[]{6, 30, 54, 78, 102},
- new ECBlocks(30, new ECB(4, 121),
- new ECB(5, 122)),
- new ECBlocks(28, new ECB(4, 47),
- new ECB(14, 48)),
- new ECBlocks(30, new ECB(11, 24),
- new ECB(14, 25)),
- new ECBlocks(30, new ECB(16, 15),
- new ECB(14, 16))),
- new Version(24, new int[]{6, 28, 54, 80, 106},
- new ECBlocks(30, new ECB(6, 117),
- new ECB(4, 118)),
- new ECBlocks(28, new ECB(6, 45),
- new ECB(14, 46)),
- new ECBlocks(30, new ECB(11, 24),
- new ECB(16, 25)),
- new ECBlocks(30, new ECB(30, 16),
- new ECB(2, 17))),
- new Version(25, new int[]{6, 32, 58, 84, 110},
- new ECBlocks(26, new ECB(8, 106),
- new ECB(4, 107)),
- new ECBlocks(28, new ECB(8, 47),
- new ECB(13, 48)),
- new ECBlocks(30, new ECB(7, 24),
- new ECB(22, 25)),
- new ECBlocks(30, new ECB(22, 15),
- new ECB(13, 16))),
- new Version(26, new int[]{6, 30, 58, 86, 114},
- new ECBlocks(28, new ECB(10, 114),
- new ECB(2, 115)),
- new ECBlocks(28, new ECB(19, 46),
- new ECB(4, 47)),
- new ECBlocks(28, new ECB(28, 22),
- new ECB(6, 23)),
- new ECBlocks(30, new ECB(33, 16),
- new ECB(4, 17))),
- new Version(27, new int[]{6, 34, 62, 90, 118},
- new ECBlocks(30, new ECB(8, 122),
- new ECB(4, 123)),
- new ECBlocks(28, new ECB(22, 45),
- new ECB(3, 46)),
- new ECBlocks(30, new ECB(8, 23),
- new ECB(26, 24)),
- new ECBlocks(30, new ECB(12, 15),
- new ECB(28, 16))),
- new Version(28, new int[]{6, 26, 50, 74, 98, 122},
- new ECBlocks(30, new ECB(3, 117),
- new ECB(10, 118)),
- new ECBlocks(28, new ECB(3, 45),
- new ECB(23, 46)),
- new ECBlocks(30, new ECB(4, 24),
- new ECB(31, 25)),
- new ECBlocks(30, new ECB(11, 15),
- new ECB(31, 16))),
- new Version(29, new int[]{6, 30, 54, 78, 102, 126},
- new ECBlocks(30, new ECB(7, 116),
- new ECB(7, 117)),
- new ECBlocks(28, new ECB(21, 45),
- new ECB(7, 46)),
- new ECBlocks(30, new ECB(1, 23),
- new ECB(37, 24)),
- new ECBlocks(30, new ECB(19, 15),
- new ECB(26, 16))),
- new Version(30, new int[]{6, 26, 52, 78, 104, 130},
- new ECBlocks(30, new ECB(5, 115),
- new ECB(10, 116)),
- new ECBlocks(28, new ECB(19, 47),
- new ECB(10, 48)),
- new ECBlocks(30, new ECB(15, 24),
- new ECB(25, 25)),
- new ECBlocks(30, new ECB(23, 15),
- new ECB(25, 16))),
- new Version(31, new int[]{6, 30, 56, 82, 108, 134},
- new ECBlocks(30, new ECB(13, 115),
- new ECB(3, 116)),
- new ECBlocks(28, new ECB(2, 46),
- new ECB(29, 47)),
- new ECBlocks(30, new ECB(42, 24),
- new ECB(1, 25)),
- new ECBlocks(30, new ECB(23, 15),
- new ECB(28, 16))),
- new Version(32, new int[]{6, 34, 60, 86, 112, 138},
- new ECBlocks(30, new ECB(17, 115)),
- new ECBlocks(28, new ECB(10, 46),
- new ECB(23, 47)),
- new ECBlocks(30, new ECB(10, 24),
- new ECB(35, 25)),
- new ECBlocks(30, new ECB(19, 15),
- new ECB(35, 16))),
- new Version(33, new int[]{6, 30, 58, 86, 114, 142},
- new ECBlocks(30, new ECB(17, 115),
- new ECB(1, 116)),
- new ECBlocks(28, new ECB(14, 46),
- new ECB(21, 47)),
- new ECBlocks(30, new ECB(29, 24),
- new ECB(19, 25)),
- new ECBlocks(30, new ECB(11, 15),
- new ECB(46, 16))),
- new Version(34, new int[]{6, 34, 62, 90, 118, 146},
- new ECBlocks(30, new ECB(13, 115),
- new ECB(6, 116)),
- new ECBlocks(28, new ECB(14, 46),
- new ECB(23, 47)),
- new ECBlocks(30, new ECB(44, 24),
- new ECB(7, 25)),
- new ECBlocks(30, new ECB(59, 16),
- new ECB(1, 17))),
- new Version(35, new int[]{6, 30, 54, 78, 102, 126, 150},
- new ECBlocks(30, new ECB(12, 121),
- new ECB(7, 122)),
- new ECBlocks(28, new ECB(12, 47),
- new ECB(26, 48)),
- new ECBlocks(30, new ECB(39, 24),
- new ECB(14, 25)),
- new ECBlocks(30, new ECB(22, 15),
- new ECB(41, 16))),
- new Version(36, new int[]{6, 24, 50, 76, 102, 128, 154},
- new ECBlocks(30, new ECB(6, 121),
- new ECB(14, 122)),
- new ECBlocks(28, new ECB(6, 47),
- new ECB(34, 48)),
- new ECBlocks(30, new ECB(46, 24),
- new ECB(10, 25)),
- new ECBlocks(30, new ECB(2, 15),
- new ECB(64, 16))),
- new Version(37, new int[]{6, 28, 54, 80, 106, 132, 158},
- new ECBlocks(30, new ECB(17, 122),
- new ECB(4, 123)),
- new ECBlocks(28, new ECB(29, 46),
- new ECB(14, 47)),
- new ECBlocks(30, new ECB(49, 24),
- new ECB(10, 25)),
- new ECBlocks(30, new ECB(24, 15),
- new ECB(46, 16))),
- new Version(38, new int[]{6, 32, 58, 84, 110, 136, 162},
- new ECBlocks(30, new ECB(4, 122),
- new ECB(18, 123)),
- new ECBlocks(28, new ECB(13, 46),
- new ECB(32, 47)),
- new ECBlocks(30, new ECB(48, 24),
- new ECB(14, 25)),
- new ECBlocks(30, new ECB(42, 15),
- new ECB(32, 16))),
- new Version(39, new int[]{6, 26, 54, 82, 110, 138, 166},
- new ECBlocks(30, new ECB(20, 117),
- new ECB(4, 118)),
- new ECBlocks(28, new ECB(40, 47),
- new ECB(7, 48)),
- new ECBlocks(30, new ECB(43, 24),
- new ECB(22, 25)),
- new ECBlocks(30, new ECB(10, 15),
- new ECB(67, 16))),
- new Version(40, new int[]{6, 30, 58, 86, 114, 142, 170},
- new ECBlocks(30, new ECB(19, 118),
- new ECB(6, 119)),
- new ECBlocks(28, new ECB(18, 47),
- new ECB(31, 48)),
- new ECBlocks(30, new ECB(34, 24),
- new ECB(34, 25)),
- new ECBlocks(30, new ECB(20, 15),
- new ECB(61, 16)))
- ]
- }
+ pub fn getTotalCodewords(&self) -> u32 {
+ self.totalCodewords
+ }
+
+ pub fn getDimensionForVersion(&self) -> u32 {
+ 17 + 4 * self.versionNumber
+ }
+
+ pub fn getECBlocksForLevel(&self, ecLevel: ErrorCorrectionLevel) -> &ECBlocks {
+ &self.ecBlocks[ecLevel.get_value() as usize]
+ }
+
+ /**
+ * Deduces version information purely from QR Code dimensions.
+ *
+ * @param dimension dimension in modules
+ * @return Version for a QR Code of that dimension
+ * @throws FormatException if dimension is not 1 mod 4
+ */
+ pub fn getProvisionalVersionForDimension(dimension: u32) -> Result {
+ if dimension % 4 != 1 {
+ return Err(Exceptions::FormatException(
+ "dimension incorrect".to_owned(),
+ ));
+ }
+ Self::getVersionForNumber((dimension - 17) / 4)
+ // try {
+ // return getVersionForNumber((dimension - 17) / 4);
+ // } catch (IllegalArgumentException ignored) {
+ // throw FormatException.getFormatInstance();
+ // }
+ }
+
+ pub fn getVersionForNumber(versionNumber: u32) -> Result {
+ if versionNumber < 1 || versionNumber > 40 {
+ return Err(Exceptions::IllegalArgumentException(
+ "version out of spec".to_owned(),
+ ));
+ }
+ Ok(VERSIONS[versionNumber as usize - 1])
+ }
+
+ pub fn decodeVersionInformation(versionBits: u32) -> Result {
+ let bestDifference = u32::MAX;
+ let bestVersion = 0;
+ for i in 0..VERSION_DECODE_INFO.len() as u32 {
+ // for (int i = 0; i < VERSION_DECODE_INFO.length; i++) {
+ let targetVersion = VERSION_DECODE_INFO[i as usize];
+ // Do the version info bits match exactly? done.
+ if targetVersion == versionBits {
+ return Self::getVersionForNumber(i + 7);
+ }
+ // Otherwise see if this is the closest to a real version info bit string
+ // we have seen so far
+ let bitsDifference = FormatInformation::numBitsDiffering(versionBits, targetVersion);
+ if bitsDifference < bestDifference {
+ bestVersion = i + 7;
+ bestDifference = bitsDifference;
+ }
+ }
+ // We can tolerate up to 3 bits of error since no two version info codewords will
+ // differ in less than 8 bits.
+ if bestDifference <= 3 {
+ return Self::getVersionForNumber(bestVersion);
+ }
+ // If we didn't find a close enough match, fail
+ Err(Exceptions::NotFoundException("could not find".to_owned()))
+ }
+
+ /**
+ * See ISO 18004:2006 Annex E
+ */
+ pub fn buildFunctionPattern(&self) -> BitMatrix {
+ let dimension = self.getDimensionForVersion();
+ let bitMatrix = BitMatrix::with_single_dimension(dimension);
+
+ // Top left finder pattern + separator + format
+ bitMatrix.setRegion(0, 0, 9, 9);
+ // Top right finder pattern + separator + format
+ bitMatrix.setRegion(dimension - 8, 0, 8, 9);
+ // Bottom left finder pattern + separator + format
+ bitMatrix.setRegion(0, dimension - 8, 9, 8);
+
+ // Alignment patterns
+ let max = self.alignmentPatternCenters.len();
+ for x in 0..max {
+ // for (int x = 0; x < max; x++) {
+ let i = self.alignmentPatternCenters[x] - 2;
+ for y in 0..max {
+ // for (int y = 0; y < max; y++) {
+ if (x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0) {
+ bitMatrix.setRegion(self.alignmentPatternCenters[y] - 2, i, 5, 5);
+ }
+ // else no o alignment patterns near the three finder patterns
+ }
+ }
+
+ // Vertical timing pattern
+ bitMatrix.setRegion(6, 9, 1, dimension - 17);
+ // Horizontal timing pattern
+ bitMatrix.setRegion(9, 6, dimension - 17, 1);
+
+ if self.versionNumber > 6 {
+ // Version info, top right
+ bitMatrix.setRegion(dimension - 11, 0, 3, 6);
+ // Version info, bottom left
+ bitMatrix.setRegion(0, dimension - 11, 6, 3);
+ }
+
+ bitMatrix
+ }
+
+ /**
+ * See ISO 18004:2006 6.5.1 Table 9
+ */
+ pub const fn buildVersions() -> Vec {
+ Vec::from([
+ Version::new(
+ 1,
+ Vec::from([]),
+ Vec::from([
+ ECBlocks::new(7, Vec::from([ECB::new(1, 19)])),
+ ECBlocks::new(10, Vec::from([ECB::new(1, 16)])),
+ ECBlocks::new(13, Vec::from([ECB::new(1, 13)])),
+ ECBlocks::new(17, Vec::from([ECB::new(1, 9)])),
+ ]),
+ ),
+ Version::new(
+ 2,
+ Vec::from([6, 18]),
+ Vec::from([
+ ECBlocks::new(10, Vec::from([ECB::new(1, 34)])),
+ ECBlocks::new(16, Vec::from([ECB::new(1, 28)])),
+ ECBlocks::new(22, Vec::from([ECB::new(1, 22)])),
+ ECBlocks::new(28, Vec::from([ECB::new(1, 16)])),
+ ]),
+ ),
+ Version::new(
+ 3,
+ Vec::from([6, 22]),
+ Vec::from([
+ ECBlocks::new(15, Vec::from([ECB::new(1, 55)])),
+ ECBlocks::new(26, Vec::from([ECB::new(1, 44)])),
+ ECBlocks::new(18, Vec::from([ECB::new(2, 17)])),
+ ECBlocks::new(22, Vec::from([ECB::new(2, 13)])),
+ ]),
+ ),
+ Version::new(
+ 4,
+ Vec::from([6, 26]),
+ Vec::from([
+ ECBlocks::new(20, Vec::from([ECB::new(1, 80)])),
+ ECBlocks::new(18, Vec::from([ECB::new(2, 32)])),
+ ECBlocks::new(26, Vec::from([ECB::new(2, 24)])),
+ ECBlocks::new(16, Vec::from([ECB::new(4, 9)])),
+ ]),
+ ),
+ Version::new(
+ 5,
+ Vec::from([6, 30]),
+ Vec::from([
+ ECBlocks::new(26, Vec::from([ECB::new(1, 108)])),
+ ECBlocks::new(24, Vec::from([ECB::new(2, 43)])),
+ ECBlocks::new(18, Vec::from([ECB::new(2, 15), ECB::new(2, 16)])),
+ ECBlocks::new(22, Vec::from([ECB::new(2, 11), ECB::new(2, 12)])),
+ ]),
+ ),
+ Version::new(
+ 6,
+ Vec::from([6, 34]),
+ Vec::from([
+ ECBlocks::new(18, Vec::from([ECB::new(2, 68)])),
+ ECBlocks::new(16, Vec::from([ECB::new(4, 27)])),
+ ECBlocks::new(24, Vec::from([ECB::new(4, 19)])),
+ ECBlocks::new(28, Vec::from([ECB::new(4, 15)])),
+ ]),
+ ),
+ Version::new(
+ 7,
+ Vec::from([6, 22, 38]),
+ Vec::from([
+ ECBlocks::new(20, Vec::from([ECB::new(2, 78)])),
+ ECBlocks::new(18, Vec::from([ECB::new(4, 31)])),
+ ECBlocks::new(18, Vec::from([ECB::new(2, 14), ECB::new(4, 15)])),
+ ECBlocks::new(26, Vec::from([ECB::new(4, 13), ECB::new(1, 14)])),
+ ]),
+ ),
+ Version::new(
+ 8,
+ Vec::from([6, 24, 42]),
+ Vec::from([
+ ECBlocks::new(24, Vec::from([ECB::new(2, 97)])),
+ ECBlocks::new(22, Vec::from([ECB::new(2, 38), ECB::new(2, 39)])),
+ ECBlocks::new(22, Vec::from([ECB::new(4, 18), ECB::new(2, 19)])),
+ ECBlocks::new(26, Vec::from([ECB::new(4, 14), ECB::new(2, 15)])),
+ ]),
+ ),
+ Version::new(
+ 9,
+ Vec::from([6, 26, 46]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(2, 116)])),
+ ECBlocks::new(22, Vec::from([ECB::new(3, 36), ECB::new(2, 37)])),
+ ECBlocks::new(20, Vec::from([ECB::new(4, 16), ECB::new(4, 17)])),
+ ECBlocks::new(24, Vec::from([ECB::new(4, 12), ECB::new(4, 13)])),
+ ]),
+ ),
+ Version::new(
+ 10,
+ Vec::from([6, 28, 50]),
+ Vec::from([
+ ECBlocks::new(18, Vec::from([ECB::new(2, 68), ECB::new(2, 69)])),
+ ECBlocks::new(26, Vec::from([ECB::new(4, 43), ECB::new(1, 44)])),
+ ECBlocks::new(24, Vec::from([ECB::new(6, 19), ECB::new(2, 20)])),
+ ECBlocks::new(28, Vec::from([ECB::new(6, 15), ECB::new(2, 16)])),
+ ]),
+ ),
+ Version::new(
+ 11,
+ Vec::from([6, 30, 54]),
+ Vec::from([
+ ECBlocks::new(20, Vec::from([ECB::new(4, 81)])),
+ ECBlocks::new(30, Vec::from([ECB::new(1, 50), ECB::new(4, 51)])),
+ ECBlocks::new(28, Vec::from([ECB::new(4, 22), ECB::new(4, 23)])),
+ ECBlocks::new(24, Vec::from([ECB::new(3, 12), ECB::new(8, 13)])),
+ ]),
+ ),
+ Version::new(
+ 12,
+ Vec::from([6, 32, 58]),
+ Vec::from([
+ ECBlocks::new(24, Vec::from([ECB::new(2, 92), ECB::new(2, 93)])),
+ ECBlocks::new(22, Vec::from([ECB::new(6, 36), ECB::new(2, 37)])),
+ ECBlocks::new(26, Vec::from([ECB::new(4, 20), ECB::new(6, 21)])),
+ ECBlocks::new(28, Vec::from([ECB::new(7, 14), ECB::new(4, 15)])),
+ ]),
+ ),
+ Version::new(
+ 13,
+ Vec::from([6, 34, 62]),
+ Vec::from([
+ ECBlocks::new(26, Vec::from([ECB::new(4, 107)])),
+ ECBlocks::new(22, Vec::from([ECB::new(8, 37), ECB::new(1, 38)])),
+ ECBlocks::new(24, Vec::from([ECB::new(8, 20), ECB::new(4, 21)])),
+ ECBlocks::new(22, Vec::from([ECB::new(12, 11), ECB::new(4, 12)])),
+ ]),
+ ),
+ Version::new(
+ 14,
+ Vec::from([6, 26, 46, 66]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(3, 115), ECB::new(1, 116)])),
+ ECBlocks::new(24, Vec::from([ECB::new(4, 40), ECB::new(5, 41)])),
+ ECBlocks::new(20, Vec::from([ECB::new(11, 16), ECB::new(5, 17)])),
+ ECBlocks::new(24, Vec::from([ECB::new(11, 12), ECB::new(5, 13)])),
+ ]),
+ ),
+ Version::new(
+ 15,
+ Vec::from([6, 26, 48, 70]),
+ Vec::from([
+ ECBlocks::new(22, Vec::from([ECB::new(5, 87), ECB::new(1, 88)])),
+ ECBlocks::new(24, Vec::from([ECB::new(5, 41), ECB::new(5, 42)])),
+ ECBlocks::new(30, Vec::from([ECB::new(5, 24), ECB::new(7, 25)])),
+ ECBlocks::new(24, Vec::from([ECB::new(11, 12), ECB::new(7, 13)])),
+ ]),
+ ),
+ Version::new(
+ 16,
+ Vec::from([6, 26, 50, 74]),
+ Vec::from([
+ ECBlocks::new(24, Vec::from([ECB::new(5, 98), ECB::new(1, 99)])),
+ ECBlocks::new(28, Vec::from([ECB::new(7, 45), ECB::new(3, 46)])),
+ ECBlocks::new(24, Vec::from([ECB::new(15, 19), ECB::new(2, 20)])),
+ ECBlocks::new(30, Vec::from([ECB::new(3, 15), ECB::new(13, 16)])),
+ ]),
+ ),
+ Version::new(
+ 17,
+ Vec::from([6, 30, 54, 78]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(1, 107), ECB::new(5, 108)])),
+ ECBlocks::new(28, Vec::from([ECB::new(10, 46), ECB::new(1, 47)])),
+ ECBlocks::new(28, Vec::from([ECB::new(1, 22), ECB::new(15, 23)])),
+ ECBlocks::new(28, Vec::from([ECB::new(2, 14), ECB::new(17, 15)])),
+ ]),
+ ),
+ Version::new(
+ 18,
+ Vec::from([6, 30, 56, 82]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(5, 120), ECB::new(1, 121)])),
+ ECBlocks::new(26, Vec::from([ECB::new(9, 43), ECB::new(4, 44)])),
+ ECBlocks::new(28, Vec::from([ECB::new(17, 22), ECB::new(1, 23)])),
+ ECBlocks::new(28, Vec::from([ECB::new(2, 14), ECB::new(19, 15)])),
+ ]),
+ ),
+ Version::new(
+ 19,
+ Vec::from([6, 30, 58, 86]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(3, 113), ECB::new(4, 114)])),
+ ECBlocks::new(26, Vec::from([ECB::new(3, 44), ECB::new(11, 45)])),
+ ECBlocks::new(26, Vec::from([ECB::new(17, 21), ECB::new(4, 22)])),
+ ECBlocks::new(26, Vec::from([ECB::new(9, 13), ECB::new(16, 14)])),
+ ]),
+ ),
+ Version::new(
+ 20,
+ Vec::from([6, 34, 62, 90]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(3, 107), ECB::new(5, 108)])),
+ ECBlocks::new(26, Vec::from([ECB::new(3, 41), ECB::new(13, 42)])),
+ ECBlocks::new(30, Vec::from([ECB::new(15, 24), ECB::new(5, 25)])),
+ ECBlocks::new(28, Vec::from([ECB::new(15, 15), ECB::new(10, 16)])),
+ ]),
+ ),
+ Version::new(
+ 21,
+ Vec::from([6, 28, 50, 72, 94]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(4, 116), ECB::new(4, 117)])),
+ ECBlocks::new(26, Vec::from([ECB::new(17, 42)])),
+ ECBlocks::new(28, Vec::from([ECB::new(17, 22), ECB::new(6, 23)])),
+ ECBlocks::new(30, Vec::from([ECB::new(19, 16), ECB::new(6, 17)])),
+ ]),
+ ),
+ Version::new(
+ 22,
+ Vec::from([6, 26, 50, 74, 98]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(2, 111), ECB::new(7, 112)])),
+ ECBlocks::new(28, Vec::from([ECB::new(17, 46)])),
+ ECBlocks::new(30, Vec::from([ECB::new(7, 24), ECB::new(16, 25)])),
+ ECBlocks::new(24, Vec::from([ECB::new(34, 13)])),
+ ]),
+ ),
+ Version::new(
+ 23,
+ Vec::from([6, 30, 54, 78, 102]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(4, 121), ECB::new(5, 122)])),
+ ECBlocks::new(28, Vec::from([ECB::new(4, 47), ECB::new(14, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(11, 24), ECB::new(14, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(16, 15), ECB::new(14, 16)])),
+ ]),
+ ),
+ Version::new(
+ 24,
+ Vec::from([6, 28, 54, 80, 106]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(6, 117), ECB::new(4, 118)])),
+ ECBlocks::new(28, Vec::from([ECB::new(6, 45), ECB::new(14, 46)])),
+ ECBlocks::new(30, Vec::from([ECB::new(11, 24), ECB::new(16, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(30, 16), ECB::new(2, 17)])),
+ ]),
+ ),
+ Version::new(
+ 25,
+ Vec::from([6, 32, 58, 84, 110]),
+ Vec::from([
+ ECBlocks::new(26, Vec::from([ECB::new(8, 106), ECB::new(4, 107)])),
+ ECBlocks::new(28, Vec::from([ECB::new(8, 47), ECB::new(13, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(7, 24), ECB::new(22, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(22, 15), ECB::new(13, 16)])),
+ ]),
+ ),
+ Version::new(
+ 26,
+ Vec::from([6, 30, 58, 86, 114]),
+ Vec::from([
+ ECBlocks::new(28, Vec::from([ECB::new(10, 114), ECB::new(2, 115)])),
+ ECBlocks::new(28, Vec::from([ECB::new(19, 46), ECB::new(4, 47)])),
+ ECBlocks::new(28, Vec::from([ECB::new(28, 22), ECB::new(6, 23)])),
+ ECBlocks::new(30, Vec::from([ECB::new(33, 16), ECB::new(4, 17)])),
+ ]),
+ ),
+ Version::new(
+ 27,
+ Vec::from([6, 34, 62, 90, 118]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(8, 122), ECB::new(4, 123)])),
+ ECBlocks::new(28, Vec::from([ECB::new(22, 45), ECB::new(3, 46)])),
+ ECBlocks::new(30, Vec::from([ECB::new(8, 23), ECB::new(26, 24)])),
+ ECBlocks::new(30, Vec::from([ECB::new(12, 15), ECB::new(28, 16)])),
+ ]),
+ ),
+ Version::new(
+ 28,
+ Vec::from([6, 26, 50, 74, 98, 122]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(3, 117), ECB::new(10, 118)])),
+ ECBlocks::new(28, Vec::from([ECB::new(3, 45), ECB::new(23, 46)])),
+ ECBlocks::new(30, Vec::from([ECB::new(4, 24), ECB::new(31, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(11, 15), ECB::new(31, 16)])),
+ ]),
+ ),
+ Version::new(
+ 29,
+ Vec::from([6, 30, 54, 78, 102, 126]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(7, 116), ECB::new(7, 117)])),
+ ECBlocks::new(28, Vec::from([ECB::new(21, 45), ECB::new(7, 46)])),
+ ECBlocks::new(30, Vec::from([ECB::new(1, 23), ECB::new(37, 24)])),
+ ECBlocks::new(30, Vec::from([ECB::new(19, 15), ECB::new(26, 16)])),
+ ]),
+ ),
+ Version::new(
+ 30,
+ Vec::from([6, 26, 52, 78, 104, 130]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(5, 115), ECB::new(10, 116)])),
+ ECBlocks::new(28, Vec::from([ECB::new(19, 47), ECB::new(10, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(15, 24), ECB::new(25, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(23, 15), ECB::new(25, 16)])),
+ ]),
+ ),
+ Version::new(
+ 31,
+ Vec::from([6, 30, 56, 82, 108, 134]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(13, 115), ECB::new(3, 116)])),
+ ECBlocks::new(28, Vec::from([ECB::new(2, 46), ECB::new(29, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(42, 24), ECB::new(1, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(23, 15), ECB::new(28, 16)])),
+ ]),
+ ),
+ Version::new(
+ 32,
+ Vec::from([6, 34, 60, 86, 112, 138]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(17, 115)])),
+ ECBlocks::new(28, Vec::from([ECB::new(10, 46), ECB::new(23, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(10, 24), ECB::new(35, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(19, 15), ECB::new(35, 16)])),
+ ]),
+ ),
+ Version::new(
+ 33,
+ Vec::from([6, 30, 58, 86, 114, 142]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(17, 115), ECB::new(1, 116)])),
+ ECBlocks::new(28, Vec::from([ECB::new(14, 46), ECB::new(21, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(29, 24), ECB::new(19, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(11, 15), ECB::new(46, 16)])),
+ ]),
+ ),
+ Version::new(
+ 34,
+ Vec::from([6, 34, 62, 90, 118, 146]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(13, 115), ECB::new(6, 116)])),
+ ECBlocks::new(28, Vec::from([ECB::new(14, 46), ECB::new(23, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(44, 24), ECB::new(7, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(59, 16), ECB::new(1, 17)])),
+ ]),
+ ),
+ Version::new(
+ 35,
+ Vec::from([6, 30, 54, 78, 102, 126, 150]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(12, 121), ECB::new(7, 122)])),
+ ECBlocks::new(28, Vec::from([ECB::new(12, 47), ECB::new(26, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(39, 24), ECB::new(14, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(22, 15), ECB::new(41, 16)])),
+ ]),
+ ),
+ Version::new(
+ 36,
+ Vec::from([6, 24, 50, 76, 102, 128, 154]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(6, 121), ECB::new(14, 122)])),
+ ECBlocks::new(28, Vec::from([ECB::new(6, 47), ECB::new(34, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(46, 24), ECB::new(10, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(2, 15), ECB::new(64, 16)])),
+ ]),
+ ),
+ Version::new(
+ 37,
+ Vec::from([6, 28, 54, 80, 106, 132, 158]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(17, 122), ECB::new(4, 123)])),
+ ECBlocks::new(28, Vec::from([ECB::new(29, 46), ECB::new(14, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(49, 24), ECB::new(10, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(24, 15), ECB::new(46, 16)])),
+ ]),
+ ),
+ Version::new(
+ 38,
+ Vec::from([6, 32, 58, 84, 110, 136, 162]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(4, 122), ECB::new(18, 123)])),
+ ECBlocks::new(28, Vec::from([ECB::new(13, 46), ECB::new(32, 47)])),
+ ECBlocks::new(30, Vec::from([ECB::new(48, 24), ECB::new(14, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(42, 15), ECB::new(32, 16)])),
+ ]),
+ ),
+ Version::new(
+ 39,
+ Vec::from([6, 26, 54, 82, 110, 138, 166]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(20, 117), ECB::new(4, 118)])),
+ ECBlocks::new(28, Vec::from([ECB::new(40, 47), ECB::new(7, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(43, 24), ECB::new(22, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(10, 15), ECB::new(67, 16)])),
+ ]),
+ ),
+ Version::new(
+ 40,
+ Vec::from([6, 30, 58, 86, 114, 142, 170]),
+ Vec::from([
+ ECBlocks::new(30, Vec::from([ECB::new(19, 118), ECB::new(6, 119)])),
+ ECBlocks::new(28, Vec::from([ECB::new(18, 47), ECB::new(31, 48)])),
+ ECBlocks::new(30, Vec::from([ECB::new(34, 24), ECB::new(34, 25)])),
+ ECBlocks::new(30, Vec::from([ECB::new(20, 15), ECB::new(61, 16)])),
+ ]),
+ ),
+ ]) /*
+ new Version(4, new int[]{6, 26},
+ new ECBlocks(20, new ECB::new(1, 80)),
+ new ECBlocks(18, new ECB::new(2, 32)),
+ new ECBlocks(26, new ECB::new(2, 24)),
+ new ECBlocks(16, new ECB::new(4, 9))),
+ new Version(5, new int[]{6, 30},
+ new ECBlocks(26, new ECB::new(1, 108)),
+ new ECBlocks(24, new ECB::new(2, 43)),
+ new ECBlocks(18, new ECB::new(2, 15),
+ new ECB::new(2, 16)),
+ new ECBlocks(22, new ECB::new(2, 11),
+ new ECB::new(2, 12))),
+ new Version(6, new int[]{6, 34},
+ new ECBlocks(18, new ECB::new(2, 68)),
+ new ECBlocks(16, new ECB::new(4, 27)),
+ new ECBlocks(24, new ECB::new(4, 19)),
+ new ECBlocks(28, new ECB::new(4, 15))),
+ new Version(7, new int[]{6, 22, 38},
+ new ECBlocks(20, new ECB::new(2, 78)),
+ new ECBlocks(18, new ECB::new(4, 31)),
+ new ECBlocks(18, new ECB::new(2, 14),
+ new ECB::new(4, 15)),
+ new ECBlocks(26, new ECB::new(4, 13),
+ new ECB::new(1, 14))),
+ new Version(8, new int[]{6, 24, 42},
+ new ECBlocks(24, new ECB::new(2, 97)),
+ new ECBlocks(22, new ECB::new(2, 38),
+ new ECB::new(2, 39)),
+ new ECBlocks(22, new ECB::new(4, 18),
+ new ECB::new(2, 19)),
+ new ECBlocks(26, new ECB::new(4, 14),
+ new ECB::new(2, 15))),
+ new Version(9, new int[]{6, 26, 46},
+ new ECBlocks(30, new ECB::new(2, 116)),
+ new ECBlocks(22, new ECB::new(3, 36),
+ new ECB::new(2, 37)),
+ new ECBlocks(20, new ECB::new(4, 16),
+ new ECB::new(4, 17)),
+ new ECBlocks(24, new ECB::new(4, 12),
+ new ECB::new(4, 13))),
+ new Version(10, new int[]{6, 28, 50},
+ new ECBlocks(18, new ECB::new(2, 68),
+ new ECB::new(2, 69)),
+ new ECBlocks(26, new ECB::new(4, 43),
+ new ECB::new(1, 44)),
+ new ECBlocks(24, new ECB::new(6, 19),
+ new ECB::new(2, 20)),
+ new ECBlocks(28, new ECB::new(6, 15),
+ new ECB::new(2, 16))),
+ new Version(11, new int[]{6, 30, 54},
+ new ECBlocks(20, new ECB::new(4, 81)),
+ new ECBlocks(30, new ECB::new(1, 50),
+ new ECB::new(4, 51)),
+ new ECBlocks(28, new ECB::new(4, 22),
+ new ECB::new(4, 23)),
+ new ECBlocks(24, new ECB::new(3, 12),
+ new ECB::new(8, 13))),
+ new Version(12, new int[]{6, 32, 58},
+ new ECBlocks(24, new ECB::new(2, 92),
+ new ECB::new(2, 93)),
+ new ECBlocks(22, new ECB::new(6, 36),
+ new ECB::new(2, 37)),
+ new ECBlocks(26, new ECB::new(4, 20),
+ new ECB::new(6, 21)),
+ new ECBlocks(28, new ECB::new(7, 14),
+ new ECB::new(4, 15))),
+ new Version(13, new int[]{6, 34, 62},
+ new ECBlocks(26, new ECB::new(4, 107)),
+ new ECBlocks(22, new ECB::new(8, 37),
+ new ECB::new(1, 38)),
+ new ECBlocks(24, new ECB::new(8, 20),
+ new ECB::new(4, 21)),
+ new ECBlocks(22, new ECB::new(12, 11),
+ new ECB::new(4, 12))),
+ new Version(14, new int[]{6, 26, 46, 66},
+ new ECBlocks(30, new ECB::new(3, 115),
+ new ECB::new(1, 116)),
+ new ECBlocks(24, new ECB::new(4, 40),
+ new ECB::new(5, 41)),
+ new ECBlocks(20, new ECB::new(11, 16),
+ new ECB::new(5, 17)),
+ new ECBlocks(24, new ECB::new(11, 12),
+ new ECB::new(5, 13))),
+ new Version(15, new int[]{6, 26, 48, 70},
+ new ECBlocks(22, new ECB::new(5, 87),
+ new ECB::new(1, 88)),
+ new ECBlocks(24, new ECB::new(5, 41),
+ new ECB::new(5, 42)),
+ new ECBlocks(30, new ECB::new(5, 24),
+ new ECB::new(7, 25)),
+ new ECBlocks(24, new ECB::new(11, 12),
+ new ECB::new(7, 13))),
+ new Version(16, new int[]{6, 26, 50, 74},
+ new ECBlocks(24, new ECB::new(5, 98),
+ new ECB::new(1, 99)),
+ new ECBlocks(28, new ECB::new(7, 45),
+ new ECB::new(3, 46)),
+ new ECBlocks(24, new ECB::new(15, 19),
+ new ECB::new(2, 20)),
+ new ECBlocks(30, new ECB::new(3, 15),
+ new ECB::new(13, 16))),
+ new Version(17, new int[]{6, 30, 54, 78},
+ new ECBlocks(28, new ECB::new(1, 107),
+ new ECB::new(5, 108)),
+ new ECBlocks(28, new ECB::new(10, 46),
+ new ECB::new(1, 47)),
+ new ECBlocks(28, new ECB::new(1, 22),
+ new ECB::new(15, 23)),
+ new ECBlocks(28, new ECB::new(2, 14),
+ new ECB::new(17, 15))),
+ new Version(18, new int[]{6, 30, 56, 82},
+ new ECBlocks(30, new ECB::new(5, 120),
+ new ECB::new(1, 121)),
+ new ECBlocks(26, new ECB::new(9, 43),
+ new ECB::new(4, 44)),
+ new ECBlocks(28, new ECB::new(17, 22),
+ new ECB::new(1, 23)),
+ new ECBlocks(28, new ECB::new(2, 14),
+ new ECB::new(19, 15))),
+ new Version(19, new int[]{6, 30, 58, 86},
+ new ECBlocks(28, new ECB::new(3, 113),
+ new ECB::new(4, 114)),
+ new ECBlocks(26, new ECB::new(3, 44),
+ new ECB::new(11, 45)),
+ new ECBlocks(26, new ECB::new(17, 21),
+ new ECB::new(4, 22)),
+ new ECBlocks(26, new ECB::new(9, 13),
+ new ECB::new(16, 14))),
+ new Version(20, new int[]{6, 34, 62, 90},
+ new ECBlocks(28, new ECB::new(3, 107),
+ new ECB::new(5, 108)),
+ new ECBlocks(26, new ECB::new(3, 41),
+ new ECB::new(13, 42)),
+ new ECBlocks(30, new ECB::new(15, 24),
+ new ECB::new(5, 25)),
+ new ECBlocks(28, new ECB::new(15, 15),
+ new ECB::new(10, 16))),
+ new Version(21, new int[]{6, 28, 50, 72, 94},
+ new ECBlocks(28, new ECB::new(4, 116),
+ new ECB::new(4, 117)),
+ new ECBlocks(26, new ECB::new(17, 42)),
+ new ECBlocks(28, new ECB::new(17, 22),
+ new ECB::new(6, 23)),
+ new ECBlocks(30, new ECB::new(19, 16),
+ new ECB::new(6, 17))),
+ new Version(22, new int[]{6, 26, 50, 74, 98},
+ new ECBlocks(28, new ECB::new(2, 111),
+ new ECB::new(7, 112)),
+ new ECBlocks(28, new ECB::new(17, 46)),
+ new ECBlocks(30, new ECB::new(7, 24),
+ new ECB::new(16, 25)),
+ new ECBlocks(24, new ECB::new(34, 13))),
+ new Version(23, new int[]{6, 30, 54, 78, 102},
+ new ECBlocks(30, new ECB::new(4, 121),
+ new ECB::new(5, 122)),
+ new ECBlocks(28, new ECB::new(4, 47),
+ new ECB::new(14, 48)),
+ new ECBlocks(30, new ECB::new(11, 24),
+ new ECB::new(14, 25)),
+ new ECBlocks(30, new ECB::new(16, 15),
+ new ECB::new(14, 16))),
+ new Version(24, new int[]{6, 28, 54, 80, 106},
+ new ECBlocks(30, new ECB::new(6, 117),
+ new ECB::new(4, 118)),
+ new ECBlocks(28, new ECB::new(6, 45),
+ new ECB::new(14, 46)),
+ new ECBlocks(30, new ECB::new(11, 24),
+ new ECB::new(16, 25)),
+ new ECBlocks(30, new ECB::new(30, 16),
+ new ECB::new(2, 17))),
+ new Version(25, new int[]{6, 32, 58, 84, 110},
+ new ECBlocks(26, new ECB::new(8, 106),
+ new ECB::new(4, 107)),
+ new ECBlocks(28, new ECB::new(8, 47),
+ new ECB::new(13, 48)),
+ new ECBlocks(30, new ECB::new(7, 24),
+ new ECB::new(22, 25)),
+ new ECBlocks(30, new ECB::new(22, 15),
+ new ECB::new(13, 16))),
+ new Version(26, new int[]{6, 30, 58, 86, 114},
+ new ECBlocks(28, new ECB::new(10, 114),
+ new ECB::new(2, 115)),
+ new ECBlocks(28, new ECB::new(19, 46),
+ new ECB::new(4, 47)),
+ new ECBlocks(28, new ECB::new(28, 22),
+ new ECB::new(6, 23)),
+ new ECBlocks(30, new ECB::new(33, 16),
+ new ECB::new(4, 17))),
+ new Version(27, new int[]{6, 34, 62, 90, 118},
+ new ECBlocks(30, new ECB::new(8, 122),
+ new ECB::new(4, 123)),
+ new ECBlocks(28, new ECB::new(22, 45),
+ new ECB::new(3, 46)),
+ new ECBlocks(30, new ECB::new(8, 23),
+ new ECB::new(26, 24)),
+ new ECBlocks(30, new ECB::new(12, 15),
+ new ECB::new(28, 16))),
+ new Version(28, new int[]{6, 26, 50, 74, 98, 122},
+ new ECBlocks(30, new ECB::new(3, 117),
+ new ECB::new(10, 118)),
+ new ECBlocks(28, new ECB::new(3, 45),
+ new ECB::new(23, 46)),
+ new ECBlocks(30, new ECB::new(4, 24),
+ new ECB::new(31, 25)),
+ new ECBlocks(30, new ECB::new(11, 15),
+ new ECB::new(31, 16))),
+ new Version(29, new int[]{6, 30, 54, 78, 102, 126},
+ new ECBlocks(30, new ECB::new(7, 116),
+ new ECB::new(7, 117)),
+ new ECBlocks(28, new ECB::new(21, 45),
+ new ECB::new(7, 46)),
+ new ECBlocks(30, new ECB::new(1, 23),
+ new ECB::new(37, 24)),
+ new ECBlocks(30, new ECB::new(19, 15),
+ new ECB::new(26, 16))),
+ new Version(30, new int[]{6, 26, 52, 78, 104, 130},
+ new ECBlocks(30, new ECB::new(5, 115),
+ new ECB::new(10, 116)),
+ new ECBlocks(28, new ECB::new(19, 47),
+ new ECB::new(10, 48)),
+ new ECBlocks(30, new ECB::new(15, 24),
+ new ECB::new(25, 25)),
+ new ECBlocks(30, new ECB::new(23, 15),
+ new ECB::new(25, 16))),
+ new Version(31, new int[]{6, 30, 56, 82, 108, 134},
+ new ECBlocks(30, new ECB::new(13, 115),
+ new ECB::new(3, 116)),
+ new ECBlocks(28, new ECB::new(2, 46),
+ new ECB::new(29, 47)),
+ new ECBlocks(30, new ECB::new(42, 24),
+ new ECB::new(1, 25)),
+ new ECBlocks(30, new ECB::new(23, 15),
+ new ECB::new(28, 16))),
+ new Version(32, new int[]{6, 34, 60, 86, 112, 138},
+ new ECBlocks(30, new ECB::new(17, 115)),
+ new ECBlocks(28, new ECB::new(10, 46),
+ new ECB::new(23, 47)),
+ new ECBlocks(30, new ECB::new(10, 24),
+ new ECB::new(35, 25)),
+ new ECBlocks(30, new ECB::new(19, 15),
+ new ECB::new(35, 16))),
+ new Version(33, new int[]{6, 30, 58, 86, 114, 142},
+ new ECBlocks(30, new ECB::new(17, 115),
+ new ECB::new(1, 116)),
+ new ECBlocks(28, new ECB::new(14, 46),
+ new ECB::new(21, 47)),
+ new ECBlocks(30, new ECB::new(29, 24),
+ new ECB::new(19, 25)),
+ new ECBlocks(30, new ECB::new(11, 15),
+ new ECB::new(46, 16))),
+ new Version(34, new int[]{6, 34, 62, 90, 118, 146},
+ new ECBlocks(30, new ECB::new(13, 115),
+ new ECB::new(6, 116)),
+ new ECBlocks(28, new ECB::new(14, 46),
+ new ECB::new(23, 47)),
+ new ECBlocks(30, new ECB::new(44, 24),
+ new ECB::new(7, 25)),
+ new ECBlocks(30, new ECB::new(59, 16),
+ new ECB::new(1, 17))),
+ new Version(35, new int[]{6, 30, 54, 78, 102, 126, 150},
+ new ECBlocks(30, new ECB::new(12, 121),
+ new ECB::new(7, 122)),
+ new ECBlocks(28, new ECB::new(12, 47),
+ new ECB::new(26, 48)),
+ new ECBlocks(30, new ECB::new(39, 24),
+ new ECB::new(14, 25)),
+ new ECBlocks(30, new ECB::new(22, 15),
+ new ECB::new(41, 16))),
+ new Version(36, new int[]{6, 24, 50, 76, 102, 128, 154},
+ new ECBlocks(30, new ECB::new(6, 121),
+ new ECB::new(14, 122)),
+ new ECBlocks(28, new ECB::new(6, 47),
+ new ECB::new(34, 48)),
+ new ECBlocks(30, new ECB::new(46, 24),
+ new ECB::new(10, 25)),
+ new ECBlocks(30, new ECB::new(2, 15),
+ new ECB::new(64, 16))),
+ new Version(37, new int[]{6, 28, 54, 80, 106, 132, 158},
+ new ECBlocks(30, new ECB::new(17, 122),
+ new ECB::new(4, 123)),
+ new ECBlocks(28, new ECB::new(29, 46),
+ new ECB::new(14, 47)),
+ new ECBlocks(30, new ECB::new(49, 24),
+ new ECB::new(10, 25)),
+ new ECBlocks(30, new ECB::new(24, 15),
+ new ECB::new(46, 16))),
+ new Version(38, new int[]{6, 32, 58, 84, 110, 136, 162},
+ new ECBlocks(30, new ECB::new(4, 122),
+ new ECB::new(18, 123)),
+ new ECBlocks(28, new ECB::new(13, 46),
+ new ECB::new(32, 47)),
+ new ECBlocks(30, new ECB::new(48, 24),
+ new ECB::new(14, 25)),
+ new ECBlocks(30, new ECB::new(42, 15),
+ new ECB::new(32, 16))),
+ new Version(39, new int[]{6, 26, 54, 82, 110, 138, 166},
+ new ECBlocks(30, new ECB::new(20, 117),
+ new ECB::new(4, 118)),
+ new ECBlocks(28, new ECB::new(40, 47),
+ new ECB::new(7, 48)),
+ new ECBlocks(30, new ECB::new(43, 24),
+ new ECB::new(22, 25)),
+ new ECBlocks(30, new ECB::new(10, 15),
+ new ECB::new(67, 16))),
+ new Version(40, new int[]{6, 30, 58, 86, 114, 142, 170},
+ new ECBlocks(30, new ECB::new(19, 118),
+ new ECB::new(6, 119)),
+ new ECBlocks(28, new ECB::new(18, 47),
+ new ECB::new(31, 48)),
+ new ECBlocks(30, new ECB::new(34, 24),
+ new ECB::new(34, 25)),
+ new ECBlocks(30, new ECB::new(20, 15),
+ new ECB::new(61, 16)))
+ ]*/
+ }
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{}", self.versionNumber)
+ write!(f, "{}", self.versionNumber)
}
}
- /**
- * Encapsulates a set of error-correction blocks in one symbol version. Most versions will
- * use blocks of differing sizes within one version, so, this encapsulates the parameters for
- * each set of blocks. It also holds the number of error-correction codewords per block since it
- * will be the same across all blocks within one version.
- */
- pub struct ECBlocks {
- ecCodewordsPerBlock:u32,
- ecBlocks:Vec,
- }
+/**
+ * Encapsulates a set of error-correction blocks in one symbol version. Most versions will
+ * use blocks of differing sizes within one version, so, this encapsulates the parameters for
+ * each set of blocks. It also holds the number of error-correction codewords per block since it
+ * will be the same across all blocks within one version.
+ */
+pub struct ECBlocks {
+ ecCodewordsPerBlock: u32,
+ ecBlocks: Vec,
+}
- impl ECBlocks {
-
- pub const fn new(ecCodewordsPerBlock:u32, ecBlocks:Vec)-> Self {
- Self{
+impl ECBlocks {
+ pub const fn new(ecCodewordsPerBlock: u32, ecBlocks: Vec) -> Self {
+ Self {
ecCodewordsPerBlock,
- ecBlocks
+ ecBlocks,
}
}
pub fn getECCodewordsPerBlock(&self) -> u32 {
- self. ecCodewordsPerBlock
+ self.ecCodewordsPerBlock
}
pub fn getNumBlocks(&self) -> u32 {
- let total = 0;
- for ecBlock in self.ecBlocks {
- // for (ECB ecBlock : ecBlocks) {
- total += ecBlock.getCount();
- }
- total
+ let total = 0;
+ for ecBlock in self.ecBlocks {
+ // for (ECB ecBlock : ecBlocks) {
+ total += ecBlock.getCount();
+ }
+ total
}
- pub fn getTotalECCodewords(&self) -> u32{
- self.ecCodewordsPerBlock * self.getNumBlocks()
+ pub fn getTotalECCodewords(&self) -> u32 {
+ self.ecCodewordsPerBlock * self.getNumBlocks()
}
pub fn getECBlocks(&self) -> &[ECB] {
- &self.ecBlocks
+ &self.ecBlocks
}
- }
+}
- /**
- * Encapsulates the parameters for one error-correction block in one symbol version.
- * This includes the number of data codewords, and the number of times a block with these
- * parameters is used consecutively in the QR code version's format.
- */
- pub struct ECB {
- count:u32,
- dataCodewords:u32,
- }
+/**
+ * Encapsulates the parameters for one error-correction block in one symbol version.
+ * This includes the number of data codewords, and the number of times a block with these
+ * parameters is used consecutively in the QR code version's format.
+ */
+pub struct ECB {
+ count: u32,
+ dataCodewords: u32,
+}
- impl ECB {
- pub const fn new(count:u32, dataCodewords:u32) -> Self {
- Self{
+impl ECB {
+ pub const fn new(count: u32, dataCodewords: u32) -> Self {
+ Self {
count,
- dataCodewords
+ dataCodewords,
}
}
pub fn getCount(&self) -> u32 {
- self.count
+ self.count
}
pub fn getDataCodewords(&self) -> u32 {
- self.dataCodewords
+ self.dataCodewords
}
- }
\ No newline at end of file
+}
diff --git a/src/qrcode/encoder/qr_code.rs b/src/qrcode/encoder/qr_code.rs
index f577453..c3b319a 100644
--- a/src/qrcode/encoder/qr_code.rs
+++ b/src/qrcode/encoder/qr_code.rs
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+use crate::qrcode::decoder::{Mode, ErrorCorrectionLevel, Version};
+
const NUM_MASK_PATTERNS : u32 = 8;
/**