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];