Red to add Four Corners yellow for scan line auto Slide
/** Copyright (C) ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); Use this file except in compliance with the License. * Obtain a copy of the License at * *http://www.apache.org/licenses/LICENSE-2.0* * Unless required by applicable or agreed to writing, software * Distributed under the License is distribute D on ' As is ' BASIS, * without warranties or CONDITIONS of any KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */Package Com.zxing.view;import java.util.collection;import java.util.hashset;import android.content.Context; Import Android.content.res.resources;import Android.graphics.bitmap;import Android.graphics.canvas;import Android.graphics.color;import Android.graphics.paint;import Android.graphics.rect;import Android.util.attributeset;import Android.view.view;import Com.bawei.zxingdemo.r;import Com.google.zxing.resultpoint;import Com.zxing.camera.CameraManager;/** * This view are overlaid on top of the camera preview. It adds the viewfinder * rectangle and partial transparency outside it, as well as the laser scanner * animation and Resul T points. 锟 all false copy 锟 Jin 锟 絍 iew 锟 catty copy 锟 Jin 锟 catty copy Shi called alkali copy 锟 pound copy show 锟 Jin copy*/ PublicFinalclassViewfinderview extends View {Private StaticFinalint[] Scanner_alpha = {0, -, -,192,255,192, -, - }; Private StaticFinalLongAnimation_delay =100L; Private StaticFinalintOPAQUE =0xFF; Privatefinal paint paint; PrivateBitmap Resultbitmap; PrivateFinalintMaskColor; PrivateFinalintResultcolor; PrivateFinalintFrameColor; PrivateFinalintLasercolor; PrivateFinalintResultpointcolor; Private intScanneralpha; /** * Four green corner corresponding to the length*/ private intscreenrate; /** * Four green corner corresponding to the width*/ private static final int corner_width = 10; /** * Cell phone's screen density*/ private static floatdensity; PrivateCollection<resultpoint>possibleresultpoints; PrivateCollection<resultpoint>lastpossibleresultpoints; int count=0; //This constructor was used when the class was built from an XML resource. PublicViewfinderview (Context context, AttributeSet Attrs) {Super (context, attrs); //Initialize These once for performance rather than calling them every//Time in OnDraw ().Paint =NewPaint (); Resources Resources=getresources (); MaskColor=Resources.getcolor (R.color.viewfinder_mask); Resultcolor=Resources.getcolor (R.color.result_view); FrameColor=Resources.getcolor (r.color.viewfinder_frame); Lasercolor=Resources.getcolor (R.color.viewfinder_laser); Resultpointcolor=Resources.getcolor (r.color.possible_result_points); Scanneralpha=0; Possibleresultpoints=NewHashset<resultpoint> (5); density = Context.getresources (). Getdisplaymetrics (). density; Convert pixel to DP screenrate = (int) (* density); } @Override Public voidOnDraw (canvas canvas) {//Juan Time Fermium ecf 壂 æ 忔 锛 Imperial quantity untreated blemish like Blake bookmark regulation 壂 æ 忔 fermium 勫 ぇ Hao 忥 紝  level hygiene Ameramanager stated expiry refer 岄 bulb ki adjustRect frame = Cameramanager.Get(). Getframingrect (); if(frame = =NULL) { return; } //Luen PK 彇 BA Chairman Wilson 箷 fermium 勫 Tel 岄 intwidth =canvas.getwidth (); intHeight =canvas.getheight (); //Draw the exterior (i.e outside the framing rect) darkened//ãºã downloading gallium 弿 Jean Ricoh 闈 ㈢ Crypto Radiation Village award 閮-Hi 垎 锛 toric eizan å›žå¤ 涗 Kettle 閮-Hi 垎 锛 屾 壂 æ 忔 fermium Âμà Kono 闈 ㈠ Lang BA Chairman Wilson 箷 Juan 婇 Bulb 锛 屾 壂 æ 忔 fermium Âμà Lower 闈 ㈠ Lang BA Chairman Wilson 箷 Juan 嬮 Bulb//Gallium 弿 Jean Bang Crypto Chen "unexpectedly 闈㈠ Lang BA Chairman Wilson 箷 Chen" unexpectedly 锛 屾 壂 æ 忔 fermium 勫 Conferences Fork Roses Lang BA Chairman Wilson 箷 Å è¡#̈亞Paint.setcolor (Resultbitmap! =NULL?Resultcolor:maskcolor); Canvas.drawrect (0,0, Width, frame.top, paint); Canvas.drawrect (0, Frame.top, Frame.left, Frame.bottom +1, paint); Canvas.drawrect (Frame.right+1, Frame.top, width, Frame.bottom +1, paint); Canvas.drawrect (0, Frame.bottom +1, width, height, paint); if(Resultbitmap! =NULL) { //Draw The opaque result bitmap over the scanning rectanglePaint.setalpha (OPAQUE); Canvas.drawbitmap (Resultbitmap, Frame.left, frame.top, paint); } Else { //ãºã plot 壂 æ 忔 fork Stroll kono fermium cancel 锛 屾? Eizan 8 Juan 儴 arrival? //Draw a pixel solid black border inside the framing rectPaint.setcolor (FrameColor); Canvas.drawrect (Frame.left, frame.top, Frame.right+1, Frame.top+2, paint); Canvas.drawrect (Frame.left, Frame.top+2, Frame.left +2, Frame.bottom-1, paint); Canvas.drawrect (Frame.right-1, Frame.top, Frame.right +1, Frame.bottom-1, paint); Canvas.drawrect (Frame.left, Frame.bottom-1, Frame.right +1, Frame.bottom+1, paint); //Draw a red "laser scanner" line through the middle to show//decoding is active//úã painted 壂 æ 忔 Juan 嬮 bulb fermium 勫 瓧Paint.setcolor (Lasercolor); Paint.setalpha (Scanner_alpha[scanneralpha]); Scanneralpha= (Scanneralpha +1) %scanner_alpha.length; int middle = count%frame.height () + frame.top; Canvas.drawrect (Frame.left + 2, middle-1, frame.right-1, Middle + 2, paint); count+=3; //draw a corner on the edge of the scan box, a total of 8 sections Paint.setcolor (Color.green); Canvas.drawrect (Frame.left, frame.top, Frame.left + screenrate, Frame.top + corner_width, paint); Canvas.drawrect (Frame.left, frame.top, Frame.left + corner_width, frame.top + screen rate, paint); Canvas.drawrect (Frame.right-screenrate, Frame.top, frame.right, Frame.top + corner_width, paint); Canvas.drawrect (Frame.right-corner_width, Frame.top, frame.right, Frame.top + SCR Eenrate, paint); Canvas.drawrect (Frame.left, frame.bottom-corner_width, Frame.left + screenrate, Frame.bottom, Pai NT); Canvas.drawrect (Frame.left, frame.bottom-screenrate, Frame.left + corner_width, Frame.bottom, Pai NT); Canvas.drawrect (Frame.right-screenrate, Frame.bottom-corner_width, Frame.right, Frame.bottom, paint); Canvas.drawrect (Frame.right-corner_width, Frame.bottom- screenrate, Frame.right, Frame.bottom, paint); Collection<ResultPoint> currentpossible =possibleresultpoints; Collection<ResultPoint> Currentlast =lastpossibleresultpoints; if(Currentpossible.isempty ()) {lastpossibleresultpoints=NULL; } Else{possibleresultpoints=NewHashset<resultpoint> (5); Lastpossibleresultpoints=currentpossible; Paint.setalpha (OPAQUE); Paint.setcolor (Resultpointcolor); for(Resultpoint point:currentpossible) {canvas.drawcircle (Frame.left+point.getx (), Frame.top+ point.gety (),6.0f, paint); } } if(Currentlast! =NULL) {Paint.setalpha (OPAQUE/2); Paint.setcolor (Resultpointcolor); for(Resultpoint point:currentlast) {canvas.drawcircle (Frame.left+point.getx (), Frame.top+ point.gety (),3.0f, paint); } } //Request Another update at the animation interval//repaint the laser line,//Not the entire viewfinder mask. //å è¡#̈亞 id ã version 壂 æ 忔 fermium 勫 search锛 yue decyl 紝 å duo Yeast Rice 鍦 Edition 闀挎柟褰 Juan Indent ID ã?postinvalidatedelayed (Animation_delay, Frame.left, Frame.top, Frame.right, Frame.bottom ); } } Public voidDrawviewfinder () {Resultbitmap=NULL; Invalidate (); } /** Draw a bitmap with the result points highlighted instead of the live * scanning display. * * @param barcode * An image of the decoded barcode. */ Public voidDrawresultbitmap (Bitmap barcode) {Resultbitmap=Barcode; Invalidate (); } Public voidAddpossibleresultpoint (Resultpoint point) {possibleresultpoints.add (point); }}
Android QR code scan box plus Four corners and middle horizontal line automatically slide