Add alpha value when create image from MTLTexture

南笙酒味 提交于 2019-12-13 03:48:22

问题


I am creating UIImage from current drawable texture as follows.

func createImageFromCurrentDrawable() ->(UIImage){

        let context = CIContext()
        let texture = metalView.currentDrawable!.texture


        let kciOptions = [kCIContextWorkingColorSpace: CGColorSpace(name: CGColorSpace.sRGB)!,
                          kCIContextOutputPremultiplied: true,
                          kCIContextUseSoftwareRenderer: false] as [String : Any]

        let cImg = CIImage(mtlTexture: texture, options: kciOptions)!
        let cgImg = context.createCGImage(cImg, from: cImg.extent)!
        let uiImg =  UIImage(cgImage: cgImg)

        return uiImg
    }

but it adds alpha value to UIImage which is not appearing in the texture.Is there any solution to get rid of alpha? here is captured texture image.

uiImage created from texture.

来源:https://stackoverflow.com/questions/51183375/add-alpha-value-when-create-image-from-mtltexture

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