readFormatInformation method

UQrFormatInformation readFormatInformation()

Implementation

UQrFormatInformation readFormatInformation() {
  final UQrFormatInformation? cached = _formatInfo;
  if (cached != null) return cached;

  int formatInfoBits1 = 0;
  for (int i = 0; i < 6; i++) {
    formatInfoBits1 = _copyBit(i, 8, formatInfoBits1);
  }
  formatInfoBits1 = _copyBit(7, 8, formatInfoBits1);
  formatInfoBits1 = _copyBit(8, 8, formatInfoBits1);
  formatInfoBits1 = _copyBit(8, 7, formatInfoBits1);
  for (int j = 5; j >= 0; j--) {
    formatInfoBits1 = _copyBit(8, j, formatInfoBits1);
  }

  final int dimension = _bits.height;
  int formatInfoBits2 = 0;
  final int jMin = dimension - 7;
  for (int j = dimension - 1; j >= jMin; j--) {
    formatInfoBits2 = _copyBit(8, j, formatInfoBits2);
  }
  for (int i = dimension - 8; i < dimension; i++) {
    formatInfoBits2 = _copyBit(i, 8, formatInfoBits2);
  }

  final UQrFormatInformation? parsed = UQrFormatInformation.decode(formatInfoBits1, formatInfoBits2);
  if (parsed == null) throw const UCodeDecodeException("Unreadable QR format information");
  _formatInfo = parsed;
  return parsed;
}