ios - CG图像创建 : invalid image alphaInfo

标签 ios objective-c xcode alpha cgimage

我收到一个奇怪的错误,我无法确定是哪部分代码导致了该错误。

运行使用相机图像检测条形码的 iOS 应用程序时,出现以下错误:

2020-12-27 23:58:53.674730+0100 MYAPP[11942:4109474] [Unknown process name] CGImageCreate: invalid image alphaInfo: kCGImageAlphaNone. It should be kCGImageAlphaNoneSkipLast

我无法弄清楚这是从哪里发射的。有人可以帮忙吗?

到目前为止我已经尝试过:

  1. 使用 NSLog 添加符号调试器假设这是一个日志输出,但调试器没有捕获它。

  2. 由于错误提到图像没有正确的 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/

相关文章:

ios - 无法阻止 Sprite 移出屏幕

ios - Xcode 4.5 Enterprise 签名问题(适用于 Xcode 4.3.3)

ios - 选择 UICollectionView 中的单元格时调整图像大小

iPhone 和 Webapp 通过 iCloud 同步 ??

ios - 缺少 HealthKit 权利

ios - 在 ios 中与音频播放器一起在屏幕上显示文本

objective-c - SceneKit 检测给定区域的触摸

objective-c - 在 Cocoa 中等待指定的时间

iphone - 在蜂窝网络和 WiFi 之间切换时 AudioStreamer 停止

ios - 冗余二进制文件上传。在 Softwareassets 上已经有构建版本为“1' for train ' 1.1.2”的二进制上传