您的位置:首页 > 其它

zxing 生成二维码 去白色补丁

2016-05-24 15:28 309 查看
`String content = "120605181003;http://www.cnblogs.com/jtmjx";
String path = "/Users/yindingyu/xxx/";

MultiFormatWriter multiFormatWriter = new MultiFormatWriter();

Map hints = Maps.newHashMap();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 0);//去掉白色边框

BitMatrix bitMatrix = null;
try {
bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, 246, 246,hints);
} catch (WriterException e) {
e.printStackTrace();
}

Path file = Paths.get(path);

try {
MatrixToImageWriter.writeToStream(bitMatrix, qRconfig.getImageFormat(), outputStream);
} catch (IOException e) {
log.error("生成二维码时出现问题",e);
throw ExceptionUtil.getException(ResponseCode.GEN_QR_CODE_ERROR);
}`
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: