微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 macOS 10.15.7 (19H1030) 上渲染 CIImage 导致空白图像

如何解决在 macOS 10.15.7 (19H1030) 上渲染 CIImage 导致空白图像

安装安全更新 2021-002 Catalina 后,渲染核心图像图像停止正常工作。 下面的代码导致空白图像:

<activity
            android:name=".SplashScreen"
            android:screenorientation="portrait"
            android:theme="@style/SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity
            android:name=".MainActivity"
            android:launchMode="singletop"
            android:screenorientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

控制台打印如下错误

    let ciContext = CIContext(options: [.useSoftwareRenderer: true])
    guard let srcPath = Bundle.main.path(forResource: "Flowers",ofType: "jpg"),let ciImage = CIImage(contentsOf: URL(fileURLWithPath: srcPath)) else { return }
    let dstUrl = URL(fileURLWithPath: Nsstring("~/Desktop/1.jpg").expandingTildeInPath)
    guard let destination = CGImageDestinationCreateWithURL(dstUrl as CFURL,kUTTypeJPEG,1,nil) else { return }
    guard let cgImage = ciContext.createCGImage(ciImage,from: ciImage.extent) else { return }
    CGImageDestinationAddImage(destination,cgImage,nil)
    CGImageDestinationFinalize(destination)

解决此问题的临时解决方案是通过在创建 CIContext 时将 useSoftwareRenderer 选项设置为 false 来禁用软件渲染。

任何帮助将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。