zoukankan      html  css  js  c++  java
  • 生成二维码

      以下是生成二维码的具体代码:

       int width=300;//设置二维码宽度
            int height=300;//设置二维码高度
            String format="png";//图片格式
            String content="这里是要扫出来的内容";//内容
            HashMap hints=new HashMap();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); //字体格式
            hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);//纠错等级
            hints.put(EncodeHintType.MARGIN, 3);//边距
            try {
                BitMatrix bitmatrix=new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height,hints);
                //建立一个新的路径
                Path file=new File("指定路径").toPath();
                MatrixToImageWriter.writeToPath(bitmatrix, format, file);
            } catch (Exception e) {
                // TODO: handle exception
            }

      ps:这里需要导一个zxing3.3.0.jar包

  • 相关阅读:
    SPOJ 149 FSHEEP Fencing in the Sheep ( 计算几何 + 二分 )
    UVa 11806
    UVa 1445
    HDU 4725 The Shortest Path in Nya Graph( 建图 + 最短路 )
    HDU 4661 Message Passing ( 树DP + 推公式 )
    从远程库克隆库
    添加远程库
    远程仓库
    删除文件
    撤销修改
  • 原文地址:https://www.cnblogs.com/zdigd/p/6414153.html
Copyright © 2011-2022 走看看