private static void EmbedPositionDetectionPattern(int xStart, int yStart,
ByteMatrix matrix) {
// We know the width and height.
if (POSITION_DETECTION_PATTERN[0].Length != 7 || POSITION_DETECTION_PATTERN.GetLength(0) != 7) {
throw new WriterException("Bad position detection pattern");
}
for (int y = 0; y < 7; ++y) {
for (int x = 0; x < 7; ++x) {
if (!IsEmpty(matrix.Get(xStart + x, yStart + y))) {
throw new WriterException();
}
matrix.Set(xStart + x, yStart + y, POSITION_DETECTION_PATTERN[y][x]);
}
}
}