• 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: Using UIImageView for animations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using UIImageView for animations


  • Subject: Re: Using UIImageView for animations
  • From: Sebastian Morsch <email@hidden>
  • Date: Tue, 13 Jan 2009 22:03:47 +0100

I am having the same problem with UIImageView, just in my case, it's not FPS performance but running out of memory. Using + imageWithContentsOfFile didn't seem to solve the problem. I had 20 full screen PNGs loaded at the same time to hand them over to the view via the animationImages property, which almost always results in a memory warning.

Understandably, because that's 20*(320*480*4) = almost 12MB, which is way too much.

So my question is, how such an animation can be implemented? My next idea would be to do the animation myself by loading the next image, swapping it for the old one and dispose of the old one, so there's always just two images in memory at the same time. But I'm not sure, if this path is a good one because the timing of that process might be difficult to handle.

From my understanding, UIImageView can't be used for full frame animations with more than 10 images, or am I missing something? Is there another recommended strategy (besides using MPMoviePlayerController)?

Thanks,
Sebastian



Am 13.01.2009 um 19:24 schrieb David Duncan:

On Jan 12, 2009, at 8:10 PM, Glenn Bloom wrote:

- When I animate a set of PNG's rather than JPEG's (again using
UIImageView's animationImages property), I am thinking I don't need to
think about compression (or Apple optimization)? Is it then appropriate to
think of the total memory to be consumed simply as an aggregate of the total
bytes for all the images?

Basically yes. The rule of thumb is Width * Height * 4 for each image. Images must be decompressed before display. The PNG optimization that Xcode applies converts the image to a format that is optimal for display, it doesn't reduce the amount of storage needed to display it.


- Am I correct in thinking that for loading a short-running animation, I
should generally use the initWithContentsOfFile method of UIImage instead of
imageNamed because imageNamed caches the data into memory?

Unless you can prove that you get better performance with +imageNamed: you should always prefer +imageWithContentsOfFile: or - initWithContentsOfFile:. This is especially true with large images (primarily because they consume lots of memory and are not reused often enough to gain a benefit).


- I had thought there was a way to use Instruments to assess if a
UIImageView animation was skipping frames. Now, I'm not so sure. Any
particular way to test if such an animation is skipping or not displaying
frames?


You can get an FPS meter from the Core Animation instrument. This may or may not be what you are thinking of.
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

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

_______________________________________________

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


  • Follow-Ups:
    • Re: Using UIImageView for animations
      • From: David Duncan <email@hidden>
References: 
 >Using UIImageView for animations (From: Alex Strand <email@hidden>)
 >Re: Using UIImageView for animations (From: David Duncan <email@hidden>)
 >Re: Using UIImageView for animations (From: "Glenn Bloom" <email@hidden>)
 >Re: Using UIImageView for animations (From: David Duncan <email@hidden>)

  • Prev by Date: Re: IKImageBrowserView drag and drop/reordering when using core data [SOLVED]
  • Next by Date: Enable Scripting Failing - Missing something? Based on SimpleScripingVerbs sample
  • Previous by thread: Re: Using UIImageView for animations
  • Next by thread: Re: Using UIImageView for animations
  • Index(es):
    • Date
    • Thread