Next Page > Hide TOC

NSColorSpace Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.4 and later.
Companion guide
Declared in
NSColorSpace.h
Related sample code

Overview

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.

Tasks

Getting a Named NSColorSpace Object

Initializing a Custom NSColorSpace Object

Accessing Color-Space Data and Attributes

Class Methods

adobeRGB1998ColorSpace

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

+ (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.

Availability
Declared In
NSColorSpace.h

deviceCMYKColorSpace

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

+ (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.

Availability
See Also
Declared In
NSColorSpace.h

deviceGrayColorSpace

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

+ (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.

Availability
See Also
Declared In
NSColorSpace.h

deviceRGBColorSpace

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

+ (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.

Availability
See Also
Declared In
NSColorSpace.h

genericCMYKColorSpace

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

+ (NSColorSpace *)genericCMYKColorSpace

Return Value

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

Availability
See Also
Declared In
NSColorSpace.h

genericGrayColorSpace

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

+ (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.

Availability
See Also
Declared In
NSColorSpace.h

genericRGBColorSpace

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

+ (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.

Availability
See Also
Related Sample Code
Declared In
NSColorSpace.h

sRGBColorSpace

Returns an NSColorSpace object representing an sRGB color space.

+ (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.

Availability
Declared In
NSColorSpace.h

Instance Methods

CGColorSpace

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

- (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.

Availability
See Also
Declared In
NSColorSpace.h

colorSpaceModel

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

- (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.

Availability
Declared In
NSColorSpace.h

colorSyncProfile

Returns the ColorSync profile from which the receiver was created.

- (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.

Availability
See Also
Declared In
NSColorSpace.h

ICCProfileData

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

- (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.

Availability
See Also
Declared In
NSColorSpace.h

initWithCGColorSpace:

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

- (id)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.

Availability
Declared In
NSColorSpace.h

initWithColorSyncProfile:

Initializes and returns an NSColorSpace object given a ColorSync profile.

- (id)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.

Availability
See Also
Declared In
NSColorSpace.h

initWithICCProfileData:

Initializes and returns an NSColorSpace object given an ICC profile.

- (id)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.

Availability
See Also
Declared In
NSColorSpace.h

localizedName

Returns the localized name of the receiver.

- (NSString *)localizedName

Return Value

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

Availability
Declared In
NSColorSpace.h

numberOfColorComponents

Returns the number of components supported by the receiver.

- (NSInteger)numberOfColorComponents

Return Value

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

Availability
Declared In
NSColorSpace.h

Constants

NSColorSpaceModel

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

typedef NSInteger NSColorSpaceModel;

Availability
Declared In
NSColorSpace.h

Color Space Models

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

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

Constants
NSUnknownColorSpaceModel

This model is not known to NSColorSpace.

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

NSGrayColorSpaceModel

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

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

NSRGBColorSpaceModel

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

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

NSCMYKColorSpaceModel

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

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

NSLABColorSpaceModel

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

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

NSDeviceNColorSpaceModel

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

Available in Mac OS X v10.4 and later.

Declared in NSColorSpace.h.

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 Mac OS X version 10.5 and later.

Declared in NSColorSpace.h.

NSPatternColorSpaceModel

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

Available in Mac OS X version 10.5 and later.

Declared in NSColorSpace.h.

Discussion

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

Availability
Declared In
NSColorSpace.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-28)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.