• 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
How best to cache/preload an NSImage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Attribute Fixing and NSAttachment
  • Next by Date: Re: Help Viewer not scrolling to anchors: Workaround
  • Previous by thread: Re: Attribute Fixing and NSAttachment
  • Next by thread: SQL and XML stores behave differently with sort descriptor
  • Index(es):
    • Date
    • Thread