开发者

What is the fastest way to load an image from SD card into a view

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜