mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 00:51:02 +00:00
Complete NSPICTImageRep implementation
This commit is contained in:
parent
325dbe5ac6
commit
6adaf911b5
4 changed files with 63 additions and 16 deletions
|
@ -86,10 +86,10 @@
|
|||
if(self != nil)
|
||||
{
|
||||
#if HAVE_IMAGEMAGICK
|
||||
ASSIGN(_pageReps, [GSImageMagickImageRep imageRepsWithData: epsData]);
|
||||
_size = [[_pageReps objectAtIndex: 0] size];
|
||||
ASSIGN(_pageRep, [GSImageMagickImageRep imageRepWithData: epsData]);
|
||||
_size = [_pageRep size];
|
||||
#else
|
||||
ASSIGN(_pageReps, [NSArray array]);
|
||||
_pageRep = nil;
|
||||
_size = NSMakeSize(0,0);
|
||||
#endif
|
||||
ASSIGNCOPY(_epsData, epsData);
|
||||
|
@ -101,7 +101,7 @@
|
|||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_epsData);
|
||||
RELEASE(_pageReps);
|
||||
RELEASE(_pageRep);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -128,12 +128,11 @@
|
|||
{
|
||||
NSRect irect = NSMakeRect(0, 0, _size.width, _size.height);
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
NSBitmapImageRep *rep = [_pageReps objectAtIndex: 0]; // can EPS have multiple pages?
|
||||
|
||||
[self prepareGState];
|
||||
|
||||
[rep _premultiply];
|
||||
[ctxt GSDrawImage: irect : rep];
|
||||
[_pageRep _premultiply];
|
||||
[ctxt GSDrawImage: irect : _pageRep];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,31 +21,71 @@
|
|||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <AppKit/NSPICTImageRep.h>
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <GNUstepGUI/GSImageMagickImageRep.h>
|
||||
|
||||
@interface NSBitmapImageRep (PrivateMethods)
|
||||
- (void) _premultiply;
|
||||
@end
|
||||
|
||||
@implementation NSPICTImageRep
|
||||
|
||||
+ (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;
|
||||
}
|
||||
|
||||
+ (instancetype) imageRepWithData: (NSData *)imageData
|
||||
{
|
||||
return AUTORELEASE([[self alloc] initWithData: imageData]);
|
||||
return [[[self class] alloc] initWithData: imageData];
|
||||
}
|
||||
|
||||
- (instancetype) initWithData: (NSData *)imageData
|
||||
{
|
||||
self = [super initWithData: imageData];
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
#if HAVE_IMAGEMAGICK
|
||||
|
||||
ASSIGN(_pageRep, [GSImageMagickImageRep imageRepWithData: imageData]);
|
||||
_size = [_pageRep size];
|
||||
#else
|
||||
_pageRep = nil;
|
||||
_size = NSMakeSize(0,0);
|
||||
#endif
|
||||
ASSIGNCOPY(_pictRepresentation, imageData);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSRect) boundingBox
|
||||
{
|
||||
return _boundingBox;
|
||||
NSSize size = [self size];
|
||||
NSRect rect = NSMakeRect(0, 0, size.width, size.height);
|
||||
return rect;
|
||||
}
|
||||
|
||||
- (NSData *) PICTRepresentation
|
||||
|
@ -53,5 +93,15 @@
|
|||
return [_pictRepresentation copy];
|
||||
}
|
||||
|
||||
// Override to draw the specified page...
|
||||
- (BOOL) draw
|
||||
{
|
||||
NSRect irect = NSMakeRect(0, 0, _size.width, _size.height);
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
|
||||
[_pageRep _premultiply];
|
||||
[ctxt GSDrawImage: irect : _pageRep];
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue