get Bitmap From Stream - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

get Bitmap From Stream

Demo Code

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

public class Main {

  public static Bitmap getBitMapFromStream(String filename) {
    Bitmap bitmap = null;//from www  .  ja va 2s . co m
    try {
      BitmapFactory.Options options = new BitmapFactory.Options();

      options.inJustDecodeBounds = false;
      bitmap = BitmapFactory.decodeFile(filename, options);

      System.gc();
      return bitmap;

    } catch (Exception ex) {
      return null;
    }
  }

}

Related Tutorials