Class

CIColor

The component values defining a color in a specific color space.

Declaration

@interface CIColor : NSObject

Overview

You use CIColor objects in conjunction with other Core Image classes, such as CIFilter, CIContext, and CIImage, to take advantage of the built-in Core Image filters when processing images.

A color space defines a one-, two-, three-, or four-dimensional environment whose color components represent intensity values. A color component is also referred to as a color channel. An RGB color space, for example, is a three-dimensional color space whose stimuli are the red, green, and blue intensities that make up a given color. Regardless of the color space, in Core Image, color values range from 0.0 to 1.0, with 0.0 representing an absence of that component (0 percent) and 1.0 representing 100 percent.

Colors also have an alpha component, which represents the opacity of the color, with 0.0 meaning completely transparent and 1.0 meaning completely opaque. If a color does not have an explicit alpha component, Core Image paints the color as if the alpha component equals 1.0. You always provide unpremultiplied color components to Core Image, and Core Image then provides unpremultiplied color components to you. Core Image premultiplies each color component with the alpha value in order to optimize calculations. For more information on premultiplied alpha values, see Core Image Programming Guide.

Topics

Initializing Color Objects

- initWithCGColor:

Initializes a Core Image color object with a Core Graphics color.

- initWithColor:

Initializes a Core Image color object using a UIKit (or AppKit) color object.

- initWithRed:green:blue:

Initializes a Core Image color object with the specified red, green, and blue component values.

- initWithRed:green:blue:alpha:

Initializes a Core Image color object with the specified red, green, blue, and alpha component values.

- initWithRed:green:blue:colorSpace:

Initializes a Core Image color object with the specified red, green, and blue component values as measured in the specified color space.

- initWithRed:green:blue:alpha:colorSpace:

Initializes a Core Image color object with the specified red, green, blue, and alpha component values as measured in the specified color space.

Creating Color Objects

+ colorWithCGColor:

Creates a color object from a Quartz color.

+ colorWithRed:green:blue:

Creates a color object using the specified RGB color component values

+ colorWithRed:green:blue:alpha:

Creates a color object using the specified RGBA color component values.

+ colorWithString:

Creates a color object using the RGBA color component values specified by a string.

+ colorWithRed:green:blue:colorSpace:

Initializes a Core Image color object with the specified red, green, and blue component values as measured in the specified color space.

+ colorWithRed:green:blue:alpha:colorSpace:

Creates a Core Image color object with the specified red, green, blue, and alpha component values as measured in the specified color space.

Getting Color Components

colorSpace

The Quartz 2D color space associated with the color.

components

The color components of the color.

numberOfComponents

Returns the number of color components in the color.

red

The unpremultiplied red component of the color.

green

The unpremultiplied green component of the color.

blue

The unpremultiplied blue component of the color.

alpha

The alpha value of the color.

stringRepresentation

A formatted string that specifies the components of the color.

Creating a CIColor Object with Preset Components

blackColor

Returns a color object whose RGB values are all 0.0 and whose alpha value is 1.0.

blueColor

Returns a color object whose RGB values are 0.0, 0.0, and 1.0 and whose alpha value is 1.0.

clearColor

Returns a color object whose RGB and alpha values are all 0.0.

cyanColor

Returns a color object whose RGB values are 0.0, 1.0, and 1.0 and whose alpha value is 1.0.

grayColor

Returns a color object whose RGB values are all 0.5 and whose alpha value is 1.0.

greenColor

Returns a color object whose RGB values are 0.0, 1.0, and 0.0 and whose alpha value is 1.0.

magentaColor

Returns a color object whose RGB values are 1.0, 0.0, and 1.0 and whose alpha value is 1.0.

redColor

Returns a color object whose RGB values are 1.0, 0.0, and 0.0 and whose alpha value is 1.0.

whiteColor

Returns a color object whose RGB values are all 1.0 and whose alpha value is 1.0.

yellowColor

Returns a color object whose RGB values are 1.0, 1.0, and 0.0 and whose alpha value is 1.0.

Relationships

Inherits From

See Also

Filter Parameters

CIVector

A container for coordinate values, direction vectors, matrices, and other non-scalar values, typically used in Core Image for filter parameters.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software