What can be the solution of a deprecated of “EAGLContext”?

末鹿安然 提交于 2019-12-30 07:44:07

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/55582603/what-can-be-the-solution-of-a-deprecated-of-eaglcontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!