2007-07-31 20:50:44 +00:00
|
|
|
/*
|
|
|
|
NSColorSpace.h
|
|
|
|
|
|
|
|
The color space class
|
|
|
|
|
|
|
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: H. Nikolaus Schaller <hns@computer.org>
|
|
|
|
Date: 2007
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2007-07-31 20:50:44 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
2007-07-31 20:50:44 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2007-07-31 20:50:44 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2007-07-31 20:50:44 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
2007-07-31 20:50:44 +00:00
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2010-03-24 22:41:21 +00:00
|
|
|
#import <Foundation/NSCoder.h>
|
|
|
|
#import <Foundation/NSData.h>
|
|
|
|
#import <Foundation/NSString.h>
|
2007-07-31 20:50:44 +00:00
|
|
|
#import <AppKit/NSColorSpace.h>
|
2010-03-24 22:41:21 +00:00
|
|
|
#import "GSGuiPrivate.h"
|
2007-07-31 20:50:44 +00:00
|
|
|
|
|
|
|
@implementation NSColorSpace
|
|
|
|
|
|
|
|
- (id) _initWithColorSpaceModel: (NSColorSpaceModel)model
|
|
|
|
{
|
2009-10-21 07:12:12 +00:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2007-07-31 20:50:44 +00:00
|
|
|
// FIXME: Load corresponding data
|
|
|
|
|
|
|
|
_colorSpaceModel = model;
|
2009-10-21 07:12:12 +00:00
|
|
|
}
|
|
|
|
return self;
|
2007-07-31 20:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define COLORSPACE(model) \
|
2009-11-03 21:32:52 +00:00
|
|
|
static NSColorSpace *csp = nil; \
|
2009-10-21 07:12:12 +00:00
|
|
|
if (!csp) \
|
|
|
|
csp = [[self alloc] _initWithColorSpaceModel: model]; \
|
|
|
|
return csp;
|
2007-07-31 20:50:44 +00:00
|
|
|
|
|
|
|
+ (NSColorSpace *) deviceCMYKColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSCMYKColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSColorSpace *) deviceGrayColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSGrayColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSColorSpace *) deviceRGBColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSRGBColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSColorSpace *) genericCMYKColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSCMYKColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSColorSpace *) genericGrayColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSGrayColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSColorSpace *) genericRGBColorSpace
|
|
|
|
{
|
|
|
|
COLORSPACE(NSRGBColorSpaceModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithColorSyncProfile: (void *)prof
|
|
|
|
{
|
2009-10-21 07:12:12 +00:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2007-07-31 20:50:44 +00:00
|
|
|
_colorSyncProfile = prof;
|
|
|
|
_colorSpaceModel = NSUnknownColorSpaceModel;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithICCProfileData: (NSData *)iccData
|
|
|
|
{
|
2009-10-21 07:12:12 +00:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2007-07-31 20:50:44 +00:00
|
|
|
ASSIGN(_iccData, iccData);
|
|
|
|
_colorSpaceModel = NSUnknownColorSpaceModel;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) dealloc
|
|
|
|
{
|
|
|
|
// FIXME: Free _colorSyncProfile
|
|
|
|
TEST_RELEASE(_iccData);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSColorSpaceModel) colorSpaceModel
|
|
|
|
{
|
|
|
|
return _colorSpaceModel;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void *) colorSyncProfile
|
|
|
|
{
|
|
|
|
return _colorSyncProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSData *) ICCProfileData
|
|
|
|
{
|
|
|
|
if (!_iccData)
|
|
|
|
{
|
|
|
|
// FIXME: Try to compute this from _colorSyncProfile
|
|
|
|
}
|
|
|
|
return _iccData;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) localizedName
|
|
|
|
{
|
|
|
|
switch (_colorSpaceModel)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case NSUnknownColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"unknown", @"color space");
|
|
|
|
case NSGrayColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"Grayscale", @"color space");
|
|
|
|
case NSRGBColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"RGB", @"color space");
|
|
|
|
case NSCMYKColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"CMYK", @"color space");
|
|
|
|
case NSLABColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"LAB", @"color space");
|
|
|
|
case NSDeviceNColorSpaceModel:
|
|
|
|
return NSLocalizedString(@"DeviceN", @"color space");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) numberOfColorComponents
|
|
|
|
{
|
|
|
|
switch (_colorSpaceModel)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case NSUnknownColorSpaceModel: return 0;
|
|
|
|
case NSGrayColorSpaceModel: return 1;
|
|
|
|
case NSRGBColorSpaceModel: return 3;
|
|
|
|
case NSCMYKColorSpaceModel: return 4;
|
|
|
|
case NSLABColorSpaceModel: return 3; // FIXME
|
|
|
|
case NSDeviceNColorSpaceModel: return 3; // FIXME
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) encodeWithCoder: (NSCoder *)coder
|
|
|
|
{
|
|
|
|
// FIXME
|
2009-10-21 07:12:12 +00:00
|
|
|
if ([coder allowsKeyedCoding])
|
2007-07-31 20:50:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
|
|
|
{
|
|
|
|
// FIXME
|
2009-10-21 07:12:12 +00:00
|
|
|
if ([aDecoder allowsKeyedCoding])
|
2007-07-31 20:50:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
}
|
2009-10-21 07:12:12 +00:00
|
|
|
return self;
|
2007-07-31 20:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|