Color Space Options for CIContext

When creating a CIContext main image, use the following:

contextWithCGLContext:pixelFormat:colorSpace:options: 

You can specify a color space with CGColorSpaceRef . However, the options dictionary, which you can pass in, also allows you to set specific color space options. From the Apple Documentation :

kCIContextOutputColorSpace

The key for the color space used for images before they are displayed in context. By default, Core Image uses the GenericRGB color space, which leaves the color matching system. You can specify a different output color space by providing a Quartz 2D CGColorSpace object (CGColorSpaceRef). (See 2D Quartz Programming Guide for information on creating and using CGColorSpace objects.)

kCIContextWorkingColorSpace

The key for the color space used for image operations. By default, Core Image assumes that the processing nodes are 128 bits per pixel, linear light, pre-multiplied RGBA floating point values ​​that use the GenericRGB color space. You can specify a different working color by providing the Quartz 2D CGColorSpace object (CGColorSpaceRef). Please note that the working color space must be RGB based. If you have YUV data as input (or other non-RGB based data), you can use the ColorSync Functions to convert to a working color space. (See Quartz 2D Programming Guide for information on creating and using CGColorSpace Objects.)

My question is: how do these different color space options interact?

My assumption would be that creating a CIContext with the color space set using the colorspace: parameter above would be the same as setting the color space with kCIContextOutputColorSpace in the options: dictionary. It's right? If not, what does each parameter mean?

If so, what happens if the color space is set using both the colorspace: parameter and the kCIContextOutputColorSpace key in the options: dictionary? Does someone redefine another? Is there any other behavior?

+6
source share

Source: https://habr.com/ru/post/949068/


All Articles