android 条码识别软件开发全解析(续2详解绝杀!)

转自http://www.cnblogs.com/tankaixiong/archive/2010/10/31/1865807.html 博客

关于andriod上实现条码识别,我前面已经讲了一些简单的应用,上篇讲过的应用zxing时必需多安装其组件这是不能接受的,
我想大家都已经想到解决的方法了吧,呵呵,其实正真学习一个东西,从其最基本的东东开始--大家都知道就是源码了。
OK,我们要深入条码的识别的话自然就要去读zxing的源码,你读完之后就不只是懂得其源码了,
你会发现你其实收获到的不仅仅只有这点,还有更多的东西,比如你更深入学习android的又一个应用示例对Android的开发多了了解。
官网源码提供免费下载,但帮助文档不是很全,最近有在读它的源码,去调试运行它的源码对你去理解了解其结构是很有帮助的。

官网上只提供源码的下载,并没有提供编译好的开发包,也就是说你自己下过来后还要自己编译,不然把下下来的源码程序导入到myeclipse中会报错。
如图:

对于新手可能有些不知下手,这里我就讲下zxing的编译,为后面的开发做好一个最基本的准备!
第一步:准备包
http://code.google.com/p/zxing/ 下载
编译zxing
 下载ant 地址http://ant.apache.org/
 下载proguard 地址http://proguard.sourceforge.net/index.html#/downloads.html
 
解压:zxing-1.6
目录结构下:
    zxing-1.6
        -android
        android-integration
        core
        build.properties
        build.xml
        ........

第二步:配置环境变量。
打开build.properties
修改proguard 为你下载的proguard下的lib文件夹下的proguard.jar指向
android-home你的 sdk目录
proguard-jar=../proguard4.5.1/lib/proguard.jar 版本为4.4以上
android-home=../Android/android-sdk-windows

配置ant环境变量
ANT_HOME
E:\MyLiB\java\ANT\apache-ant-1.8.1
PATH
E:\MyLiB\java\ANT\apache-ant-1.8.1\bin

cmd 中ant回车出现
Buildfile: build.xml does not exist!
Build failed
表现成功!

第三步:开始编译

cd 到core目录 然后ant!

BUILD SUCCESSFUL
Total time: * second
表示成功编译!
然后编译android
cd ../android
ant

好了!有了核心包后我们可以就可以导入到项目工程里去了,现在是不是就不报错了!而且还可以直接运行的!

如图:


ZXingTestActivity为其zxing运用的例子,这是学习zxing的一个很好的帮助!这个例子运行前提也是必需先安装BarcodeScanner3.5.apk
android 目录则是前篇我博客讲调用时必需安装的一个组件BarcodeScanner3.5.apk的源码。呵呵,我想大家就知道了,对了,
想不安装我们可以直接在源码上进行修改并进行编译,就ok了。
希望我的这几篇文章可以给大家有些帮助,也算引个方向,最后更深入学习代码,就只能看自己了!
大家肯定比我聪明,会很快读懂源码并很快应用起来,如有什么问题希望大家一起探讨学习,不断进步!
下几篇博客我想可以写一些基于 zxing条码识别自己的运用程序示例了!如果大家有兴趣我会和大家一起分享!好了,今天就写到这里了!

另附编译说明:
官网引用详细参见:
# Download and install the latest public Android SDK.
# Edit build.properties at the top level of the project, and change the android-home property to point to the SDK install location
# Download Proguard, version 4.4 minimum, and install it where you like.
# Edit build.properties and set proguard-jar to the full path (including the filename) of the ProGuard library.
# Build core; Note that core must be built without debug symbols to avoid an incompatibility between proguard and the Android tool chain:

 cd core
 ant clean build-no-debug

# Build android:

 cd ../android
 ant

另外我上传已经编译我的jar包供大家下载:

 http://files.cnblogs.com/tankaixiong/zxing%e6%a0%b8%e5%bf%83%e5%8c%85.rar

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ZXing一维码/二维码 使用文档 样例: System.IO.Stream stmYiWei = new System.IO.MemoryStream(); BitMatrix byteMatrix = new MultiFormatWriter().encode(sCode, BarcodeFormat.CODE_39, 230, 40); toBitmap(byteMatrix).Save(stmYiWei, ImageFormat.Bmp); Byte[] byteYiWei = new byte[stmYiWei.Length]; stmYiWei.Position = 0; stmYiWei.Read(byteYiWei, 0, (int)stmYiWei.Length); //将图片文件流保存为二进制文件以便保存到数据库中 System.IO.Stream stmErWei = new System.IO.MemoryStream(); IDictionary hints = new Dictionary(); hints.Add(EncodeHintType.CHARACTER_SET, "UTF-8"); byteMatrix = new MultiFormatWriter().encode(sTmp, BarcodeFormat.QR_CODE, 200, 200, hints); toBitmap(byteMatrix).Save(stmErWei, ImageFormat.Bmp); Byte[] byteErWei = new byte[stmErWei.Length]; stmErWei.Position = 0; stmErWei.Read(byteErWei, 0, (int)stmErWei.Length); //将图片文件流保存为二进制文件以便保存到数据库中 strSQL = "insert into gdzc_biaoqian( bq_gd_no,bq_yiweima,bq_erweima,bq_us_no) values("; strSQL = strSQL + " @bq_gd_no,@bq_yiweima,@bq_erweima,@bq_us_no)"; SqlCommand commandImage = new SqlCommand(strSQL, connectionImage); commandImage.Parameters.Clear(); commandImage.Parameters.Add("@bq_gd_no", SqlDbType.Int).Value = Convert.ToInt32(sGdzcNo); commandImage.Parameters.Add("@bq_yiweima", SqlDbType.Image).Value = byteYiWei; commandImage.Parameters.Add("@bq_erweima", SqlDbType.Image).Value = byteErWei; commandImage.Parameters.Add("@bq_us_no", SqlDbType.Int).Value = Convert.ToInt32(Session["LoginUserID"]); commandImage.ExecuteNonQuery(); commandImage.Dispose();

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值