UIImage created from MTKView results in color/opacity differences

前端 未结 3 1229
-上瘾入骨i
-上瘾入骨i 2021-02-10 06:30

When I capture the contents of an MTKView into a UIImage, the resulting image looks qualitatively different, as shown below:

The code I use to generate the UIIm

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-10 07:13

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

提交回复
热议问题