Re: "Headless" NSImage?
Re: "Headless" NSImage?
- Subject: Re: "Headless" NSImage?
- From: Don Yacktman <email@hidden>
- Date: Fri, 20 May 2005 01:42:39 -0600
On May 19, 2005, at 7:24 PM, James Bucanek wrote:
My question:
I'm going to be generating the icons and converting them to TIFF in a
faceless background daemon. While this is an Obj-C program, it is not
running the AppKit. Will NSImage, and specifically drawing into an
NSImage, and image->TIFF conversion work under these circumstances?
Not a problem -- it has been possible to use NSImage "headless" since
the NeXT days. The main things you need to know are (1) you still have
to link with the AppKit and (2) you do have to initialize an
NSApplication instance so that the proper connections are made to the
graphics subsystems. Something like this is will do the trick:
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication]; // NSImage won't work right if
you don't create an app instance
// ----- Do your image manipulation work here! -----
[pool release];
return 0;
}
Note that this works for command line tools and the binary does not
have to be inside of an app wrapper. You should be able to just drop
it into /usr/local/bin/ and have it work fine.
--
Later,
Don Yacktman
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden