When creating a Core Image CIContext using the following:
contextWithCGLContext:pixelFormat:colorSpace:options:
You can specify a color space with a CGColorSpaceRef
. However, the options
dictionary that you can pass also allows you to set certain color space parameters. From Apple's documentation:
kCIContextOutputColorSpace
A key for the color space to use for images before they are rendered to the context. By default, Core Image uses the GenericRGB color space, which leaves color matching to the system. You can specify a different output color space by providing a Quartz 2D CGColorSpace object (CGColorSpaceRef). (See Quartz 2D Programming Guide for information on creating and using CGColorSpace objects.)
kCIContextWorkingColorSpace
A key for the color space to use for image operations. By default, Core Image assumes that processing nodes are 128 bits-per-pixel, linear light, premultiplied RGBA floating-point values that use the GenericRGB color space. You can specify a different working color space by providing a Quartz 2D CGColorSpace object (CGColorSpaceRef). Note that the working color space must be RGB-based. If you have YUV data as input (or other data that is not RGB-based), you can use ColorSync functions to convert to the working color space. (See Quartz 2D Programming Guide for information on creating and using CGColorSpace objects.)
My question is, how do these various color space parameters interact?
My assumption would be that creating the CIContext with with a color space set using the colorspace:
parameter above would be the same as setting the color space using the kCIContextOutputColorSpace
in the options:
dictionary. Is that correct? If not, what does each parameter mean?
If so, then what happens if the color space is set using both the colorspace:
parameter as well as the kCIContextOutputColorSpace
key in the options:
dictionary? Does one override the other? Is there some other behavior?