我正在基于CIFilters和MetalKit构建实时照片编辑器。但是在MTKView中显示宽色域图像时遇到了问题。
标准的sRGB图像可以正常显示,但Display P3图像会变得模糊。
我尝试将CIContext.render颜色空间设置为图像颜色空间,但仍然存在问题。
以下是代码片段:
标准的sRGB图像可以正常显示,但Display P3图像会变得模糊。
我尝试将CIContext.render颜色空间设置为图像颜色空间,但仍然存在问题。
以下是代码片段:
guard let inputImage = CIImage(mtlTexture: sourceTexture!) else { return }
let outputImage = imageEditor.processImage(inputImage)
print(colorSpace)
context.render(outputImage,
to: currentDrawable.texture,
commandBuffer: commandBuffer,
bounds: inputImage.extent,
colorSpace: colorSpace)
commandBuffer?.present(currentDrawable)
let pickedImage = info[UIImagePickerControllerOriginalImage] as! UIImage
print(pickedImage.cgImage?.colorSpace)
if let cspace = pickedImage.cgImage?.colorSpace {
colorSpace = cspace
}
我在苹果开发者论坛上找到了一个类似的问题,但没有任何答案:https://forums.developer.apple.com/thread/66166