Esempio n. 1
0
        public static VersionCheckStatus VersionCheck(int versionNum, int numDataBits, Mode mode, ErrorCorrectionLevel level, string encodingName)
        {
            int    TotalDataBits = numDataBits;
            ECISet eciSet        = new ECISet(ECISet.AppendOption.NameToValue);

            if (mode == Mode.EightBitByte)
            {
                if (encodingName != DEFAULT_ENCODING)
                {
                    int eciValue = eciSet.GetECIValueByName(encodingName);
                    TotalDataBits += ECISet.NumOfECIHeaderBits(eciValue);
                }
            }
            int bitCharCountIndicator = CharCountIndicatorTable.GetBitCountInCharCountIndicator(mode, versionNum);

            TotalDataBits += (4 + bitCharCountIndicator);

            int expectContainer = DataBits(versionNum, level);
            int lowerContainer  = versionNum == 1 ? 0 : DataBits(versionNum - 1, level);

            if (expectContainer < TotalDataBits)
            {
                return(VersionCheckStatus.SmallerThanExpect);
            }
            else if (lowerContainer >= TotalDataBits)
            {
                return(VersionCheckStatus.LargerThanExpect);
            }
            else
            {
                return(VersionCheckStatus.Efficient);
            }
        }
Esempio n. 2
0
 protected override int GetBitCountInCharCountIndicator(int version) => CharCountIndicatorTable.GetBitCountInCharCountIndicator(version);