IOS-zbar scanview

Source: Internet
Author: User

Add scan area in scanview

 
Zbarreaderviewcontroller * reader = [zbarreaderviewcontroller new]; reader. readerdelegate = self; // cgrect frame = cgrectmake (20, 30,320,260); reader. scancrop = cgrectmake (0.2 ,. 1 ,. 47 ,. 8 );

Add a custom scan box for the custom scanview

-(Uiview *) setoverlaypickerview {uiview * V = [[uiview alloc] initwithframe: cgrectmake (0, 0,320,480)]; [V setbackgroundcolor: [uicolor clearcolor]; uilabel * scanninglabel = [[uilabel alloc] labels: cgrectmake (100, 50,120, 30)]; [scanninglabel setbackgroundcolor: [uicolor clearcolor]; [scanninglabel setfont: [uifont fontwithname: @ "Courier" Size: 18.0]; [scanninglabel settextcolor: [uicolor redcolor]; [scanninglabel settext: @ "scanning... "]; [scanninglabel sethidden: No]; [V addsubview: scanninglabel]; uiimageview * overlayimageview = [[uiimageview alloc] initwithimage: [uiimage imagenamed: @" success "]; [overlayimageview setframe: cgrectmake (30,100,260,200)]; [V addsubview: overlayimageview]; uitoolbar * mytoolbar = [[uitoolbar alloc] init]; optional * backbutton = [externalloc] initwithtitle: @ "back" style: uibarbuttonitemstylebordered target: Self action: @ selector (dismissoverlayview :)]; uiswitch * Sw = [[uiswitch alloc] init]; [SW Seton: No]; uibarbuttonitem * switchbutton = [[uibarbuttonitem alloc] failed: Sw]; uibarbuttonitem * fixed = [[uibarbuttonitem alloc] failed: Failed target: Nil action: Nil]; [SW addtarget: self action: @ selector (handleswitchflash :) forcontrolevents: Counter]; [mytoolbar setitems: [nsarray handle: backbutton, fixed, switchbutton, nil]; [mytoolbar setbarstyle: uibarstyledefault]; cgrect toolbarframe; toolbarframe = cgrectmake (0,436,320, 44); [mytoolbar setframe: toolbarframe]; [V addsubview: mytoolbar]; return V ;}

cut an image

// Example: Do something useful with the barcode image uiimage * largeimage = [info objectforkey: Encrypted]; // uiimage * portraitimage = [[uiimage alloc] initwithcgimage: largeimage. cgimage // scale: 1.0 // orientation: uiimageorientationleft]; uiimage * portraitimage = [largeimage imagerotatedbydegrees: 90]; // cgrectmake (0.2 ,. 1 ,. 47 ,. 8); float W = largeimage. size. width; float H = largeimage. size. height; nslog (@ "==== largeimagesize: H = % F, W = % F", largeimage. size. height, largeimage. size. width); nslog (@ "==== portraitimage: H = % F, W = % F", portraitimage. size. height, portraitimage. size. width); cgimageref imageref = cgimagecreatewithimageinrect ([portraitimage cgimage], cgrectmake (w *. 25, H *. 2, w *. 8, H *. 27); // or use the uiimage wherever you like [self. scanimageview setimage: [uiimage imagewithcgimage: imageref];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.