Thursday, July 28, 2011

Android : How to reduce size of Bitmaps / Images?

Reducing size of Bitmaps / Re-sizing Bitmaps to reduce memory requirement:

Bringing actual image in memory will occupy more space and hence low performance and Virtual Memory problems. 

For example, suppose if we are loading 10 images to show in Gallery view then bringing all original bitmaps in memory will bring application close to virtual memory limit. We can reduce bitmap size by re-sizing it using inSampleSize.

Specifying inSampleSize = 2 will reduce image size by 1/2, specifying inSampleSize = 4 will reduce image size by 1/4. It is good to specify value of inSampleSize to powers of 2, which makes calculation faster.

BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inSampleSize = 4;

Bitmap imgBitmap = BitmapFactory.decodeFile(filePath, bounds);



  1. Dude thanks a lot for UR help :)

  2. Android Application Developers : Select somebody who values quality of the app above everything else. This allows you make sure that your Android app development company will concentrate on the requirements like performance, running time, energy intake, involvement quotient, interaction, intuitiveness and consumer encounter. If the app concentrates on the non-essentials, there is no way that the app can be successful.

  3. i had decodeFile(path); only
    i need decodeFile(path, bound);