2002-10-09 02:47:40 +00:00
|
|
|
/** <title>GSFusedSilicaContext</title>
|
|
|
|
|
|
|
|
<abstract>Extention to NSGraphicsContext for necessary methods</abstract>
|
|
|
|
|
|
|
|
Copyright (C) 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Adam Fedor <fedor@gnu.org>
|
|
|
|
Date: Oct 2002
|
|
|
|
|
|
|
|
This file is part of the GNUStep
|
|
|
|
|
|
|
|
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
|
2002-10-09 02:47:40 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2007-10-29 21:16:17 +00:00
|
|
|
version 3 of the License, or (at your option) any later version.
|
|
|
|
|
2002-10-09 02:47:40 +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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2002-10-09 02:47:40 +00:00
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
#include "GSFusedSilicaContext.h"
|
|
|
|
#include "GNUstepGUI/GSFontInfo.h"
|
2003-06-13 15:01:12 +00:00
|
|
|
#include "AppKit/NSGraphics.h"
|
2002-10-09 02:47:40 +00:00
|
|
|
#include <Foundation/NSData.h>
|
|
|
|
#include <Foundation/NSDictionary.h>
|
|
|
|
#include <Foundation/NSValue.h>
|
|
|
|
|
|
|
|
#define NUMBER(num) \
|
|
|
|
[NSNumber numberWithInt: num]
|
|
|
|
#define FLOAT_ARRAY(ptr, count) \
|
|
|
|
[NSData dataWithBytes: ptr length: count*sizeof(float)]
|
|
|
|
|
|
|
|
@implementation NSGraphicsContext (FusedSilica)
|
|
|
|
|
|
|
|
/* Colorspaces */
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceGray
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: NSDeviceWhiteColorSpace
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: NUMBER(1) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceRGB
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: NSDeviceRGBColorSpace
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateDeviceCMYK
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: NSDeviceCMYKColorSpace
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: NUMBER(4) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedGray: (const float *)whitePoint
|
|
|
|
: (const float *)blackPoint
|
|
|
|
: (float)gamma
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: NSCalibratedWhiteColorSpace
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
|
|
|
|
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
|
|
|
|
[space setObject: NUMBER(1) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateCalibratedRGB: (const float *)whitePoint
|
|
|
|
: (const float *)blackPoint
|
|
|
|
: (const float *)gamma
|
|
|
|
: (const float *)matrix
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: NSCalibratedRGBColorSpace
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
|
|
|
|
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
|
|
|
|
[space setObject: FLOAT_ARRAY(gamma, 3) forKey: GSColorSpaceGamma];
|
|
|
|
[space setObject: FLOAT_ARRAY(matrix, 9) forKey: GSColorSpaceMatrix];
|
|
|
|
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateLab: (const float *)whitePoint
|
|
|
|
: (const float *)blackPoint
|
|
|
|
: (const float *) range
|
|
|
|
{
|
|
|
|
NSMutableDictionary *space;
|
2008-02-12 22:35:03 +00:00
|
|
|
space = [NSMutableDictionary dictionaryWithObject: @"NSLabColorSpace"
|
2002-10-09 02:47:40 +00:00
|
|
|
forKey: GSColorSpaceName];
|
|
|
|
[space setObject: FLOAT_ARRAY(whitePoint, 3) forKey: GSColorSpaceWhitePoint];
|
|
|
|
[space setObject: FLOAT_ARRAY(blackPoint, 3) forKey: GSColorSpaceBlackPoint];
|
|
|
|
[space setObject: FLOAT_ARRAY(range, 4) forKey: GSColorSpaceRange];
|
|
|
|
[space setObject: NUMBER(3) forKey: GSColorSpaceComponents];
|
|
|
|
return space;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateICCBased: (size_t) nComponents
|
|
|
|
: (const float *)range
|
|
|
|
: (CGDataProviderRef)profile
|
|
|
|
: (CGColorSpaceRef)alternateSpace
|
|
|
|
{
|
|
|
|
//FIXME
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceCreateIndexed: (CGColorSpaceRef)baseSpace
|
|
|
|
: (size_t)lastIndex
|
|
|
|
: (const unsigned short int *)colorTable
|
|
|
|
{
|
|
|
|
//FIXME
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (size_t) CGColorSpaceGetNumberOfComponents: (CGColorSpaceRef)cs
|
|
|
|
{
|
|
|
|
return [[(NSDictionary *)cs objectForKey: GSColorSpaceComponents] intValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGColorSpaceRef) CGColorSpaceRetain: (CGColorSpaceRef)cs
|
|
|
|
{
|
|
|
|
return [(NSDictionary *)cs retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) CGColorSpaceRelease: (CGColorSpaceRef)cs
|
|
|
|
{
|
2003-08-20 12:13:34 +00:00
|
|
|
[(NSDictionary *)cs release];
|
2002-10-09 02:47:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Fonts */
|
|
|
|
|
|
|
|
+ (CGFontRef) CGFontReferenceFromFont: (NSFont *)font
|
|
|
|
{
|
|
|
|
return [font fontInfo];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGFontRef) CGFontRetain: (CGFontRef) font
|
|
|
|
{
|
|
|
|
return [(GSFontInfo *)font retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) CGFontRelease: (CGFontRef) font
|
|
|
|
{
|
|
|
|
[(GSFontInfo *)font release];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|