How to assemble animation from an array of images with the highest FPS possible on iOS?

孤者浪人 提交于 2019-12-12 01:09:37

问题


I apologize in advance if this question sounds dumb.

I have an array of images produced by another project, and I want to show them on the screen in sequence as fast as possible to assemble them to animation. How should I do this to achieve a frame rate at least higher than 30FPS?

I'm new to iOS development and I'm not sure where to start with. Should I look into Core Animation or OpenGL or Quartz2D or something else? Can someone please point me a direction?

Thanks a lot! Really appreciate the help.


回答1:


 imageView.animationImages = imagesArray;
 imageView.animationRepeatCount = 0;
 imageView.animationDuration = 35;//depends on how fast you want it

imagesArray is the array of images. Each image for each frame.

Hope this helps..




回答2:


You should not be using the imageView.animationImages API. It will consume all your app memory. A complete description of the problem with Video and Memory usage on iOS devices is available. A quick fix would be to save your frames as a series of PNG images, but that will not give you 60FPS because it will take too long to decode each PNG image and blit it to the screen. The real solution that will give you 60FPS is to decode each image into "keyframes" of raw binary data in BGRA format and then memory map each frame as needed. My own code that implements this solution can be found at the link above.



来源:https://stackoverflow.com/questions/16880798/how-to-assemble-animation-from-an-array-of-images-with-the-highest-fps-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!