问题描述
运行使用相机图像检测条形码的 iOS 应用时,出现以下错误:
2020-12-27 23:58:53.674730+0100 MYAPP[11942:4109474] [UnkNown process name] CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be kCGImageAlphaNoneskipLast
我不知道这是从哪里触发的。有人可以帮忙吗?
到目前为止我已经尝试过:
还有什么我应该尝试的吗?
P.S.:该应用程序是使用 Cordova 的混合应用程序,之前使用 XCode < 12
编译并在 iOS < 14
上运行时未出现此错误。
P.P.S.:我对 iOS/objective-c 很陌生。如果需要,我可以提供更多日志。
解决方法
如果您创建 CGImage
对象,请尝试将 bitmapInfo
赋予 CGImage
初始值设定项。
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.noneSkipLast.rawValue)
let cgImage = CGImage(
width: width,height: height,bitsPerComponent: bitsPerComponent,bitsPerPixel: bitsPerPixel,bytesPerRow: bytesPerRow,space: colorSpace,bitmapInfo: bitmapInfo,provider: provider,decode: nil,shouldInterpolate: true,intent: CGColorRenderingIntent.defaultIntent
)