Creating fullscreen animations on Android? Should I use OPENGL?

Let's say I need to make some full-screen animations, which consist of approximately 500 frames each. The animation should play at a reasonable speed - presumably no less, and then 20 frames per second - and the images should be of reasonable quality and not too compressed.

Which method do you think should be used?

So far I have tried:

1. storing each frame as a compressed JPEG 2. before animation starts, loading each frame into a byteArray 3. as the animation plays, decode corresponding byteArray into a bitmap and draw it on a surface view. 

The problem is the speed is too low, usually around 5-10 FPS.

I thought of two other options.

  • turning all animations into a single movie file ... but I think that there may be problems with starting, pausing and finding the exact right frame ... what do you think?

  • the other option that I was thinking about was using OPENGL (so far I had never worked with it before) to play frame-by-frame animation. Do you think he can handle it?

Thanks!


edit, I managed to look into talktom and found that it contains about 20 million well-compressed JPEG files, for example.

enter image description here

+4
source share
3 answers

You can handle it in several ways.

  • Decoding seems to be your bottleneck. You can try to do all 3 steps, including decoding, before playing the animation, so you just need to draw already converted bitmaps.

  • OpenGL definitely depends on the task in the sense that it will probably never become your bottleneck. But, as stated above, the drawing does not seem to be a problem.

  • Animation on the device. If you animate geometric objects or bitmap images, and the animation has a common background, you can reuse it, separate the animation to β€œactors” and move them - this will require much less data.

EDIT: complex animations on mobile devices - these are rarely full-screen movies or series of images - the amount of (redundant) data will be huge (as you already noticed). These are animated 2D and 3D models. For 3D, using OpenGL is recommended; for 2D, general canvas drawing may be sufficient. To make it even more efficient, you can divide the model into separate parts and animate them separately (it will be similar to SouthPark animation). You can combine this with sprites (for example, individual small stripes of films) to animate individual parts. This will give you much more flexibility in using less data than a compressed movie.

+3
source

I really think you need to turn it into a movie file - this will give you a suitable compression, and the android can do all the work with a media player. I think getting the right frame is pretty simple, but you might have to use lower compression in the video stream to make this work.

+2
source

Perhaps using the universal tween engine might solve your performance problem.

+1
source

Source: https://habr.com/ru/post/1445488/


All Articles