Re: Using NSImage/NSBitmapImageRep stuff in command line tools
Re: Using NSImage/NSBitmapImageRep stuff in command line tools
- Subject: Re: Using NSImage/NSBitmapImageRep stuff in command line tools
- From: Florent Pillet <email@hidden>
- Date: Tue, 30 Sep 2003 15:10:02 +0200
Hmm after checking the archives, it looks like I'm hitting the
"NSBMPFileType doesn't really work" problem. If I get a NSPNGFileType
representation, everything works fine. However, NSBMPFileType always
return nil. Grr.
Florent
On mardi, sep 30, 2003, at 10:27 Europe/Paris, Florent Pillet wrote:
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.
--
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.