private static int chooseMaskPattern(BitList bits, QRCorrectionLevel correctionLevel, QRVersion version, QRMatrix matrix) { int minPenalty = Int32.MaxValue; // Assume the lowest possible penalty int bestMaskPattern = -1; // Calculate all mask paterns to find the pattern with minimum possible penalty for (int maskPattern = 0; maskPattern < MASK_PATTERNS_QTY; maskPattern++) { matrix.FormMatrix(bits, correctionLevel, version, maskPattern); int penalty = matrix.GetMaskPenalty(); if (penalty < minPenalty) { minPenalty = penalty; bestMaskPattern = maskPattern; } } return(bestMaskPattern); }
private static QRVersion chooseVersion(int numInputBits, QRCorrectionLevel ecLevel) { for (int versionNum = 1; versionNum <= 40; versionNum++) { QRVersion version = QRVersion.GetVersionByNumber(versionNum); int numBytes = version.TotalCodewords; QRVersion.CorrectionBlockSet correctionBlocks = version.GetBlockSetByLevel(ecLevel); int numEcBytes = correctionBlocks.TotalCodewords; int numDataBytes = numBytes - numEcBytes; int totalInputBytes = (numInputBits + 7) / 8; if (numDataBytes >= totalInputBytes) { return(version); } } throw new AzosException(StringConsts.CODE_LOGIC_ERROR + typeof(QREncoderMatrix).Name + ".chooseVersion(data)"); }
public static QREncoderMatrix CreateMatrix(string content, QRCorrectionLevel correctionLevel) { QREncoderMatrix matrix = Encode(content, correctionLevel); return(matrix); }
public CorrectionBlockSet GetBlockSetByLevel(QRCorrectionLevel level) { return(m_CorrectionBlockSets[level.Ordinal]); }