相关疑难解决方法(0)

使用zxing进行QR码编码和解码

好的,所以我要抓住这里有人曾经使用过zxing的机会.我正在开发一个Java应用程序,它需要做的一件事就是将一个字节数据数组编码为QR代码,然后再对其进行解码.

这是我的编码器的示例:

byte[] b = {0x48, 0x45, 0x4C, 0x4C, 0x4F};
//convert the byte array into a UTF-8 string
String data;
try {
    data = new String(b, "UTF8");
}
catch (UnsupportedEncodingException e) {
 //the program shouldn't be able to get here
 return;
}

//get a byte matrix for the data
ByteMatrix matrix;
com.google.zxing.Writer writer = new QRCodeWriter();
try {
 matrix = writer.encode(data, com.google.zxing.BarcodeFormat.QR_CODE, width, height);
}
catch (com.google.zxing.WriterException e) {
 //exit the method
 return;
}

//generate an image from the byte …
Run Code Online (Sandbox Code Playgroud)

java qr-code barcode zxing

35
推荐指数
3
解决办法
10万
查看次数

标签 统计

barcode ×1

java ×1

qr-code ×1

zxing ×1