maybeEmbedVersionInfo static method

void maybeEmbedVersionInfo(
  1. Version version,
  2. ByteMatrix matrix
)

Implementation

static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) {
  if (version.versionNumber < 7) {
    // Version info is necessary if version >= 7.
    return; // Don't need version info.
  }
  final versionInfoBits = BitArray();
  makeVersionInfoBits(version, versionInfoBits);

  int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0.
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 3; ++j) {
      // Place bits in LSB (least significant bit) to MSB order.
      final bit = versionInfoBits.get(bitIndex);
      bitIndex--;
      // Left bottom corner.
      matrix.set(i, matrix.height - 11 + j, bit ? 1 : 0);
      // Right bottom corner.
      matrix.set(matrix.height - 11 + j, i, bit ? 1 : 0);
    }
  }
}