• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EPS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EPS


  • Subject: Re: EPS
  • From: has <email@hidden>
  • Date: Fri, 12 Sep 2008 20:05:48 +0100

Georg Seifert wrote:

 [NSView dataWithEPSInsideRect:] does not seem to help, unless I
build a dummy view, draw in it and then use this method.

I believe that's the general idea. An NSBezierPath instance by itself doesn't really do anything unless/until you draw it into a suitable graphics context. Read the Cocoa Drawing Guide; in particular, the 'Creating Graphics Contexts' chapter.


but this seems to be quite complicated.


I'm no graphics guru (so try not to laugh), but here's a simple example:


/////// CustomView.h ///////

#import <Cocoa/Cocoa.h>

@interface CustomView : NSView {
}

- (NSEPSImageRep *)epsImageRep;

@end


/////// CustomView.m ///////

#import "CustomView.h"

@implementation CustomView

- (void)drawRect:(NSRect)rect {
// do all your drawing here... e.g. to draw a black rectangle in middle of view:
[[NSBezierPath bezierPathWithRect: NSMakeRect(10, 10, 20, 20)] fill];
}


- (NSEPSImageRep *)epsImageRep {
	NSData* theData = [self dataWithEPSInsideRect: [self bounds]];
	return [NSEPSImageRep imageRepWithData: theData];
}

@end


/////// main.m ///////

int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

// create a custom view of the desired size
CustomView *view = [[CustomView alloc] initWithFrame: NSMakeRect(0, 0, 40, 40)];

// extract an EPS image rep from it
NSEPSImageRep *epsRep = [view epsImageRep];


// do some stuff with the EPS image rep here... e.g. to write to file:
[[epsRep EPSRepresentation] writeToFile: @"/Users/foobar/test.eps" atomically: NO];

[view release];
[pool release];
return 0;
}



HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Newb: Targeting an instance of a class instantiated by a NIB file
  • Next by Date: Re: when should my NSWindowController be released?
  • Previous by thread: Re: EPS
  • Next by thread: HTTP chunked transfer encoding implementation
  • Index(es):
    • Date
    • Thread