MxABC / LBXScan

A barcode and qr code scanner (二维码、扫码、扫一扫、ZXing、ZBar、iOS系统AVFoundation扫码封装,扫码界面效果封装)
MIT License
3.23k stars 679 forks source link

zxing模式下不能扫出本地二维码 #200

Open Args opened 4 years ago

isdotjim commented 4 years ago

搭个车... 想邀请Repo参与者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍: http://t.cn/Ai1vLcCU http://t.cn/Ai1vLcCG http://t.cn/Ai1vLcCA

llwj0303 commented 3 years ago

请问解决了吗,亲

llwj0303 commented 3 years ago

自己解决了,算是库的一个BUG吧,写给需要的人😄

fixOrientation函数如下:

// Now we draw the underlying CGImage into a new context, applying the transform

// calculated above.

CGContextRef ctx = CGBitmapContextCreate(NULL, aImage.size.width, aImage.size.height,

                                         CGImageGetBitsPerComponent(aImage.CGImage), 0,

                                         CGImageGetColorSpace(aImage.CGImage),

                                         CGImageGetBitmapInfo(aImage.CGImage));

CGContextConcatCTM(ctx, transform);

switch (aImage.imageOrientation) {
    case UIImageOrientationLeft:

    case UIImageOrientationLeftMirrored:

    case UIImageOrientationRight:

    case UIImageOrientationRightMirrored:

// Grr...

        CGContextDrawImage(ctx, CGRectMake(0, 0, aImage.size.height, aImage.size.width), aImage.CGImage);

        break;

    default:

        CGContextDrawImage(ctx, CGRectMake(0, 0, aImage.size.width, aImage.size.height), aImage.CGImage);

        break;
}

// And now we just create a new UIImage from the drawing context

CGImageRef cgimg = CGBitmapContextCreateImage(ctx);

UIImage *img = [UIImage imageWithCGImage:cgimg];

CGContextRelease(ctx);

CGImageRelease(cgimg);

return img;

}