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 PROTECTED]> 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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to