private static void embedTimingPatterns(ByteMatrix matrix)
{
// -8 is for skipping position detection patterns (size 7), and two horizontal/vertical
// separation patterns (size 1). Thus, 8 = 7 + 1.
for (int i = 8; i < matrix.Width - 8; ++i)
{
int bit = (i + 1) % 2;
// Horizontal line.
if (isEmpty(matrix[i, 6]))
{
matrix[i, 6] = bit;
}
// Vertical line.
if (isEmpty(matrix[6, i]))
{
matrix[6, i] = bit;
}
}
}