0

I am building a simple wallpaper app. I store the wallpaper images(.jpg) as resources in the res folder. I show the user a grid of thumbnails, which I store separately as resources(.jpg) too in res. I want the scrolling through this grid to be smooth and fast. My question is that when I load the gridview using the adapter, In the getView method I convert the resource to a bitmap and then load it in each imageView in the Grid. Would it be faster if I stored the thumbnails as .bmp in the res folder in the first place? Also I've manually created the thumbnails, rather than manipulating the large wallpapers making them at run-time. Each thumbnail is made to scale to width of 120pixels and the grid consists of 120x120 imageviews. So I was wondering how I could load these images quickly and effectively? Im setting the adapter to the gridview inside Asyntask, but I dont notice an improvement.

Shanky
  • 49
  • 7
  • 2
    Have you considered using @Fedor's _Lazy Loading_ method? You can get more info about it here: [Lazy Load](http://stackoverflow.com/a/3068012/450534). – Siddharth Lele Sep 23 '12 at 11:11

2 Answers2

2

Jpeg, which is lossy image compression, usually provides the best quality to size trade-off. If you're trying to store high quality images then you're almost certainly going to want to use Jpeg.

PNG does has useful features such as allowing you to work with transparency, and, for simple block colour images outputs really small file sizes.

However, the moment you start to create photo quality images, such as wallpapers, as PNG, you're going to see monster file sizes, which on a mobile device is not going to be much fun or much appreciated by the end user. Also larger files tend to require more system resources (CPU time and RAM), and on a mobile devices these resources are at a premium.

I would suggest that perhaps for thumbnails you might use PNG, and for the full size image use JPEG, but you might do well to see which creates the smallest file, because that is likely to give an good indication of the rendering efficiency i.e. it takes little resources to render a 800b PNG.

CodePoint
  • 29
  • 1
  • 5
1

Changing your images to the bmp file format could make a little improvement in performance (because JPG is a compressed bitmap image that needs to be decompressed when rendered), but it's usually not worth the major increase in filesize.

I would recommend using the PNG bitmap format because it's light in both rendering and filesize.

As for the rendering in the ListView, you might want to take a look at this question and this code project.

Community
  • 1
  • 1
Leon Lucardie
  • 9,541
  • 4
  • 50
  • 70