Contents

CIContext

The Core Image context class provides an evaluation context for Core Image processing with Metal, OpenGL, or OpenCL.

Declaration

class CIContext

Mentioned in

Overview

You use a CIContext instance to render a CIImage instance which represents a graph of image processing operations which are built using other Core Image classes, such as CIFilter, CIKernel, CIColor and CIImage. You can also use a CIContext with the CIDetector class to analyze images — for example, to detect faces or barcodes.

Contexts support automatic color management by performing all processing operations in a working color space. This means that unless told otherwise:

  • All input images are color matched from the input’s color space to the working space.

  • All renders are color matched from the working space to the destination space. (For more information on CGColorSpace see CGColorSpace)

CIContext and CIImage instances are immutable, so multiple threads can use the same CIContext instance to render CIImage instances. However, CIFilter instances are mutable and thus cannot be shared safely among threads. Each thread must take case not to access or modify a CIFilter instance while it is being used by another thread.

The CIContext manages various internal state such as MTLCommandQueue and caches for compiled kernels and intermediate buffers. For this reason it is not recommended to create many CIContext instances. As a rule, it recommended that you create one CIContext instance for each view that renders CIImage or each background task.

Topics

Creating a Context Without Specifying a Destination

Creating a Context for CPU-Based Rendering

Creating a Context for GPU-Based Rendering

Rendering Images

Drawing Images

Determining the Allowed Extents for Images Used by a Context

Managing Resources

Rendering Images for Data or File Export

Creating Depth Blur Filters

Constants

Customizing Render Destination

Deprecated

Initializers

Instance Methods

Default Implementations

See Also

Essentials