Set Bitmap Sample Size - Android android.graphics

Android examples for android.graphics:Bitmap Size

Description

Set Bitmap Sample Size

Demo Code

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {

  public static Bitmap getBitmap(String path, int bounds) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;/*from   www  .  j a v a2 s .  c  om*/
    BitmapFactory.decodeFile(path, options);
    options.inSampleSize = bounds;
    options.inJustDecodeBounds = false;
    Bitmap bitmap = BitmapFactory.decodeFile(path, options);
    return bitmap;
  }

}

Related Tutorials