private static void embedPositionDetectionPattern(int xStart, int yStart,
      ByteMatrix matrix) throws WriterException {
    // We know the width and height.
    if (POSITION_DETECTION_PATTERN[0].length != 7 || POSITION_DETECTION_PATTERN.length != 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]);
      }
    }
  }