java生成二维码内部放入中文介绍
2021-06-05 12:02
标签:false getwidth 添加 exists common hand isp ade barcode //工具类 //启动控制类 //pom.xml文件 java生成二维码内部放入中文介绍 标签:false getwidth 添加 exists common hand isp ade barcode 原文地址:https://www.cnblogs.com/xianz666/p/14629034.htmlpackage test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
/*
* 语言:java 工具jar:zxing 版本:3.2.1
* 使用前需要导入jar包或者依赖
* 生成和解码QR工具类
* 参考自:https://www.cnblogs.com/mr-wuxiansheng/p/7256507.html
*/
public class QR {
private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF;
// LOGO宽度
private static final int LOGO_WIDTH = 60;
// LOGO高度
private static final int LOGO_HEIGHT = 60;
//二维码
private static final int QCwidth = 600;
private static final int QCheight = 600;
//图片格式
private static final String format="png";
/**
*
* 图片高度增加60
*
*/
private static final int PIC_HEIGHT=QCheight+60;
public static String createQR(String outPath,String content) {
Hashtable
package test;
import java.util.Map;
public class CreateQR {
public static void main(String[] args) {
//生成QR
String cqr = QR.createQR("E:test.png", "老银铺百年传承承接各种金银首饰加工,地址苏州市吴江区友谊大厦105号,高级金银加工大师:裴忠云 电话:18362712202");
System.out.println("生成状态:" + cqr);
//解析QR
Map m = QR.analysisQR("E:test.png");
System.out.println("解析状态:" + m.get("STATE"));
System.out.println("二维码内容:" + m.get("TEXT"));
}
}
上一篇:JAVA中字符串相等如何表示
下一篇:Python - pyenv