Example #1
0
        public static VersionTableTestProperties GetVersionInfo(int versionNum, ErrorCorrectionLevel level)
        {
            Version version                = VersionTable.GetVersionByNum(versionNum);
            int     totalNumCodewords      = version.TotalCodewords;
            ErrorCorrectionBlocks ecBlocks = version.GetECBlocksByLevel(level);
            int    numECCodewords          = ecBlocks.NumErrorCorrectionCodewards;
            string ecBlockString           = ErrorCorrectionBlocksToString(ecBlocks);

            return(new VersionTableTestProperties(versionNum, totalNumCodewords, level, numECCodewords, ecBlockString));
        }
Example #2
0
        private static VersionControlStruct FillVCStruct(int versionNum, ErrorCorrectionLevel level, string encodingName)
        {
            if (versionNum < 1 || versionNum > 40)
            {
                throw new InvalidOperationException(string.Format("Unexpected version number: {0}", 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);
        }