Closed karthikgs7 closed 8 years ago
Also getting an error...
Based on https://github.com/objcio/functional-programming-in-swift/issues/77, I switched to a CIColor as the input color but still getting error.
I notice that in https://github.com/objcio/issue-16-functional-apis/blob/master/FunctionalCoreImage/CoreImage.swift, you unwrap the CIColor but when I try to, it says its a non-optional.
To fix this problem need set size for output image in CIConstantColorGenerator filter, try this function
func colorGenerator(color: NSColor) -> Filter { return { image in guard let c = CIColor(color: color) else { fatalError() } let parameters = [kCIInputColorKey: c] guard let filter = CIFilter(name: "CIConstantColorGenerator", withInputParameters: parameters) else { fatalError() } guard let outputImage = filter.outputImage?.imageByCroppingToRect(image.extent) else { fatalError() } return outputImage } }
afterfriday's fix worked for me - thanks very much. This is really just applying the same crop as used in compositeSourceOverlay. I still had a problem due to my own typo in the filter name, so that is worth checking if things are going weird.
With the CIColor un-wrapping, if you are using an iOS playground with UIColor, the CIColor initialiser does not return an optional. If you are using an NSColor, it does.
Thanks for all the comments everyone. Unfortunately, we can't do much about it until Apple fixes this =).
When, I call the colorGenerator and compositeSourceOver, separately, it works fine. I got error only, when I calling colorOverlay function.