internal QRCodeVersion(int versionNum, int totalCodewords, ErrorCorrectionBlocks ecblocksL, ErrorCorrectionBlocks ecblocksM, ErrorCorrectionBlocks ecblocksQ, ErrorCorrectionBlocks ecblocksH) : this() { VersionNum = versionNum; TotalCodewords = totalCodewords; ECBlocks = new ErrorCorrectionBlocks[] { ecblocksL, ecblocksM, ecblocksQ, ecblocksH }; DimensionForVersion = 17 + (versionNum * 4); }
private static string ErrorCorrectionBlocksToString(ErrorCorrectionBlocks ecBlocks) { ErrorCorrectionBlock[] ecBlock = ecBlocks.GetECBlocks(); string returnValue = ""; foreach(ErrorCorrectionBlock ecb in ecBlock) { returnValue = string.Join(s_Separator, returnValue, ecb.NumErrorCorrectionBlock, ecb.NumDataCodewords); } return returnValue; }
private static VersionControlStruct FillVCStruct(int versionNum, ErrorCorrectionLevel level) { if (versionNum < 1 || versionNum > 40) { throw new InvalidOperationException($"Unexpected version number: {versionNum}"); } VersionControlStruct vcStruct = new VersionControlStruct(); int version = versionNum; QRCodeVersion versionData = VersionTable.GetVersionByNum(versionNum); int numTotalBytes = versionData.TotalCodewords; ErrorCorrectionBlocks ecBlocks = versionData.GetECBlocksByLevel(level); int numDataBytes = numTotalBytes - ecBlocks.NumErrorCorrectionCodewards; int numECBlocks = ecBlocks.NumBlocks; VersionDetail vcDetail = new VersionDetail(version, numTotalBytes, numDataBytes, numECBlocks); vcStruct.VersionDetail = vcDetail; return(vcStruct); }