I am unable to get an image that was originally created via a CIFilter to display in IB on on a simulator. Display on a device is fine.
Here is how I am rendering the image:
if let f = constructFilter(radius: radius, value: sliderView.value.hsba.brightness), let foi = f.outputImage {
circleView.image = UIImage(ciImage: foi)
}
And here is how I consruct the filter (the 'value' input parameter is always 1.0):
private func constructFilter(radius: CGFloat, value: CGFloat) -> CIFilter? {
guard let cs = CGColorSpace.init(name: CGColorSpace.extendedSRGB) else { return nil }
return CIFilter(name: "CIHueSaturationValueGradient", parameters: [
"inputColorSpace" : cs,
"inputDither" : 0,
"inputRadius" : radius,
"inputSoftness" : 0,
"inputValue" : value])
}
The specific color space doesn't change the behaviour. This also fails:
return CIFilter(name: "CIHueSaturationValueGradient", parameters: [
"inputColorSpace" : CGColorSpaceCreateDeviceRGB(),
"inputDither" : 0,
"inputRadius" : radius,
"inputSoftness" : 0,
"inputValue" : value])
Of course, if I generate the image from a resource it works just fine on device, IB and simulator.
Poking around in the debugger, I notice that extracting png data from the UIImage returns nil when the image has been created from CIFilter - which could explain why IB and simulator fail to display anything
Any thoughts would be welcome.
Regards,
ac