Atitit zxing二维码qr码识别解析


Atitit zxing二维码qr码识别解析



 

1.1. qr码识别解析 by zxing1

1.2. 解码libqrcode.jar  2

1.3. atitit.二维码生成总结java zxing 2

 

 

1.1. qr码识别解析 by zxing

 

/AtiPlatf_ee/src/com/attilax/qrcode/qrcodex.java

 

public static String decode(String imagePath) {

String contents = null;

 

MultiFormatReader formatReader = new MultiFormatReader();

 

BufferedImage image;

try {

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

 

// 将图像数据转换为1 bit data

LuminanceSource source = new BufferedImageLuminanceSource(image);

Binarizer binarizer = new HybridBinarizer(source);

// BinaryBitmap是ZXing用来表示1 bit data位图的类,Reader对象将对它进行解析

BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);

 

Map hints = new HashMap();

hints.put(DecodeHintType.CHARACTER_SET, "UTF-8");

 

// 对图像进行解码

Result result = formatReader.decode(binaryBitmap, hints);

contents = result.toString();

 

System.out.println("barcode encoding format :\t " + result.getBarcodeFormat());

} catch (IOException e) {

 

} catch (NotFoundException e) {

e.printStackTrace();

}

 

return contents;

 

 

1.2. 解码libqrcode.jar  

1.1.解码
编码lib:Qrcode_swetake.jar   (官网介绍-- http://www.swetake.com/qr/index-e.html)             
解码lib:qrcode.jar                 (官网介绍-- http://sourceforge.jp/projects/qrcode/)

qrcode.jar\jp\sourceforge\qrcode - 解包大小为 77.6 KB


1.2.首先,我们先说一下二维码一共有40个尺寸。官方叫版本Version。
Version 1是21 x 21的矩阵,Version 2是 25 x 25的矩阵,Version 3是29的尺寸,每增加一个version,就会增加4的尺寸,公式是:(V-1)*4 + 21(V是版本号) 最高Version 40,(40-1)*4+21 = 177,所以最高是177 x 177 的正方形。




    /**
     * @param args the command line arguments
     */ 
    public static void main(String[] args) { 
        QRCodeDecoderHandler handler = new QRCodeDecoderHandler(); 
        String imgPath = "c:\\3bf33a87e950352a5936aa0a5543fbf2b2118b59.jpg"; 
        String decoderContent = handler.decoderQRCode(imgPath,"gbk"); 
        System.out.println("解析结果如下:"); 
        System.out.println(decoderContent); 
        System.out.println("========decoder success  !!!"); 
    } 

1.3. atitit.二维码生成总结java zxing 

 

#-----zxing类库..
but zxing3.0  的类库core-3.0.jar 需要jdk7
只好zing2.2.jar ..jdk6ok..

 

 

#----com.attilax.qrcode.qrcodex.javar


public static void gene(final String content, final String path,
            final int width, final int height) {
        new tryX<Object>() {

            @Override
            public Object item(Object t) throws Exception {
                // attilax 老哇的爪子  下午5:23:26   2014511 
                   MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
                     
                     Map hints = new HashMap();
                     hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
                 
                    BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, width, height,hints);
                     File file1 = new File(path );
                     MatrixToImageWriter.writeToFile(bitMatrix, "jpg", file1);
                return null;
            }
        }.$("");
    }    

 

Ck参考资料

}

Java利用Zxing生成二维码 - 帅星星 - 博客园.html

atitit.二维码生成总结java zxing - attilax的专栏 - 博客频道 - CSDN.NET.html

Atitit java 二维码识别 图片识别_attilax_新浪博客.html

Atitit.二维码功能的设计实践 attilax 总结 - attilaxAti - 博客园.html

 

 

作者:: 绰号:老哇的爪子claw of Eagle 偶像破坏者Iconoclast image-smasher

捕鸟王"Bird Catcher 王中之王King of Kings 虔诚者Pious 宗教信仰捍卫者 Defender Of the Faith. 卡拉卡拉红斗篷 Caracalla red cloak

简称:: Emir Attilax Akbar 埃米尔 阿提拉克斯 阿克巴

全名::Emir Attilax Akbar bin Mahmud bin  attila bin Solomon bin adam Al Rapanui 埃米尔 阿提拉克斯 阿克巴 马哈茂德  阿提拉 所罗门 本亚当  阿尔 拉帕努伊

常用名:艾提拉(艾龙),  EMAIL:1466519819@qq.com

 

 

头衔:uke总部o2o负责人,全球网格化项目创始人,

uke宗教与文化融合事务部部长, uke宗教改革委员会副主席

Uke部落首席大酋长,

uke制度与重大会议委员会委员长,uke保安部首席大队长,uke制度检查委员会副会长,

奶牛科技cto ,uke 首席cto

uke波利尼西亚区大区连锁负责人,克尔格伦群岛区连锁负责人,莱恩群岛区连锁负责人,uke汤加王国区域负责人。布维岛和南乔治亚和南桑威奇群岛大区连锁负责人

 Uke软件标准化协会理事长理事长 uke终身教育学校副校长

Uke 数据库与存储标准化协会副会长 uke出版社编辑总编

Uke医院方面的创始人

 

转载请注明来源:attilax的专栏  ?http://blog.csdn.net/attilax

--Atiend

 

 


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值