问题
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