示例#1
0
  /**
   * 写入二维码、以及将照片logo写入二维码中
   *
   * @param matrix 要写入的二维码
   * @param format 二维码照片格式
   * @param imagePath 二维码照片保存路径
   * @param logoPath logo路径
   * @throws IOException
   */
  @SuppressWarnings({"deprecation"})
  public static void writeToFile(BitMatrix matrix, String format, String imagePath, String logoPath)
      throws IOException {
    MatrixToImageWriter.writeToFile(matrix, format, new File(imagePath), new MatrixToImageConfig());

    // 添加logo图片, 此处一定需要重新进行读取,而不能直接使用二维码的BufferedImage 对象
    BufferedImage img = ImageIO.read(new File(imagePath));
    MatrixToImageWriterEx.overlapImage(img, format, imagePath, logoPath, DEFAULT_CONFIG);
  }