libs-gui/Source/NSPICTImageRep.m

99 lines
2.3 KiB
Mathematica
Raw Normal View History

2019-11-18 10:23:30 +00:00
/* Implementation of class NSPICTImageRep
Copyright (C) 2019 Free Software Foundation, Inc.
2019-11-29 18:01:42 +00:00
By: Gregory Casamento <greg.casamento@gmail.com>
2019-11-18 10:23:30 +00:00
Date: Fri Nov 15 04:24:51 EST 2019
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
2019-11-18 10:23:30 +00:00
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
2019-11-18 10:23:30 +00:00
*/
2019-12-04 13:40:35 +00:00
#import "config.h"
2019-11-18 10:23:30 +00:00
2019-12-04 13:40:35 +00:00
#import <AppKit/NSPICTImageRep.h>
#import <AppKit/NSPasteboard.h>
#import <Foundation/NSData.h>
#import <Foundation/NSArray.h>
#import <GNUstepGUI/GSImageMagickImageRep.h>
2019-12-03 13:30:17 +00:00
2019-11-18 10:23:30 +00:00
@implementation NSPICTImageRep
2019-12-03 13:30:17 +00:00
+ (NSArray *) imageUnfilteredFileTypes
{
static NSArray *types = nil;
if (types == nil)
{
types = [[NSArray alloc] initWithObjects: @"pct", @"pict", nil];
}
return types;
}
+ (NSArray *) imageUnfilteredPasteboardTypes
{
static NSArray *types = nil;
if (types == nil)
{
types = [[NSArray alloc] initWithObjects: NSPICTPboardType, nil];
}
return types;
}
2019-11-22 07:52:31 +00:00
+ (instancetype) imageRepWithData: (NSData *)imageData
{
2019-12-03 13:30:17 +00:00
return [[[self class] alloc] initWithData: imageData];
2019-11-22 07:52:31 +00:00
}
- (instancetype) initWithData: (NSData *)imageData
{
2019-12-03 13:30:17 +00:00
self = [super init];
2019-11-22 07:52:31 +00:00
if (self != nil)
{
#if HAVE_IMAGEMAGICK
2019-12-03 13:30:17 +00:00
ASSIGN(_pageRep, [GSImageMagickImageRep imageRepWithData: imageData]);
_size = [_pageRep size];
#else
_pageRep = nil;
_size = NSMakeSize(0,0);
#endif
2019-12-03 13:30:17 +00:00
ASSIGNCOPY(_pictRepresentation, imageData);
2019-11-22 07:52:31 +00:00
}
return self;
}
- (NSRect) boundingBox
{
2019-12-03 13:30:17 +00:00
NSSize size = [self size];
NSRect rect = NSMakeRect(0, 0, size.width, size.height);
return rect;
2019-11-22 07:52:31 +00:00
}
- (NSData *) PICTRepresentation
{
return [_pictRepresentation copy];
}
2019-12-03 13:30:17 +00:00
// Override to draw the specified page...
- (BOOL) draw
{
return [_pageRep draw];
2019-12-03 13:30:17 +00:00
}
2019-11-18 10:23:30 +00:00
@end