load Bitmap from File - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

load Bitmap from File

Demo Code

import java.io.File;

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

public class Main {

  public static Bitmap loadFromFile(String filename) {
    try {//from   ww  w.j a  va  2  s.c  om
      File f = new File(filename);
      if (!f.exists()) {
        return null;
      }
      Bitmap tmp = BitmapFactory.decodeFile(filename);
      return tmp;
    } catch (Exception e) {
      return null;
    }
  }

}

Related Tutorials