Mac Developer Library

Developer

AppKit Framework Reference NSColorSpace Class Reference

Options
Deployment Target:

On This Page
Language:

NSColorSpace

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.4 and later.

The NSColorSpace class enables the creation of objects representing custom color spaces. You can make custom color spaces from ColorSync profiles or from ICC profiles. NSColorSpace also has factory methods that return objects representing the system color spaces.

You can use the colorWithColorSpace:components:count: method of the NSColor class to create color objects using custom NSColorSpace objects. You can also send the colorUsingColorSpace: message to an NSColor object to convert it between two color spaces, either of which may be a custom color space.

  • Returns an NSColorSpace object representing a calibrated or device-dependent RGB color space.

    Declaration

    Swift

    class func deviceRGBColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)deviceRGBColorSpace

    Return Value

    The NSColorSpace object. This color space has red, green, blue, and alpha components. Typical devices that use the color-additive RGB color space are displays and scanners. This object corresponds to the Cocoa color space name NSDeviceRGBColorSpace.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing a device-independent RGB color space.

    Declaration

    Swift

    class func genericRGBColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)genericRGBColorSpace

    Return Value

    The NSColorSpace object. This color-additive color space has red, green, blue, and alpha components. This object corresponds to the Cocoa color space name NSCalibratedRGBColorSpace.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing a calibrated or device-dependent CMYK color space.

    Declaration

    Swift

    class func deviceCMYKColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)deviceCMYKColorSpace

    Return Value

    The NSColorSpace object. This color space has cyan, magenta, yellow, black, and alpha components. Typical devices that use the color-subtractive CMYK color space are color printers. This object corresponds to the Cocoa color space name NSDeviceCMYKColorSpace.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing a device-independent CMYK color space.

    Declaration

    Swift

    class func genericCMYKColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)genericCMYKColorSpace

    Return Value

    The NSColorSpace object. This color space has cyan, magenta, yellow, black and alpha component.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing a calibrated or device-dependent gray color space.

    Declaration

    Swift

    class func deviceGrayColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)deviceGrayColorSpace

    Return Value

    The NSColorSpace object. The color space also includes an alpha component. Typical devices that use this color space are grayscale printers and displays. This object corresponds to the Cocoa color space name NSDeviceWhiteColorSpace.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing a device-independent gray color space.

    Declaration

    Swift

    class func genericGrayColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)genericGrayColorSpace

    Return Value

    The NSColorSpace object. The color space also includes an alpha component. This object corresponds to the Cocoa color space name NSCalibratedWhiteColorSpace.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColorSpace object representing an sRGB color space.

    Declaration

    Swift

    class func sRGBColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)sRGBColorSpace

    Return Value

    The NSColorSpace object. This color-additive color space has red, green, blue, and alpha components.

    Discussion

    The sRGB color space is a standard color space for use on monitors, printers, and the Internet. For further information on sRGB, see http://www.color.org/srgb.html.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns an NSColorSpace object representing a gray color space with a gamma value of 2.2.

    Declaration

    Swift

    class func genericGamma22GrayColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)genericGamma22GrayColorSpace

    Return Value

    The NSColorSpace object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Returns an NSColorSpace object representing an Adobe RGB (1998) color space.

    Declaration

    Swift

    class func adobeRGB1998ColorSpace() -> NSColorSpace

    Objective-C

    + (NSColorSpace *)adobeRGB1998ColorSpace

    Return Value

    The NSColorSpace object. This color-additive color space has red, green, blue, and alpha components.

    Discussion

    The Adobe RGB (1998) color space was designed to encompass most of the colors achievable on CMYK color printers, but by using RGB primary colors on a device such as the computer display. For more information on this color space, go to http://www.adobe.com/digitalimag/adobergb.html.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the list of color spaces available on the system that are displayed in the color panel, in the order they are displayed in the color panel.

    Declaration

    Swift

    class func availableColorSpacesWithModel(_ model: NSColorSpaceModel) -> [AnyObject]

    Objective-C

    + (NSArray *)availableColorSpacesWithModel:(NSColorSpaceModel)model

    Parameters

    model

    The model to return the color spaces for.

    Return Value

    The list of color spaces, or an empty array if no color spaces are available for the specified model.

    Discussion

    This method doesn’t return color spaces created on the fly or spaces without user-displayable names. Pass NSUnknownColorSpaceModel as model to get all available color spaces.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Initializes and returns an NSColorSpace object initialized from a Core Graphics color-space object.

    Declaration

    Swift

    init?(CGColorSpace cgColorSpace: CGColorSpace)

    Objective-C

    - (instancetype)initWithCGColorSpace:(CGColorSpaceRef)cgColorSpace

    Parameters

    cgColorSpace

    A reference to a Core Graphics color-space object (CGColorSpaceRef).

    Return Value

    The initialized NSColorSpace object or nil if initialization was not successful, which might happen if the color space represented by the CGColorSpace object is not supported by NSColorSpace.

    Discussion

    Because NSColorSpace might retain or copy the CGColorSpace object depending on circumstances, you should not assume pointer equality of the provided object with that returned by CGColorSpace. And even if the pointer equality is preserved during runtime, it may not be after the NSColorSpace object is archived and unarchived.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Initializes and returns an NSColorSpace object given a ColorSync profile.

    Declaration

    Swift

    init?(colorSyncProfile prof: UnsafeMutablePointer<Void>)

    Objective-C

    - (instancetype)initWithColorSyncProfile:(void *)prof

    Parameters

    prof

    The ColorSync profile to use when initializing the NSColorSpace object. This should be an object of opaque type CMProfileRef. See ColorSync Manager Reference for further information on CMProfileRef.

    Return Value

    The initialized NSColorSpace object or nil if initialization was not successful.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Initializes and returns an NSColorSpace object given an ICC profile.

    Declaration

    Swift

    init?(ICCProfileData iccData: NSData)

    Objective-C

    - (instancetype)initWithICCProfileData:(NSData *)iccData

    Parameters

    iccData

    The ICC profile to use when initializing the NSColorSpace object. For information on ICC profiles, see the latest ICC specification at the International Color Consortium website.

    Return Value

    The initialized NSColorSpace object or nil if initialization was not successful.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns a Core Graphics color-space object that represents a color space equivalent to the receiver’s.

    Declaration

    Swift

    var CGColorSpace: CGColorSpace? { get }

    Objective-C

    @property(readonly) CGColorSpaceRef CGColorSpace

    Return Value

    A reference to an Core Graphics color-space object (CGColorSpaceRef) or NULL if the type of color space represented by the receiver cannot be represented by a CGColorSpace object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the model on which the color space of the receiver is based.

    Declaration

    Swift

    var colorSpaceModel: NSColorSpaceModel { get }

    Objective-C

    @property(readonly) NSColorSpaceModel colorSpaceModel

    Return Value

    A constant specifying the color space model of the receiver. See Color Space Models for a list of valid NSColorSpaceModel constants.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the ColorSync profile from which the receiver was created.

    Declaration

    Swift

    var colorSyncProfile: UnsafeMutablePointer<Void> { get }

    Objective-C

    @property(readonly) void *colorSyncProfile

    Return Value

    The ColorSync profile on which the receiver is based. You need to cast this value to an object of opaque type CMProfileRef. Returns NULL if the receiver was created from a ICC-profile data instead. See ColorSync Manager Reference for further information on CMProfileRef.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the ICC profile data from which the receiver was created.

    Declaration

    Swift

    var ICCProfileData: NSData? { get }

    Objective-C

    @property(readonly, strong) NSData *ICCProfileData

    Return Value

    The ICC profile from which the receiver was created. This method attempts to compute the profile data from a CMProfileRef object and returns nil if it is unable to.

    For information on ICC profiles, see the latest ICC specification at the International Color Consortium website.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the localized name of the receiver.

    Declaration

    Swift

    var localizedName: String? { get }

    Objective-C

    @property(readonly, copy) NSString *localizedName

    Return Value

    The name of the color space as a localized string or nil if no localized name exists.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the number of components supported by the receiver.

    Declaration

    Swift

    var numberOfColorComponents: Int { get }

    Objective-C

    @property(readonly) NSInteger numberOfColorComponents

    Return Value

    The number of components (excluding alpha) the receiver supports or zero if the receiver is not based on float components.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

Data Types

  • The type of the color-space mode constants listed in Color Space Models.

    Declaration

    Swift

    enum NSColorSpaceModel : Int { case NSUnknownColorSpaceModel case NSGrayColorSpaceModel case NSRGBColorSpaceModel case NSCMYKColorSpaceModel case NSLABColorSpaceModel case NSDeviceNColorSpaceModel case NSIndexedColorSpaceModel case NSPatternColorSpaceModel }

    Objective-C

    typedef NSInteger NSColorSpaceModel;

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Identify the abstract model on which an NSColorSpace object is based.

    Declaration

    Swift

    case NSUnknownColorSpaceModel case NSGrayColorSpaceModel case NSRGBColorSpaceModel case NSCMYKColorSpaceModel case NSLABColorSpaceModel case NSDeviceNColorSpaceModel case NSIndexedColorSpaceModel case NSPatternColorSpaceModel

    Objective-C

    typedef enum { NSUnknownColorSpaceModel = -1, NSGrayColorSpaceModel, NSRGBColorSpaceModel, NSCMYKColorSpaceModel, NSLABColorSpaceModel, NSDeviceNColorSpaceModel, NSIndexedColorSpaceModel, NSPatternColorSpaceModel };

    Constants

    • NSUnknownColorSpaceModel

      NSUnknownColorSpaceModel

      This model is not known to NSColorSpace.

      Available in OS X v10.4 and later.

    • NSGrayColorSpaceModel

      NSGrayColorSpaceModel

      The grayscale color-space model. Can refer to both device-dependent and generic color space variants.

      Available in OS X v10.4 and later.

    • NSRGBColorSpaceModel

      NSRGBColorSpaceModel

      The RGB (red green blue) color-space model. Can refer to both device-dependent and generic color space variants.

      Available in OS X v10.4 and later.

    • NSCMYKColorSpaceModel

      NSCMYKColorSpaceModel

      The CYMK (cyan, yellow, magenta, black) color-space model. Can refer to both device-dependent and generic color space variants.

      Available in OS X v10.4 and later.

    • NSLABColorSpaceModel

      NSLABColorSpaceModel

      The L*a*b* device-independent color-space model, which represents colors relative to a reference white point.

      Available in OS X v10.4 and later.

    • NSDeviceNColorSpaceModel

      NSDeviceNColorSpaceModel

      DeviceN is a color-space model from Adobe Systems, Inc. used in PostScript and PDF color specification.

      Available in OS X v10.4 and later.

    • NSIndexedColorSpaceModel

      NSIndexedColorSpaceModel

      An indexed color space, which identifies specified discrete colors in a color list by index number. An indexed color value (a color specification in indexed color space) consists of an index value that refers to a color in a color list.

      Available in OS X v10.5 and later.

    • NSPatternColorSpaceModel

      NSPatternColorSpaceModel

      Identifies a pattern color space, which is simply an image that is repeated over and over again in a tiled pattern.

      Available in OS X v10.5 and later.

    Discussion

    These constants are returned from colorSpaceModel and are derived from the profile data encapsulated by the object.