日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Adding a QR Code Reader in Flex on Android

發布時間:2023/11/27 生活经验 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Adding a QR Code Reader in Flex on Android 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"><fx:Declarations><!-- Place non-visual elements (e.g., services, value objects) here --></fx:Declarations><fx:Script><![CDATA[import com.google.zxing.BarcodeFormat;import com.google.zxing.BinaryBitmap;import com.google.zxing.BufferedImageLuminanceSource;import com.google.zxing.DecodeHintType;import com.google.zxing.Result;import com.google.zxing.client.result.ParsedResult;import com.google.zxing.client.result.ResultParser;import com.google.zxing.common.BitMatrix;import com.google.zxing.common.ByteMatrix;import com.google.zxing.common.GlobalHistogramBinarizer;import com.google.zxing.common.flexdatatypes.HashTable;import com.google.zxing.qrcode.QRCodeReader;import com.google.zxing.qrcode.detector.Detector;import spark.events.ViewNavigatorEvent;protected var camera:Camera;private var videoDisplay:Video=new Video(360, 360);private var qrReader:QRCodeReader;private var bmd:BitmapData;private var cameraStarted:Boolean = false;protected function button1_clickHandler(event:MouseEvent):void{if (!cameraStarted) {if (Camera.isSupported){camera=Camera.getCamera();camera.setMode(360, 360, 24);videoDisplay.x = 360;sv.addChild(videoDisplay);videoDisplay.attachCamera(camera);videoDisplay.rotation=90;qrReader=new QRCodeReader;btn.label = "Scan Now";lbl.text = "";cameraStarted = true;}else {lbl.text = "no camera found";}}else {decodeSnapshot();}}public function decodeSnapshot():void{lbl.text="checking...";bmd=new BitmapData(300, 300);bmd.draw(videoDisplay, null, null, null, null, true);videoDisplay.cacheAsBitmap=true;videoDisplay.cacheAsBitmapMatrix=new Matrix;decodeBitmapData(bmd, 300, 300);bmd.dispose();bmd=null;System.gc();}public function decodeBitmapData(bmpd:BitmapData, width:int, height:int):void{var lsource:BufferedImageLuminanceSource=new BufferedImageLuminanceSource(bmpd);var bitmap:BinaryBitmap=new BinaryBitmap(new GlobalHistogramBinarizer(lsource));var ht:HashTable=null;ht=this.getAllHints();var res:Result=null;try {res=qrReader.decode(bitmap, ht);}catch (event:Error) {}if (res == null) {videoDisplay.clear();lbl.text="nothing decoded";}else {var parsedResult:ParsedResult=ResultParser.parseResult(res);lbl.text=parsedResult.getDisplayResult();sv.removeChild(videoDisplay);cameraStarted = false;btn.label = "Start Camera";}}public function getAllHints():HashTable{var ht:HashTable=new HashTable;ht.Add(DecodeHintType.POSSIBLE_FORMATS, BarcodeFormat.QR_CODE);return ht;}]]></fx:Script><s:VGroup width="100%" horizontalAlign="center" id="vg"><s:SpriteVisualElement id="sv" width="360" height="400"/><s:Label id="lbl" text="" /><s:Button id="btn" label="Start Camera" width="220" height="93" click="button1_clickHandler(event)"/></s:VGroup> </s:View>
public function decodeSnapshot():void
{lbl.text="checking...";bmd=new BitmapData(300, 300);bmd.draw(videoDisplay, null, null, null, null, true);videoDisplay.cacheAsBitmap=true;videoDisplay.cacheAsBitmapMatrix=new Matrix;decodeBitmapData(bmd, 300, 300);bmd.dispose();bmd=null;System.gc();
}public function decodeBitmapData(bmpd:BitmapData, width:int, height:int):void
{var lsource:BufferedImageLuminanceSource=new BufferedImageLuminanceSource(bmpd);var bitmap:BinaryBitmap=new BinaryBitmap(new GlobalHistogramBinarizer(lsource));var ht:HashTable=null;ht=this.getAllHints();var res:Result=null;try {res=qrReader.decode(bitmap, ht);}catch (event:Error) {}if (res == null) {videoDisplay.clear();lbl.text="nothing decoded";}else {var parsedResult:ParsedResult=ResultParser.parseResult(res);lbl.text=parsedResult.getDisplayResult();sv.removeChild(videoDisplay);cameraStarted = false;btn.label = "Start Camera";}
}public function getAllHints():HashTable
{var ht:HashTable=new HashTable;ht.Add(DecodeHintType.POSSIBLE_FORMATS, BarcodeFormat.QR_CODE);return ht;
}

?

if (Camera.isSupported)
{camera=Camera.getCamera();camera.setMode(360, 360, 24);videoDisplay.x = 360;sv.addChild(videoDisplay);videoDisplay.attachCamera(camera);videoDisplay.rotation=90;qrReader=new QRCodeReader;btn.label = "Scan Now";lbl.text = "";cameraStarted = true;
}
else {lbl.text = "no camera found";
}

?

轉載于:https://www.cnblogs.com/ggzjj/p/3612850.html

總結

以上是生活随笔為你收集整理的Adding a QR Code Reader in Flex on Android的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。