Esempio n. 1
0
        /// <summary>
        /// Gets the format info bits.
        /// </summary>
        /// <param name="errorlevel">The errorlevel.</param>
        /// <param name="pattern">The pattern.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private static BitList GetFormatInfoBits(ErrorCorrectionLevel errorlevel, Pattern pattern)
        {
            var formatInfo = (int)pattern.MaskPatternType;

            //Pattern bits length = 3
            formatInfo |= GetErrorCorrectionIndicatorBits(errorlevel) << 3;

            int bchCode = BCHCalculator.CalculateBCH(formatInfo, s_FormatInfoPoly);

            //bchCode length = 10
            formatInfo = (formatInfo << 10) | bchCode;

            //xor maskPattern
            formatInfo ^= s_FormatInfoMaskPattern;

            var resultBits = new BitList();

            resultBits.Add(formatInfo, 15);

            if (resultBits.Count != 15)
            {
                throw new Exception("FormatInfoBits length is not 15");
            }
            else
            {
                return(resultBits);
            }
        }
        /// <summary>
        /// Versions the info bit list.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private static BitList VersionInfoBitList(int version)
        {
            var result = new BitList();

            result.Add(version, s_LengthDataBits);
            result.Add(BCHCalculator.CalculateBCH(version, s_VersionBCHPoly), s_LengthECBits);

            if (result.Count != (s_LengthECBits + s_LengthDataBits))
            {
                throw new Exception("Version Info creation error. Result is not 18 bits");
            }
            return(result);
        }