public static void MaybeEmbedVersionInfo(int version, ByteMatrix matrix) {
if (version < 7) { // Version info is necessary if version >= 7.
return; // Don't need version info.
}
BitVector versionInfoBits = new BitVector();
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.
int bit = versionInfoBits.At(bitIndex);
bitIndex--;
// Left bottom corner.
matrix.Set(i, matrix.GetHeight() - 11 + j, bit);
// Right bottom corner.
matrix.Set(matrix.GetHeight() - 11 + j, i, bit);
}
}
}