Using NSImage/NSBitmapImageRep stuff in command line tools
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.