利用googleZxing生成二维码识别二维码
2016-05-20 17:22
706 查看
生成二维码ImageIO流:
识别二维码:
maven依赖:
注:本人应用版本2.3.0,识别二维码时遇到问题,
<span style="color:#FF6666;">MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); BitMatrix bitMatrix = multiFormatWriter.encode(url, BarcodeFormat.QR_CODE, 140, 140); BufferedImage image = MatrixToImageWriter.toBufferedImage(bitMatrix); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(image, "jpg", out);</span>
识别二维码:
<span style="color:#FF6666;">String imgUrl = "*.com/a.jpg" URL url = new URL(imgUrl); image = ImageIO.read(url); LuminanceSource source = new BufferedImageLuminanceSource(image); Binarizer binarizer = new HybridBinarizer(source); BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer); MultiFormatReader uultiFormatReader = new MultiFormatReader(); Result result = uultiFormatReader.decode(binaryBitmap); return result.getText();</span>
maven依赖:
<span style="color:#FF0000;"><dependency> <groupId>com.google.zxing</groupId> <artifactId>core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.google.zxing</groupId> <artifactId>javase</artifactId> <version>2.2</version> </dependency></span>
注:本人应用版本2.3.0,识别二维码时遇到问题,
<span style="background-color: rgb(0, 153, 0);"><span style="font-size:24px;">javase包JDK版本1.7 如Java6项目,请将javase版本降级为2.2</span></span> 下载包地址:<span style="font-family:Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', SimSun, SimHei, arial, sans-serif;color:#000000;font-size: 15.238096237182617px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 22.85714340209961px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">http://mvnrepository.com/</span>
相关文章推荐
- java-用HttpURLConnection发送Http请求.
- android Google Map获取地理位置信息的方法
- 谷歌 Project Zero 团队宣布新政策,漏洞披露前将有完整的 90 天缓冲期
- Android使用Google Map浅谈
- 专家解读:开源软件项目是否会被限制出口?
- 专家解读:开源软件项目是否会被限制出口?
- 马化腾亲自“站台” 企业微信和个人微信互通能带来什么?
- Google排名算法改变 不在以外部链为主
- Google Adsense 支票托收信息收集 (1-30-2007)
- Google Adsense常用技巧总结
- Google推广的十二点技巧
- google优化圣经做网站必备第1/3页
- Google AdSense英文高价关键词排行列表
- VBScript 剪贴板抓取URL并在浏览器中打开
- Google 统计图表(Flash)小插件
- 2月份停止Google Adsense下线推介 将在中国地区停止投放
- 使用Google工具栏追踪 Blog 留言
- 用vbs 实现从剪贴板中抓取一个 URL 然后在浏览器中打开该 Web 站点
- asp获取URL参数的几种方法分析总结[原创]_应用技巧_脚本之家