`

QR code类库

阅读更多
Google code发现的好东西。


QR code 类库: http://code.google.com/p/zxing/




ZXing (pronounced "zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java. Our focus is on using the built-in camera on mobile phones to photograph and decode barcodes on the device, without communicating with a server. We currently have support for:



UPC-A and UPC-E

EAN-8 and EAN-13

Code 39

Code 93

Code 128

QR Code

ITF

Codabar

RSS-14 (all variants)

Data Matrix ('alpha' quality)

PDF 417 ('alpha' quality)

This library is divided into several components; some are actively supported:



core: The core image decoding library, and test code

javase: J2SE-specific client code

android: Android client, called Barcode Scanner

androidtest: Android test app

android-integration: Supports integration with our Barcode Scanner app via Intent

zxingorg: The source behind zxing.org/w

zxing.appspot.com: The source behind our web-based barcode generator

Some modules are contributed and/or intermittently maintained:



javame: JavaME client

csharp: Partial C# port

cpp: Partial C++ port

rim: RIM/Blackberry-specific client build

iphone: iPhone client + port to Objective C / C++ (QR code only)

bug: Client for BugLabs's BUG

jruby: Ruby wrapper

actionscript: partial port to Actionscript




To complement our decoding software, we have created a web-based QR Code generator which supports contact information, calendar events, URLs, and much more.
分享到:
评论
4 楼 贝壳水母 2010-06-11  
有个地方需要注意下,直接调用该项目的QR码自动生成方法
(如:
QRCodeWriter_ED qrwriter = new QRCodeWriter_ED();
ByteMatrix matrix = qrwriter.encode("source", BarcodeFormat.QR_CODE, 200, 200,hints);MatrixToImageWriter.writeToFile(matrix, "png", file);

)
时,生成的图像是黑白颠倒的,以下是我改动后的QRCodeWriter类,修改后图像正常了
不知道各位有没有遇过这个问题,具体缘由以及是否会对其他方法有影响我不清楚,请指教

/*     */ package com.google.zxing.qrcode;
/*     */ 
/*     */ import com.google.zxing.BarcodeFormat;
/*     */ import com.google.zxing.EncodeHintType;
/*     */ import com.google.zxing.Writer;
/*     */ import com.google.zxing.WriterException;
/*     */ import com.google.zxing.common.ByteMatrix;
/*     */ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
/*     */ import com.google.zxing.qrcode.encoder.Encoder;
/*     */ import com.google.zxing.qrcode.encoder.QRCode;
/*     */ import java.util.Hashtable;
/*     */ 
/*     */ public final class QRCodeWriter_ED
/*     */   implements Writer
/*     */ {
/*     */   private static final int QUIET_ZONE_SIZE = 4;
/*     */ 
/*     */   public ByteMatrix encode(String contents, BarcodeFormat format, int width, int height)
/*     */     throws WriterException
/*     */   {
/*  42 */     return encode(contents, format, width, height, null);
/*     */   }
/*     */ 
/*     */   public ByteMatrix encode(String contents, BarcodeFormat format, int width, int height, Hashtable hints)
/*     */     throws WriterException
/*     */   {
/*  48 */     if ((contents == null) || (contents.length() == 0)) {
/*  49 */       throw new IllegalArgumentException("Found empty contents");
/*     */     }
/*     */ 
/*  52 */     if (format != BarcodeFormat.QR_CODE) {
/*  53 */       throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
/*     */     }
/*     */ 
/*  56 */     if ((width < 0) || (height < 0)) {
/*  57 */       throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
/*     */     }
/*     */ 
/*  61 */     ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;
/*  62 */     if (hints != null) {
/*  63 */       ErrorCorrectionLevel requestedECLevel = (ErrorCorrectionLevel)hints.get(EncodeHintType.ERROR_CORRECTION);
/*  64 */       if (requestedECLevel != null) {
/*  65 */         errorCorrectionLevel = requestedECLevel;
/*     */       }
/*     */     }
/*     */ 
/*  69 */     QRCode code = new QRCode();
/*  70 */     Encoder.encode(contents, errorCorrectionLevel, hints, code);
/*  71 */     return renderResult(code, width, height);
/*     */   }
/*     */ 
/*     */   private static ByteMatrix renderResult(QRCode code, int width, int height)
/*     */   {
/*  77 */     ByteMatrix input = code.getMatrix();
/*  78 */     int inputWidth = input.getWidth();
/*  79 */     int inputHeight = input.getHeight();
/*  80 */     int qrWidth = inputWidth + 8;
/*  81 */     int qrHeight = inputHeight + 8;
/*  82 */     int outputWidth = Math.max(width, qrWidth);
/*  83 */     int outputHeight = Math.max(height, qrHeight);
/*     */ 
/*  85 */     int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);
/*     */ 
/*  90 */     int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
/*  91 */     int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
/*     */ 
/*  93 */     ByteMatrix output = new ByteMatrix(outputWidth, outputHeight);
/*  94 */     byte[][] outputArray = output.getArray();
/*     */ 
/*  98 */     byte[] row = new byte[outputWidth];
/*     */ 
/* 101 */     for (int y = 0; y < topPadding; ++y) {
//下面一行代码原为setRowColor(outputArray[y], -1);
/* 102 */       setRowColor(outputArray[y], 0);
/*     */     }
/*     */ 
/* 106 */     byte[][] inputArray = input.getArray();
/* 107 */     for (int y = 0; y < inputHeight; ++y)
/*     */     {
/* 109 */       for (int x = 0; x < leftPadding; ++x) {
//原为row[x] = -1;
/* 110 */         row[x] = 0;
/*     */       }
/*     */ 
/* 114 */       int offset = leftPadding;
/* 115 */       for (int x = 0; x < inputWidth; ++x) {
//原为byte value = (inputArray[y][x] == 1) ? 0 : -1;
/* 116 */         byte value = (inputArray[y][x] == 1) ? -1 : 0;
/* 117 */         for (int z = 0; z < multiple; ++z) {
/* 118 */           row[(offset + z)] = value;
/*     */         }
/* 120 */         offset += multiple;
/*     */       }
/*     */ 
/* 124 */       offset = leftPadding + inputWidth * multiple;
/* 125 */       for (int x = offset; x < outputWidth; ++x) {
//原为row[x] = -1;
/* 126 */         row[x] = 0;
/*     */       }
/*     */ 
/* 130 */       offset = topPadding + y * multiple;
/* 131 */       for (int z = 0; z < multiple; ++z) {
/* 132 */         System.arraycopy(row, 0, outputArray[(offset + z)], 0, outputWidth);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 137 */     int offset = topPadding + inputHeight * multiple;
/* 138 */     for (int y = offset; y < outputHeight; ++y) {
/* 139 */       setRowColor(outputArray[y], 0);
/*     */     }
/*     */ 
/* 142 */     return output;
/*     */   }
/*     */ 
/*     */   private static void setRowColor(byte[] row, byte value) {
/* 146 */     for (int x = 0; x < row.length; ++x)
/* 147 */       row[x] = value;
/*     */   }
/*     */ }
3 楼 zcbbupt 2010-06-11  
能详细讲一下怎么使用这个开源项目嘛!
2 楼 sinfrancis 2010-06-07  
贝壳水母 写道
毕业设计刚搞的就是QRCODE,这个项目帮了不少忙

此类库做条形码扫描有很大的帮助。
1 楼 贝壳水母 2010-06-04  
毕业设计刚搞的就是QRCODE,这个项目帮了不少忙

相关推荐

    PHP QR Code在线生成二维码调用方法及实例.rar

    这是一个PHP二维码在线生成源码,采用的是PHP QR Code类库生成,在生成时调用这个类文件即可,用此方法生成二维码,相对来说是比较简单的了。这个二维码生成用法也挺简单,直接在文本框中输入文字或网址后,单击按钮...

    PHP下通过QRCode类库创建中间带网站LOGO的二维码

    我们要生成二维码都需要借助一些类库来实现了,下面我介绍利用PHP QR Code生成二维码吧,生成方法很简单,下面我来介绍一下. ...例子,使用PHP QR Code类库创建二维码。 1,浏览器输出: &lt;? include "php

    php二维码类库:一个支持二维码读取的php类库(qreader)

    介绍一个支持二维码读取的php类库,引入即可使用,这个php二维码读取类库支持多种二维码的读取。

    用于读写条形码 C# 类库 MessagingToolkit Barcode

    QR Code Data Matrix PDF 417 Bookland/ISBN Codabar Code 11 Code 128 Code 128-A Code 128-B Code 128-C Code 39 Code 39 Extended Code 93 EAN-13 EAN-8 FIM Interleaved 2 of 5 ITF-14 LOGMARS MSI 2 Mod 10 MSI...

    用于读写条形码 C#类库 MessagingToolkit Barcode

    QR Code Data Matrix PDF 417 Bookland/ISBN Codabar Code 11 Code 128 Code 128-A Code 128-B Code 128-C Code 39 Code 39 Extended Code 93 EAN-13 EAN-8 FIM Interleaved 2 of 5 ITF-14 LOGMARS MSI 2 Mod 10 MSI...

    PHPqrCode:一个生成二维码的php类库

    PHPqrCode是一个PHP二维码生成类库,利用它可以轻松生成二维码,下载类库后,只需要使用phpqrcode.php就可以生成二维码了,当然您的PHP环境必须开启支持GD2。

    (0140)-iOS/iPhone/iPAD/iPod源代码-其他(Others)-QR Code Encoder

    将字符串生成二维码。能够将一个字符串(NSString)转换成一个二维码图像(UIImage)。代码中用到了类库libqrencode。 注意:请在Mac下解压使用

    条形码(Code39、Code93、Code128A/B/C、CodeI2of5、CodeEan13)、QR二维码生成DLL

    条形码、二维码是当前数字世界最常用的编码格式,作者将相关编码生成类库打包形成DLL,5分钟学会使用,方便使用: 1、将StoneQrBarcode.h、StoneQrBarcode.lib和StoneQrBarcode.dll三个文件拷贝到项目子目录下,并在...

    PHP基于phpqrcode类生成二维码的方法示例详解

    HP QR Code是一个PHP二维码生成类库,利用它可以轻松生成二维码,官网提供了下载和多个演示demo,查看地址: http://phpqrcode.sourceforge.net/ 下载官网提供的类库后,只需要使用phpqrcode.php就可以生成二维码了...

    barcodelib条形码生成读取库

    支持一维码EAN8, EAN13, UPCA, CODE39, CODE128, ITF,二维码QR_CODE的生成和读取。 本类库基于ZXing条形码库修改而来,主要的改动: * 取消支持部分条形码,较少库文件大小。 * 拆分为barcodelib.swc和barcodelib...

    C# VB .NET中条码识别读取条形码QR二维码生成和创建条码二维码生成的源码

    C#编写的实现条形码和QR二维码读取和生成的类库。支持读取QR Code,Aztec Code,Data Matrix,MaxiCode,USPS OneCode,IM Barcode; SharpBarcode也支持Code93,Code129,PDF417,Rss14,GS1,UPC-A,UPC-E,EAN-8,EAN-13,...

    zxing-javase.jar

    QR Code ITF Codabar RSS-14 (all variants) Data Matrix PDF 417 ('alpha' quality) Aztec ('alpha' quality) 同时官网提供了 Android、cpp、C#、iPhone、j2me、j2se、jruby、objc、rim、symbian等多种应用...

    ThoughtWorks.QRCode二维码生成库已修改 支持中文

    今天刚刚编译的二维码类库,绝对支持中文! 使用方法(先引用dll) 示例: QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE; qrCodeEncoder....

    zxing.java源码解析-barcode4jAndZxingStudy:一维码和二维码整明白了

    zxing.java源码解析 简介 条形码(一维码)和二维码 解决方案 barcode4j、zxing barcode4j开源Java条形码生成库,j适合生成条形码,不适合生成二维码。 zxing是由google开源的...CODE的流行,所以二维码又叫做QR code。

    php qrcode

    PHP QR Code是一个PHP二维码生成类库,利用它可以轻松生成二维码

    php使用qr生成二维码的示例分享

    二维码就是用在平面上用特定的几何图形记录数据信息的,QR码是常见的一种二维码。推荐使用生成QR码的php类库PHP QR Code,下面是使用示例

    CSharp开发二维码应用实例

    1.支持PDF417,QR_Code,DataMatrix和Aztec等多种二维码 2.各种条码都符合国家标准和ISO标准。 3.提供编码多种字符集选择 4.采用统一编码接口 5.提供两种常用编码方式 5.1通过内容大小决定条码图像区域 5.2根据...

    二维条形码生成图片功能

    5、生成多种像 QR Code, Code 39, Code 128, UPC,EAN这样的类型的1维和2维条形码 6、兼容最新的条形码ISO标准 7、容易将URLs、联系信息等信息转换成QR Code和Data Matrix 8、可靠成熟的Android条形码生成类库

    zxing.java源码解析-zxing-spring-boot-starter:兴

    crossing”)是一个支持多种格式的条形码和二维码图形解析的开源Java类库,同时它也提供了其他语言的接口。 解码时支持格式有:UPC-A、UPC-E、EAN-8、EAN-13、Code 39、Code 93、Code 128、ITF、Codabar、MSI、RSS-...

Global site tag (gtag.js) - Google Analytics