我收到一个奇怪的错误,我无法确定是哪部分代码导致了该错误。
运行使用相机图像检测条形码的 iOS 应用程序时,出现以下错误:
2020-12-27 23:58:53.674730+0100 MYAPP[11942:4109474] [Unknown process name] CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be kCGImageAlphaNoneSkipLast
我无法弄清楚这是从哪里发射的。有人可以帮忙吗?
到目前为止我已经尝试过:
使用
NSLog
添加符号调试器假设这是一个日志输出,但调试器没有捕获它。由于错误提到图像没有正确的 alphaInfo,我尝试向 UIImage 被修改的所有位置添加 alpha(它被修改以进行裁剪和旋转)
我还应该尝试什么吗?
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
)
关于ios - CG图像创建 : invalid image alphaInfo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65471347/