0

To simulate an animation I decode a sequence of frame next to another and update it on a Bitmap at a fixed rate. The problem is everytime the BitmapFactory.decodeFile function get call it allocate new File and FileInputStream objects, this leads to the GC being called very frequently.

So is there a way to effectively decode file in this scenario for Android. Note that caching Bitmap is useless here 'cause the frames loop continuously one after another.

ttson153
  • 63
  • 1
  • 8
  • As long as you use files you have to create a new inputstream for every file. You cannot blame bitmap factory for that. – greenapps Oct 21 '16 at 10:05
  • So there's no way to reuse the InputStream I guest? Or can you suggest an efficient way to decode bitmap from file repetitively? – ttson153 Oct 21 '16 at 10:38

1 Answers1

0

You'd better convert the bunch of image files into AGIF format and play it.

Check this post. https://stackoverflow.com/a/20277649/4518710

Community
  • 1
  • 1
Suhyeon Lee
  • 569
  • 4
  • 18
  • Hello! GIF doesn't work for me because I need to draw these Bitmap with OpenGL. What I'm after here is to create animated stickers and overlay them on camera feed. – ttson153 Oct 21 '16 at 10:42