• 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: "Headless" NSImage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >"Headless" NSImage? (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: Plugin support for Apple's Mail application
  • Next by Date: Re: Plugin support for Apple's Mail application
  • Previous by thread: "Headless" NSImage?
  • Next by thread: CoreData, OutlineView, and NSTreeController
  • Index(es):
    • Date
    • Thread