iOS Developer Library

Developer

CoreImage Framework Reference CIColor Class Reference

Options
Deployment Target:

On This Page
Language:

CIColor

The CIColor class contains color values and the color space for which the color values are valid. 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. More...

Inheritance


Conforms To


Import Statement


import CoreImage @import CoreImage;

Availability


Available in iOS 5.0 and later.
  • Initializes a color object with a Quartz color.

    Declaration

    Swift

    init!(CGColor c: CGColor!)

    Objective-C

    - (id)initWithCGColor:(CGColorRef)c

    Parameters

    c

    A Quartz color (CGColorRef) created using a Quartz color creation function such as CGColorCreate.

    Discussion

    A CGColorRef object is the fundamental opaque data type used internally by Quartz to represent colors. For more information on Quartz 2D color and color spaces, see Quartz 2D Programming Guide.

    You can pass a CGColorRef object that represents any color space, including CMYK, but Core Image converts all color spaces to the Core Image working color space before it passes the color space to the filter kernel. The Core Image working color space uses three color components plus alpha.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

  • Creates a color object from a Quartz color.

    Declaration

    Objective-C

    + (CIColor *)colorWithCGColor:(CGColorRef)c

    Parameters

    c

    A Quartz color (CGColorRef object) created using a Quartz color creation function such as CGColorCreate.

    Return Value

    A Core Image color object that represents a Quartz color.

    Discussion

    A CGColorRef object is the fundamental opaque data type used internally by Quartz to represent colors. For more information on Quartz 2D color and color spaces, see Quartz 2D Programming Guide.

    You can pass a CGColorRef object that represents any color space, including CMYK, but Core Image converts all color spaces to the Core Image working color space before it passes the color space to the filter kernel. The Core Image working color space uses three color components plus alpha.

    Import Statement

    Availability

    Available in iOS 5.0 and later.

  • Creates a color object using the specified RGB color component values

    Declaration

    Swift

    init!(red r: CGFloat, green g: CGFloat, blue b: CGFloat) -> CIColor

    Objective-C

    + (CIColor *)colorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b

    Parameters

    r

    The value of the red component.

    g

    The value of the green component.

    b

    The value of the blue component.

    Return Value

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    init!(red r: CGFloat, green g: CGFloat, blue b: CGFloat, alpha a: CGFloat) -> CIColor

    Objective-C

    + (CIColor *)colorWithRed:(CGFloat)r green:(CGFloat)g blue:(CGFloat)b alpha:(CGFloat)a

    Parameters

    r

    The value of the red component.

    g

    The value of the green component.

    b

    The value of the blue component.

    a

    The value of the alpha component.

    Return Value

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB and an alpha value.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

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

    Declaration

    Swift

    init!(string representation: String!) -> CIColor

    Objective-C

    + (CIColor *)colorWithString:(NSString *)representation

    Parameters

    representation

    A string that is in one of the formats returned by the stringRepresentation method. For example, the string:

    @"0.5 0.7 0.3 1.0"

    indicates an RGB color whose components are 50% red, 70% green, 30% blue, and 100% opaque (alpha value of 1.0). The string representation always has four components—red, green, blue, and alpha. The default value for the alpha component is 1.0.

    Return Value

    A Core Image color object that represents an RGB color in the color space specified by the Quartz 2D constant kCGColorSpaceGenericRGB.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

  • Returns the alpha value of the color.

    Declaration

    Swift

    func alpha() -> CGFloat

    Objective-C

    - (CGFloat)alpha

    Return Value

    The alpha value. A color created without an explicit alpha value has an alpha of 1.0 by default.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns the blue component of the color.

    Declaration

    Swift

    func blue() -> CGFloat

    Objective-C

    - (CGFloat)blue

    Return Value

    The unpremultiplied blue component of the color.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns the Quartz 2D color space associated with the color.

    Declaration

    Swift

    func colorSpace() -> Unmanaged<CGColorSpace>!

    Objective-C

    - (CGColorSpaceRef)colorSpace

    Return Value

    The Quartz 2D color space (CGColorSpaceRef object).

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns the color components of the color.

    Declaration

    Swift

    func components() -> UnsafePointer<CGFloat>

    Objective-C

    - (const CGFloat *)components

    Return Value

    An array of color components, specified as floating-point values in the range of 0.0 through 1.0. This array includes an alpha component if there is one.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

  • Returns the green component of the color.

    Declaration

    Swift

    func green() -> CGFloat

    Objective-C

    - (CGFloat)green

    Return Value

    The unpremultiplied green component of the color.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns the number of color components in the color.

    Declaration

    Swift

    func numberOfComponents() -> UInt

    Objective-C

    - (size_t)numberOfComponents

    Return Value

    The number of color components, which includes an alpha component if there is one.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns the red component of the color.

    Declaration

    Swift

    func red() -> CGFloat

    Objective-C

    - (CGFloat)red

    Return Value

    The unpremultiplied red component of the color.

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components

  • Returns a formatted string that specifies the components of the color.

    Declaration

    Swift

    func stringRepresentation() -> String!

    Objective-C

    - (NSString *)stringRepresentation

    Return Value

    The formatted string.

    Discussion

    The string representation always has four components—red, green, blue, and alpha. The default value for the alpha component is 1.0.F or example, this string:

    @"0.5 0.7 0.3 1.0"

    indicates an RGB color whose components are 50% red, 70% green, 30% blue, and 100% opaque (alpha value of 1.0).

    Import Statement

    import CoreImage

    Availability

    Available in iOS 5.0 and later.

    See Also

    – components