MTKView Displaying Wide Gamut P3 Colorspace

Viewed 2830

I'm building a real-time photo editor based on CIFilters and MetalKit. But I'm running into an issue with displaying wide gamut images in a MTKView.

Standard sRGB images display just fine, but Display P3 images are washed out.

I've tried setting the CIContext.render colorspace as the image colorspace, and still experience the issue.

Here are snippets of the code:

 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
        }

I have found a similar issue on the Apple developer forums, but without any answers: https://forums.developer.apple.com/thread/66166

1 Answers
Related