【发布时间】:2017-01-04 15:04:42
【问题描述】:
zxing` lib,用于在我的 spring mvc 应用程序中生成 qr 代码。他们生成代码非常好,现在我想要在 qr 图像底部的自定义文本。 比如----
我使用的库。
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>2.2</version>
</dependency>
我使用的代码
String charset = "UTF-8"; // or "ISO-8859-1"
Map hintMap = new HashMap();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
createQRCode(code,
dirPath ,
charset, hintMap, 200, 200);
public static void createQRCode(String qrCodeData, String filePath, String charset, Map hintMap, int qrCodeheight,
int qrCodewidth) throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(new String(qrCodeData.getBytes(charset), charset),
BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight, hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath.lastIndexOf('.') + 1), new File(filePath));
}
【问题讨论】:
-
我也遇到了同样的问题,有人找到解决办法了吗???