NSColorSpace Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.4 and later. |
| Companion guide | |
| Declared in | NSColorSpace.h |
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
-
+ deviceRGBColorSpace -
+ genericRGBColorSpace -
+ deviceCMYKColorSpace -
+ genericCMYKColorSpace -
+ deviceGrayColorSpace -
+ genericGrayColorSpace -
+ sRGBColorSpace -
+ genericGamma22GrayColorSpace -
+ adobeRGB1998ColorSpace
Getting the Color Spaces Available On the System
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.
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
- Available in OS X v10.5 and later.
Declared In
NSColorSpace.havailableColorSpacesWithModel:
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.
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.
Availability
- Available in OS X v10.6 and later.
Declared In
NSColorSpace.hdeviceCMYKColorSpace
Returns an NSColorSpace object representing a calibrated or device-dependent CMYK color space.
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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hdeviceGrayColorSpace
Returns an NSColorSpace object representing a calibrated or device-dependent gray color space.
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
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hdeviceRGBColorSpace
Returns an NSColorSpace object representing a calibrated or device-dependent RGB color space.
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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hgenericCMYKColorSpace
Returns an NSColorSpace object representing a device-independent CMYK color space.
Return Value
The NSColorSpace object. This color space has cyan, magenta, yellow, black and alpha component.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hgenericGamma22GrayColorSpace
Returns an NSColorSpace object representing a gray color space with a gamma value of 2.2.
Return Value
The NSColorSpace object.
Availability
- Available in OS X v10.6 and later.
Declared In
NSColorSpace.hgenericGrayColorSpace
Returns an NSColorSpace object representing a device-independent gray color space.
Return Value
The NSColorSpace object. The color space also includes an alpha component. This object corresponds to the Cocoa color space name NSCalibratedWhiteColorSpace.
Availability
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hgenericRGBColorSpace
Returns an NSColorSpace object representing a device-independent RGB color space.
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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hsRGBColorSpace
Returns an NSColorSpace object representing an sRGB color space.
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
- Available in OS X v10.5 and later.
Declared In
NSColorSpace.hInstance Methods
CGColorSpace
Returns a Core Graphics color-space object that represents a color space equivalent to the receiver’s.
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
- Available in OS X v10.5 and later.
See Also
Declared In
NSColorSpace.hcolorSpaceModel
Returns the model on which the color space of the receiver is based.
Return Value
A constant specifying the color space model of the receiver. See Color Space Models for a list of valid NSColorSpaceModel constants.
Availability
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hcolorSyncProfile
Returns the ColorSync profile from which the receiver was created.
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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hICCProfileData
Returns the ICC profile data from which the receiver was created.
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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hinitWithCGColorSpace:
Initializes and returns an NSColorSpace object initialized from a Core Graphics color-space object.
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
- Available in OS X v10.5 and later.
Declared In
NSColorSpace.hinitWithColorSyncProfile:
Initializes and returns an NSColorSpace object given a ColorSync profile.
Parameters
- prof
The ColorSync profile to use when initializing the
NSColorSpaceobject. 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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hinitWithICCProfileData:
Initializes and returns an NSColorSpace object given an ICC profile.
Parameters
- iccData
The ICC profile to use when initializing the
NSColorSpaceobject. 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
- Available in OS X v10.4 and later.
See Also
Declared In
NSColorSpace.hlocalizedName
Returns the localized name of the receiver.
Return Value
The name of the color space as a localized string or nil if no localized name exists.
Availability
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hnumberOfColorComponents
Returns the number of components supported by the receiver.
Return Value
The number of components (excluding alpha) the receiver supports or zero if the receiver is not based on float components.
Availability
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hConstants
NSColorSpaceModel
The type of the color-space mode constants listed in “Color Space Models.”
typedef NSInteger NSColorSpaceModel;
Availability
- Available in OS X v10.4 and later.
Declared In
NSColorSpace.hColor 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
NSUnknownColorSpaceModelThis model is not known to
NSColorSpace.Available in OS X v10.4 and later.
Declared in
NSColorSpace.h.NSGrayColorSpaceModelThe grayscale color-space model. Can refer to both device-dependent and generic color space variants.
Available in OS X v10.4 and later.
Declared in
NSColorSpace.h.NSRGBColorSpaceModelThe 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.
Declared in
NSColorSpace.h.NSCMYKColorSpaceModelThe 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.
Declared in
NSColorSpace.h.NSLABColorSpaceModelThe 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.
Declared in
NSColorSpace.h.NSDeviceNColorSpaceModelDeviceN is a color-space model from Adobe Systems, Inc. used in PostScript and PDF color specification.
Available in OS X v10.4 and later.
Declared in
NSColorSpace.h.NSIndexedColorSpaceModelAn 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.
Declared in
NSColorSpace.h.NSPatternColorSpaceModelIdentifies 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.
Declared in
NSColorSpace.h.
Discussion
These constants are returned from colorSpaceModel and are derived from the profile data encapsulated by the object.
Declared In
NSColorSpace.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-03-12)