• 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
Re: NSImage TIFFRepresentation crashes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage TIFFRepresentation crashes


  • Subject: Re: NSImage TIFFRepresentation crashes
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 10 Mar 2013 12:09:52 +0000

On 10 Mar 2013, at 08:05, Markus Spoettl <email@hidden> wrote:

> On 3/10/13 1:55 AM, Mike Abdullah wrote:
> > Well that exception suggests you have a truly giant image on your hands.
> > Perhaps there's enough memory to do some work with it, but not all.
>
> I was trying to say that the framework appears to be confusing the size. The image itself is being serialized from and to archives and displayed on screen. Unfortunately I don't have the data, but I assume it's an "normal" sized image.
>
> > The most important question: what are you actually calling
> > -TIFFRepresentation for? In practice it's often a rather inefficient method
> > to accomplish your end goal.
>
> I'm using -TIFFRepresentation to produce a PNG representation. The are more efficient ways to do that, I'm sure, but it generally seems to be working fine:
>
> NSData *tiff = [image TIFFRepresentation];
> NSBitmapImageRep *bmprep = [NSBitmapImageRep imageRepWithData:tiff];
> NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], NSImageInterlaced, nil];
> NSData *pngData = [bmprep representationUsingType:NSPNGFileType properties:props];

This is a massively wasteful approach. Likely the best compromise for your needs is to grab a CGImage from the NSImage, and then generate the PNG from that (either using NSBitmapImageRep or CGImageDestination). This takes care of only creating a fresh CGImage instance if actually needed.


_______________________________________________

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 TIFFRepresentation crashes
      • From: Markus Spoettl <email@hidden>
References: 
 >NSImage TIFFRepresentation crashes (From: Markus Spoettl <email@hidden>)
 >Re: NSImage TIFFRepresentation crashes (From: Mike Abdullah <email@hidden>)
 >Re: NSImage TIFFRepresentation crashes (From: Markus Spoettl <email@hidden>)

  • Prev by Date: Re: NSImage TIFFRepresentation crashes
  • Next by Date: Re: NSImage TIFFRepresentation crashes
  • Previous by thread: Re: NSImage TIFFRepresentation crashes
  • Next by thread: Re: NSImage TIFFRepresentation crashes
  • Index(es):
    • Date
    • Thread