Beispiel #1
0
        /// <summary>
        /// Fills the VC struct.
        /// </summary>
        /// <param name="versionNum">The version num.</param>
        /// <param name="level">The level.</param>
        /// <param name="encodingName">Name of the encoding.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        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));
            }

            var 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;

            var vcDetail = new VersionDetail(version, numTotalBytes, numDataBytes, numECBlocks);

            vcStruct.VersionDetail = vcDetail;
            return(vcStruct);
        }