不推荐使用“ EAGLContext”的解决方案是什么? [英] What can be the solution of a deprecated of "EAGLContext"?

查看:452
本文介绍了不推荐使用“ EAGLContext”的解决方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的应用程序使用本机过滤器,该功能可以使用,但我想避免从文档中删除的方法。我在整个互联网上搜索,没有解决方案。

I want to use the native filters for my app, the function works but I want to avoid methods that will be removed from the documentation. I search over the whole internet and no solution.

我在整个互联网上进行搜索,但找不到任何解决方案。

I search over the whole internet and i haven't found any solution at my problem.

public func applyFilterTo(image: UIImage, filterEffect: Filter) -> UIImage? {
    guard let cgImage = image.cgImage,
          let openGLContext = EAGLContext(api: .openGLES3) else {
            return nil
    }
    let context = CIContext(eaglContext: openGLContext)
    let ciImage = CIImage(cgImage: cgImage)
    let filter = CIFilter(name: filterEffect.filterName)

    filter?.setValue(ciImage, forKey: kCIInputImageKey)

    if let filterEffectValue = filterEffect.filterEffectValue, let filterEffectValueName = filterEffect.filterEffectValueName {
        filter?.setValue(filterEffectValue, forKey: filterEffectValueName)
    }

    var filteredImage: UIImage?

    if let output = filter?.value(forKey: kCIOutputImageKey) as? CIImage,
        let cgiImageResult = context.createCGImage(output, from: output.extent) {
        filteredImage = UIImage(cgImage: cgiImageResult)
    }

    return filteredImage

}

结果不错,但我担心的是我的应用中的警告无效。谢谢

The result is good but my concern is voiding warnings in my app. Thanks

推荐答案

EAGLContext是OpenGL的一部分,已弃用。您应该在此阶段切换到Metal

EAGLContext is part of OpenGL, which is deprecated. You should switch to Metal at this stage.

这篇关于不推荐使用“ EAGLContext”的解决方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆