【发布时间】:2017-12-30 22:20:22
【问题描述】:
我正在构建一个基于 CIFilters 和 MetalKit 的实时照片编辑器。但我遇到了在 MTKView 中显示广色域图像的问题。
标准 sRGB 图像显示正常,但 Display P3 图像褪色。
我尝试将 CIContext.render 颜色空间设置为图像颜色空间,但仍然遇到问题。
这里是sn-ps的代码:
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
}
我在 Apple 开发者论坛上发现了一个类似的问题,但没有任何答案:https://forums.developer.apple.com/thread/66166
【问题讨论】:
-
我不确定它在 iOS 中是否可行...在 macOS 中,MTKView 有一个您可以设置的 colorSpace 属性,但显然它在 iOS 中不受支持:(developer.apple.com/documentation/metalkit/mtkview/…
标签: ios swift core-image metal metalkit