getSize method
returns the size in bits
Implementation
int getSize(Version version) {
int size = 4 + mode.getCharacterCountBits(version);
switch (mode) {
case Mode.kanji:
size += 13 * characterLength;
break;
case Mode.alphanumeric:
size += (characterLength ~/ 2) * 11;
size += (characterLength % 2) == 1 ? 6 : 0;
break;
case Mode.numeric:
size += (characterLength ~/ 3) * 10;
final rest = characterLength % 3;
size += rest == 1
? 4
: rest == 2
? 7
: 0;
break;
case Mode.byte:
size += 8 * getCharacterCountIndicator();
break;
case Mode.eci:
size +=
8; // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long
}
return size;
}