【问题标题】:How to get the type of bar code from zbar?如何从zbar获取条码类型?
【发布时间】:2013-09-03 08:51:47
【问题描述】:

在我的应用程序中,Zbar 完美解码。但问题是Zbar可以同时解码二维码和条形码。那么解码后,如何获取Encoding Style的类型呢?

【问题讨论】:

    标签: iphone ios qr-code zbar


    【解决方案1】:

    ZBarSymbol 中有类型的返回码。您将寻找用于二维码的 ZBAR_QRCODE

    ZBarSymbol documentation

    这样的东西应该可以帮助你把符号弄出来:

    - (void) readerView: (ZBarReaderView*) view didReadSymbols: (ZBarSymbolSet*) syms  fromImage: (UIImage*) img 
    {
        //do something useful with results and display resultText in resultViewController
        for(ZBarSymbol *sym in syms) 
        {
            imageResult3.image = img; 
            resultText.text = sym.typeName;
            resultText.text =  [ resultText.text stringByAppendingString:@" - " ];
            resultText.text =  [ resultText.text stringByAppendingString:sym.data ]; 
    
        }
    }
    

    【讨论】:

    • 谢谢伙计.. :-) 现在你能告诉我如何获得该图像的最后修改日期.. ???所有代码都试过了,但没有运气..
    【解决方案2】:

    我所做的是,

    - (void) imagePickerController: (UIImagePickerController*) reader  didFinishPickingMediaWithInfo: (NSDictionary*) info
    {
        UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage];
        ZBarImage *zImage = [[ZBarImage alloc] initWithCGImage:image.CGImage];
        ZBarImageScanner *scanner = [[ZBarImageScanner alloc] init];
        [scanner setSymbology: ZBAR_I25
                            config: ZBAR_CFG_ENABLE
                            to: 0];
        [scanner scanImage:zImage];
        ZBarSymbolSet *set = [scanner results];
    
        ZBarSymbol *symbol = nil;
        for (symbol in set)
            break;
        codeType.text = symbol.typeName
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-06
      • 1970-01-01
      • 1970-01-01
      • 2012-01-05
      • 2018-01-26
      • 1970-01-01
      • 2013-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多