Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSImage/NSBitmapImageRep stuff in command line tools



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.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.