zoukankan      html  css  js  c++  java
  • 修改ZXing,使之支持条形码识别


    1.在- (IBAction)scanPressed:(id)sender方法中:
    ZXingWidgetController *widController = [[ZXingWidgetControlleralloc] initWithDelegate:selfshowCancel:YESOneDMode:YES];
    
    
    MultiFormatOneDReader *OneReaders=[[MultiFormatOneDReaderalloc]init]; QRCodeReader* qrcodeReader = [[QRCodeReaderalloc] 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];

        //              UIImageWriteToSavedPhotosAlbum([UIImage imageWithCGImage:capture], nil, nil, nil);

        CGImageRelease(croppedImg);

        cropRect.origin.x = 0.0;

        cropRect.origin.y = 0.0;

        cropRect.size.width = CGImageGetWidth(capture);

        cropRect.size.height = CGImageGetHeight(capture);

      }

     
    3. 将上面注释掉的代码向下数大概约20行处的代码:
    UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage]; 
    改为:
    int backCameraImageOrientation = UIImageOrientationRight; 
    UIImage *scrn = [[UIImage alloc] initWithCGImage:newImage scale: 
    (CGFloat)1.0 orientation:backCameraImageOrientation];

    4. 在OverlayView.m注释代码以下代码:

    self.oneDMode = isOneDModeEnabled;
    
     
    然后运行,OK。
     
    With kind regards, --- Kris Wang QQ : 652289237 E-mail:kris.wa@qq.com
  • 相关阅读:
    动态模板列更新数据分页的例子
    Oracle SCN机制解析
    阻止特定的ip登陆数据库的2种方法 (轉)
    Oracle动态执行SQL四种方式的例子
    使用Oracle的DBMS_SQL包执行动态SQL语句
    Oracle XML DB之浅入浅出
    将oracle设为归档模式和非归档模式启动的方法
    如何修改Oracle數據庫字符集
    (原創)C#使用QueryTables導出到Excel
    常用SQL語句2
  • 原文地址:https://www.cnblogs.com/wangfangkui/p/3052138.html
Copyright © 2011-2022 走看看