• 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: Scheme for efficiently archiving images.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scheme for efficiently archiving images.


  • Subject: Re: Scheme for efficiently archiving images.
  • From: Graham Cox <email@hidden>
  • Date: Thu, 27 Nov 2008 15:19:17 +1100


On 27 Nov 2008, at 12:49 pm, Ken Ferry wrote:

I don't have time to go much into this before I go off for the
holiday, but one thing:

On Wed, Nov 26, 2008 at 5:26 PM, Graham Cox <email@hidden> wrote:
For images from a file, I am thinking I can copy the
original file into my package and simply archive a relative path to it.

If you create an image with -initByReferencingURL:, the URL is all it will archive. The 'reference' here means that the app is permitted to assume image remains accessible at the URL. If you use initWithContentsOfURL:, the app is contractually obligated to read the data in immediately and no longer go back to the URL.


OK, that's fine - I'm not sure it will be a problem, but I will bear it in mind.

I'm already running into a few other problems though, basically because NSImage is too much of a black-box.

In order to cache the original data used to create an image, I need to grab it before the image is actually constructed. That isn't too bad, but for example, using [NSImage initWithPasteboard:] or [NSImage initWithContentsOfURL:], those methods covers up a lot of functionality. For example, it will correctly rotate an image that was saved with a rotation flag, whereas if I grab the data from the URL myself and make the image from that, it does not. That seems a bit strange to me, since it's surely the same, complete data.

i.e. these two bits of code give unexpectedly different results:

	return [[[NSImage alloc] initWithContentsOfURL:url] autorelease];

and

	NSData* data = [NSData dataWithContentsOfURL:url];
	return [[[[NSImage alloc] initWithData:data] autorelease];

Why does that happen and what can I do to fix it?

If NSImage had a way to return its retained data (if I call setDataRetained:), none of this would seem to be necessary. Why doesn't it?

--Graham


_______________________________________________

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


References: 
 >Scheme for efficiently archiving images. (From: Graham Cox <email@hidden>)
 >Re: Scheme for efficiently archiving images. (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: Re: Memory management puzzle
  • Next by Date: Re: Memory management puzzle
  • Previous by thread: Re: Scheme for efficiently archiving images.
  • Next by thread: Re: Scheme for efficiently archiving images.
  • Index(es):
    • Date
    • Thread