• 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
NSImage with Core Foundation Console Application failed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSImage with Core Foundation Console Application failed?
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Menu Weirdness (can't set command + 3 or command + 4)
  • Next by Date: Re: NSImage with Core Foundation Console Application failed?
  • Previous by thread: Re: UIWebView height calculation
  • Next by thread: Re: NSImage with Core Foundation Console Application failed?
  • Index(es):
    • Date
    • Thread