NSImage with Core Foundation Console Application failed?
NSImage with Core Foundation Console Application failed?
- Subject: NSImage with Core Foundation Console Application failed?
- From: DairyKnight <email@hidden>
- Date: Tue, 8 Sep 2009 11:08:42 +0800
Hi all,
I'm trying to use NSImage in a Cocoa Console App, but every time I tried to
save the NSImage into a file through NSImageRep, it failed with
NSData.length = 0.
This is what I did:
NSImage *surface = [[NSImage alloc] initWithSize:NSMakeSize(786 * 2, 1144 *
2)];
NSBitmapImageRep *jpgRep = [NSBitmapImageRep imageRepWithData:[surface
TIFFRepresentation]];
NSDictionary *jpgProp = [NSDictionary dictionaryWithObject:[NSNumber
numberWithFloat:0.7] forKey:NSImageCompressionFactor];
NSData *dat = [jpgRep representationUsingType:NSJPEGFileType properties
:jpgProp];
if ([dat length] == 0)
NSLog(@"Data is zero");
[dat writeToFile:@"dummyfile.jpg" atomically:YES];
Anyone knows why? Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden