Read Bitmap from file name - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

Read Bitmap from file name

Demo Code

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {

  public static Bitmap getInternalBitmap(Context c, String filename) {
    Bitmap b = null;// w ww  .  ja v a2s.co m
    try {
      FileInputStream fis = c.openFileInput(filename);
      BufferedInputStream buf = new BufferedInputStream(fis);
      b = BitmapFactory.decodeStream(buf);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    return b;
  }

}

Related Tutorials