BitmapFactory.Options.inBitmap causes tearing when switching ImageView bitmap often

后端 未结 5 862
野的像风
野的像风 2021-02-05 16:31

I\'ve encountered a situation where I have to display images in a slideshow that switches image very fast. The sheer number of images makes me want to store the JPEG data in mem

5条回答
  •  别跟我提以往
    2021-02-05 17:00

    As an alternative to your current approach, you might consider keeping the JPEG data as you are doing, but also creating a separate Bitmap for each of your images, and using the inPurgeable and inInputShareable flags. These flags allocate the backing memory for your bitmaps on a separate heap that is not directly managed by the Java garbage collector, and allow Android itself to discard the bitmap data when it has no room for it and re-decode your JPEGs on demand when required. Android has all this special-purpose code to manage bitmap data, so why not use it?

提交回复
热议问题