Search code examples
macoscore-animationcore-image

How to create a graph of CIFilter in Core Animation


In Interface Builder, I can create a stack of contents filters.

If I have n filters, the result is computed as: fno fn-1o..o f1. Now I would like to create several stacks and compose them into one filter.

How can I do that ?


Solution

  • The solution was to use the CIFilterGenerator class.

    The CIFilterGenerator class provides methods for creating a CIFilter object by chaining together existing CIFilter objects to create complex effects. (A filter chain refers to the CIFilter objects that are connected in the CIFilterGenerator object.) The complex effect can be encapsulated as a CIFilterGenerator object and saved as a file so that it can be used again. The filter generator file contains an archived instance of all the CIFilter objects that are chained together.

    And it becomes available as a CIFilter:

    Any filter generator files that you copy to /Library/Graphics/Image Units/ are loaded when any of the loading methods provided by the CIPlugIn class are invoked. A CIFilterGenerator object is registered by its filename or, if present, by a class attribute that you supply in its description.