IOS zXing 扫描条形码

在ios中使用zxing扫描条形码:
1.在- (IBAction)scanPressed:(id)sender方法中:
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:YES];



MultiFormatOneDReader *OneReaders=[[MultiFormatOneDReader alloc]init];
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc ] initWithObjects:OneReaders,qrcodeReader,nil];

[qrcodeReader release];

[OneReaders release];

2.在ZXingWidgetController.m的 (void)captureOutput:(AVCaptureOutput *)captureOutput :方法中,注释掉以下方法
if (oneDMode) {
    // let's just give the decoder a vertical band right above the red line
        cropRect.origin.x = cropRect.origin.x + (cropRect.size.width / 2) - (ONE_D_BAND_HEIGHT + 1);
    cropRect.size.width = ONE_D_BAND_HEIGHT;
                
    // do a rotate
    CGImageRef croppedImg = CGImageCreateWithImageInRect(capture, cropRect);  
    capture = [self CGImageRotated90:croppedImg]; 
    capture = [self CGImageRotated180:capture];
    CGImageRelease(croppedImg);  
    cropRect.origin.x = 0.0;
    cropRect.origin.y = 0.0;  
cropRect.size.width = CGImageGetWidth(capture); cropRect.size.height = CGImageGetHeight(capture); }
4、将以下的代码替换:
UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage]; 
改为:
int backCameraImageOrientation = UIImageOrientationRight; 
    UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage scale: 
(CGFloat)1.0 orientation:backCameraImageOrientation];
5、在OverlayView.m注释代码以下代码:
self.oneDMode = isOneDModeEnabled;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值