• 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
Using NSImage/NSBitmapImageRep stuff in command line tools
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSImage/NSBitmapImageRep stuff in command line tools


  • Subject: Using NSImage/NSBitmapImageRep stuff in command line tools
  • From: Florent Pillet <email@hidden>
  • Date: Tue, 30 Sep 2003 10:27:44 +0200

I want to have a tool that manipulates images through the use of NSImage, then generates bmp data using NSBitmapImageRep's -representationUsingType selector. Right now, I've found that I need to do:

NSApplication *app = [NSApplication sharedApplication];

in my tool's main() so that NSImage doesn't crash. I guess that's because it needs some kind of connection to the Window Server, which is fine with me.

But the problem is that the following code in my NSImage category returns NULL:

- (NSData *)BMPData
{
NSRect r = [self rect];
[self lockFocus];
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:r];
[self unlockFocus];
NSData *bmpData = [rep representationUsingType:NSBMPFileType properties:[NSDictionary dictionary]];
[rep release];
return bmpData;
}

I suspect that it's because the tool doesn't have a "real" window at all, but since there is no specific exception or log from the system, I can't be sure.

Any lead on this ?

Thanks,
Florent.

--
Florent Pillet, Code Segment email@hidden
Developer tools and end-user products for Palm OS & Mac OS X
ICQ: 117292463 http://perso.wanadoo.fr/fpillet
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Using NSImage/NSBitmapImageRep stuff in command line tools
      • From: Florent Pillet <email@hidden>
  • Prev by Date: different launch methods
  • Next by Date: Re: Cocoa graphics speed
  • Previous by thread: Re: Safari under the mouse?
  • Next by thread: Re: Using NSImage/NSBitmapImageRep stuff in command line tools
  • Index(es):
    • Date
    • Thread