How best to cache/preload an NSImage?
How best to cache/preload an NSImage?
- Subject: How best to cache/preload an NSImage?
- From: Dominic Yu <email@hidden>
- Date: Thu, 11 Aug 2005 13:30:00 -0700
Currently, I am doing something like this:
// typed in mail, not real code
NSImage *sourceImage, *cachedImage;
sourceImage = [NSImage initWithFileContents:myPath];
cachedImage = [[NSImage alloc] initWithSize:newSize];
[cachedImage lockFocus];
[sourceImage drawInRect:newRect fromRect:oldRect ...];
[cachedImage unlockfocus];
// cachedImage now contains one NSCachedImageRep
Problem is, when my custom NSView draws this image for the first time,
there's a small but noticeable lag. The second time (after I've
switched to another image, then back), it's instantaneous. I suspect
this has something to do with NSImage buffering to its offscreen
window, but I don't know how to force it do that without drawing on a
real window.
Any pointers would be appreciated, or suggestions on other ways to
solve approach this task...
-Dominic
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden