How to get the type of code from zbar?

允我心安 提交于 2019-12-12 12:07:49

问题


In my Application Zbar is decoding perfectly. But the problem is Zbar can decode both QR code and Bar code . So after decoding How do i get the type of Encoding Style ?

thanks in advance


回答1:


There are return codes for type in ZBarSymbol. You will be looking for ZBAR_QRCODE for QR codes

ZBarSymbol documentation

Something like this should help you to get the symbol out:

- (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:


What i did was,

- (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
}


来源:https://stackoverflow.com/questions/18587917/how-to-get-the-type-of-code-from-zbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!