ZXing.QrCode.Internal.Mode.getCharacterCountBits C# (CSharp) Method

getCharacterCountBits() public method

public getCharacterCountBits ( Version version ) : int
version Version version in question ///
return int
        public int getCharacterCountBits(Version version)
        {
            if (characterCountBitsForVersions == null)
             {
            throw new System.ArgumentException("Character count doesn't apply to this mode");
             }
             int number = version.VersionNumber;
             int offset;
             if (number <= 9)
             {
            offset = 0;
             }
             else if (number <= 26)
             {
            offset = 1;
             }
             else
             {
            offset = 2;
             }
             return characterCountBitsForVersions[offset];
        }

Usage Example

                /// <summary>
                /// returns the size in bits
                /// </summary>
                /// <returns></returns>
                public int getSize(Version version)
                {
                    int size = 4 + mode.getCharacterCountBits(resultList.version);

                    switch (mode.Name)
                    {
                    case Mode.Names.KANJI:
                        size += 13 * characterLength;
                        break;

                    case Mode.Names.ALPHANUMERIC:
                        size += (characterLength / 2) * 11;
                        size += (characterLength % 2) == 1 ? 6 : 0;
                        break;

                    case Mode.Names.NUMERIC:
                        size += (characterLength / 3) * 10;
                        int rest = characterLength % 3;
                        size += rest == 1 ? 4 : rest == 2 ? 7 : 0;
                        break;

                    case Mode.Names.BYTE:
                        size += 8 * CharacterCountIndicator;
                        break;

                    case Mode.Names.ECI:
                        size += 8;     // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long
                        break;
                    }
                    return(size);
                }
All Usage Examples Of ZXing.QrCode.Internal.Mode::getCharacterCountBits