Search code examples
swiftcifilter

Error with CIFilter key: kCIInputPoint0Key for CIToneCurve - Swift 3 & macOS


I'm trying to control brightness as in this Stack Overflow post with the CIFilter CIToneCurve.

Tho I'm getting this error:

Use of unresolved identifier 'kCIInputPoint0Key'

I also can't find the key here: Filter Parameter Keys

Has anyone figured this out?


Solution

  • From your link on the filter parameter keys (emphasis mine):

    These keys represent some of the most commonly used input parameters. A filter can use other kinds of input parameters.

    What you need to do is "hard-code" those parameters. For instance:

    let ciVector0 = CIVector(cgPoint: CGPoint(x: 0, y: 0))
    filter.setValue(ciVector0, forKey: "inputPoint0")
    

    You'll need to do this for all 5 vectors for this filter.