Retired Document
Important: Retired Document: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Setting the ColorSync profile for a NSBitmapImageRep object
Q:
I'd like to associate a ColorSync profile with a given NSBitmapImageRep object for color-matching purposes. Is there a simple way to do this?
A: I'd like to associate a ColorSync profile with a given NSBitmapImageRep object for color-matching purposes. Is there a simple way to do this?
You can associate a ColorSync profile with a -setProperty: method and the NSImageColorSyncProfileData property.
Here's a short code snippet showing how it's done:
Listing 1 Setting the ColorSync profile for a NSBitmapImageRep object.
//
// imageRepWithProfileAtPath
//
// Associate a given file-based ColorSync profile with
// a NSBitmapImageRep object
//
// Inputs:
//
// aPath - file path for a ColorSync profile
//
// Outputs:
//
// - returns a new NSBitmapImageRep object, created
// by copying the receiver and applying the ColorSync
// profile.
@implementation NSBitmapImageRep (MoreColorMethods)
- (NSBitmapImageRep *) imageRepWithProfileAtPath:(NSString *) pathToProfile
{
id result = [self copy];
// build a NSData object for our ColorSync profile file
id profile = [NSData dataWithContentsOfFile: pathToProfile];
// now set the ColorSync profile for the object
[result setProperty:NSImageColorSyncProfileData withValue:profile];
return [result autorelease];
}
@end |
Document Revision History
| Date | Notes |
|---|---|
| 2018-06-04 | Moved to Retired Documents Library. |
| 2004-09-08 | New document that setting the ColorSync profile for a NSBitmapImageRep object |
Copyright © 2018 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2018-06-04