• 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 drawInRect:fromRect:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage drawInRect:fromRect:


  • Subject: Re: NSImage drawInRect:fromRect:
  • From: Ricky Sharp <email@hidden>
  • Date: Thu, 17 Mar 2005 09:37:38 -0600

On Thursday, March 17, 2005, at 09:09AM, Michael Becker <email@hidden> wrote:

>Currently I am using NSImages in my application, doing a lot of
>drawInRect:fromRect:operation:fraction:. Since I do not really need all
>of the big features of NSImage, I would like to use NSBitmapImageReps.
>However, NSBitmapImageRep does not have any method like the one
>mentioned before.

Why not just stick with NSImage?  Even though you may not use many of its APIs, you'll still gain all the benefits of any of its underpinnings (e.g. caching).

>As my main concern here is speed and memory usage: Is it feasible to
>use NSBitmapImageRep's here and if so, how can I make them do what I
>want?

Have you profiled things and thus want to improve speed and/or mem usage?

In terms of speed, there is an initial hit when first loading in image data and another hit when the data is rendered for the first time.  For example, all my images are vector-based PDF.  I do take an initial hit on views that display many images where those images have not yet been loaded or drawn.  However, returning to the view will be much faster since it is now using cached images.  I'd strongly suggest you just use NSImage as you'll gain all this caching logic for free.

In terms of mem usage, you can always create an "image factory" that will maintain a fixed quantity of images that are ultimately loaded.  You can then implement a scheme where least-used images are purged (assuming that nobody is holding a reference of course).

I sort of do this in my app to manage theme-based images.  For each theme, I have a subfolder with the theme name inside of my bundle's Resources folder.  Whenever I call my setTheme: API, I purge any existing NSDictionary containing the images (keys are the image names).  I then rebuild an NSDictionary with the images found in the appropriate subfolder.  But for non-theme images, once they're loaded, they stay resident in memory.

--
Rick Sharp
Instant Interactive(tm)

 _______________________________________________
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

References: 
 >NSImage drawInRect:fromRect: (From: Michael Becker <email@hidden>)

  • Prev by Date: display modal window once main window is visible
  • Next by Date: Re: display modal window once main window is visible
  • Previous by thread: NSImage drawInRect:fromRect:
  • Next by thread: Re: NSImage drawInRect:fromRect:
  • Index(es):
    • Date
    • Thread