條碼掃描二維碼掃描—ZXing android 改進版本


看了Vurtexゞ. 文章《[Android實例] 條碼掃描二維碼掃描——ZXing android 源碼簡化 (附:支持中文) 》的基礎上對代碼進行了修改

1、增加了將代碼嵌套入自己工程后傳值的辦法(初學,如果有更好的方法也希望告訴我,先謝謝了)

2、掃碼界面進行了處理(初步實現了現有某些軟件的樣子,至於長的像誰就不說了)

//畫四個角的代碼
paint.setColor(frameColor); canvas.drawRect(15 + frame.left, 15 + frame.top,15 + (linewidht + frame.left), 15 + (50 + frame.top), paint); canvas.drawRect(15 + frame.left, 15 + frame.top,15 + (50 + frame.left), 15 + (linewidht + frame.top), paint); canvas.drawRect(-15 + ((0 - linewidht) + frame.right),15 + frame.top, -15 + (1 + frame.right),15 + (50 + frame.top), paint); canvas.drawRect(-15 + (-50 + frame.right), 15 + frame.top, -15+frame.right, 15 + (linewidht + frame.top), paint); canvas.drawRect(15 + frame.left, -15 + (-49 + frame.bottom),15 + (linewidht + frame.left), -15 + (1 + frame.bottom), paint); canvas.drawRect(15 + frame.left, -15+ ((0 - linewidht) + frame.bottom), 15 + (50 + frame.left), -15 + (1 + frame.bottom), paint); canvas.drawRect(-15 + ((0 - linewidht) + frame.right), -15+ (-49 + frame.bottom), -15 + (1 + frame.right), -15+ (1 + frame.bottom), paint); canvas.drawRect(-15 + (-50 + frame.right), -15+ ((0 - linewidht) + frame.bottom), -15 + frame.right, -15+ (linewidht - (linewidht - 1) + frame.bottom), paint);

  

 掃碼

linewidht變量控制四個角的寬度,下圖顯示的是設置為2時的效果

將ViewfinderView類中代碼中vmiddle hmiddle 變量定義下的這兩句替換可以變為小十字坐標

canvas.drawRect(hmiddle - 20, vmiddle - 1, hmiddle + 20,vmiddle + 2, paint);
canvas.drawRect(hmiddle - 1, vmiddle - 20, hmiddle + 2,vmiddle + 20, paint);

  360手機助手截圖01.png

代碼下載地址:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=225832&page=1&extra=#pid1997182

再貼一些經典的掃描界面

 參考資料:

android入門:zxing學習筆記

條碼掃描二維碼掃描——ZXing android 源碼簡化 (附:支持中文)

Android 條形碼識別軟件開發全解析

ZXing改橫屏識別為豎屏識別

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM