问题
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