iOS iPhone ZBar获取扫描图像

时间:2011-06-07 06:04:32

标签: ios iphone uiimage barcode scanning

如何让ZBar不仅返回条形码文本字符串,还可以返回扫描条形码的UIImage?

1 个答案:

答案 0 :(得分:3)

在实现ZBarReaderDelegate的类中包含类似的内容:

- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    // ADD:  get the decode results
    id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
    ZBarSymbol* symbol = nil;

    for (symbol in results)
    {
        // grab first barcode
        break;
    }

    // do something with barcode data
    qrCode.text = symbol.data;

    // do something with barcode image
    // BELOW IS HOW YOU GET THE SCANNED IN IMAGE
    //
    resultImage.image = [info objectForKey: UIImagePickerControllerOriginalImage];

    // dismiss controller
    [reader dismissModalViewControllerAnimated: YES];