我正在从当前的可绘制纹理创建 UIImage,如下所示。
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
}
但它为 UIImage 添加了 alpha 值,而 UIImage 没有出现在纹理中。有什么解决方案可以摆脱 alpha 吗?这是捕获的纹理图像。
从纹理创建的 uiImage。