zxing扫描条形码 ios
2013-04-02 14:49
316 查看
在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;
SCANNER for Portrait mode更多了解,参考一下文档:http://groups.google.com/group/zxing/browse_thread/thread/cfe2324e8baf2aaa
参考:http://code.google.com/p/zxing/issues/detail?id=571
PS:谁如果已经解决了5.0用zxing扫描条形码的问题,弄出来给大家看下
http://shopsavvy.mobi/developers/ 扫描库,没用过不知道效果如何
注,如果是itouch的话,可能会因为分辨率低的问题(以前一直因为是5.0的系统影响),不能解码,我以前为这个事情纠结了好长时间,刚刚买了iphone,是5.0的系统一切正常。
转载地址:http://blog.sina.com.cn/s/blog_6dae58b30100xz7e.html
相关文章推荐
- ios ZXing 二维码、条形码扫描
- zxing扫描条形码 ios
- iOS 条形码 二维码 的生成 和 扫描 zBarSDK zXing
- 使用zxing生成QRCode二维码,在Android的webview中调用条形码扫描
- android studio 集成zxing二维码,条形码扫描
- 如何在iOS中使用ZXing库(ZXing是一个开源的条码生成和扫描库,开源协议为Apache2.0。它持众多条码格式和语言,比如Java、 C++、 C#、 Objective-C以及Act )
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- iOS扫描二维码条形码ZBar的简单使用
- 使用ZXing扫描条形码和二维码
- 基于Zxing的二维码、条形码的扫描以及二维码的生成(简洁高效)
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- iOS 使用ZBarSDK扫描条形码和二维码
- ZXing二维码、条形码生成和扫描
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- ios 二维码、条形码扫描
- iOS 原生实现扫描二维码和条形码功能限制扫描区域
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果