JAVA 压缩图片-解析一维码二维码

首先使用这个类来压缩图片:

相关包下载

CompressPicDemo

CompressPicDemo mypic = new CompressPicDemo(); //创建压缩图对象
//compressPic(大图片路径,生成小图片路径,大图片文件名,生成小图片文名,生成小图片宽度,生成小图片高度,是否等比缩放(默认为true))
mypic.compressPic("c:\\原图片路径", "c:\\输出图片路径", "原图片.后缀", "输出图.后缀", 600, 600, true);

然后使用ZXING来解码

用到的包 core-2.0.jar javase-1.7.jar

//解码
BufferedImage image = null;  

Result result = null;  //com.google.zxing.Result

image = ImageIO.read(new File(imgPath));

if (image == null) {

System.out.println("the decode image may be not exit.");


 }

LuminanceSource source = new BufferedImageLuminanceSource(image);

BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 


result = new MultiFormatReader().decode(bitmap, null);

String decodeContent = result.getText();

System.out.println("解码内容如下:" + decodeContent);



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值