I want to implement a picture gallery and I'm not satisfied with the performance of my solution. My application creates small thumbnails (around 1k file size / 64x64px) and stores them onto SD card. Loading these images from SD card into a view costs some time (20ms per thumbnail) and causes that the gallery does not scroll very smooth.
I've tried loading the image using BitmapFactory.decodeStream or BitmapDrawable(InputStream). I don't want a full memory cache, because - depends on the number of pictures - OutOfMemory can occour and the initial creation of the cache tasks a lot of 开发者_StackOverflow中文版time.
Has anybody an idea how to load the images in a faster way? Are the framworks for free? Or or or...
I suggest you to read "File I/O and efficiency" post on Android Google groups. After the benchmarks author came to the conclusion that the most efficient way of file I/O is "batch operation on a memory mapped ByteBuffer"
.
In your case it may be more efficient to use one big file for thumbnails storage instead of hundreds of small ones. You may also need a separate file for indexing (e.g. for mapping between file name/number and start/end position in big thumbnail file) - this however depends on your logic.
精彩评论