read BitMap from file - Android android.graphics

Android examples for android.graphics:Bitmap Load Save

Description

read BitMap from file

Demo Code

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

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

public class Main {

  public static Bitmap readBitMap(File file) throws FileNotFoundException {
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inPreferredConfig = Bitmap.Config.RGB_565;
    opt.inPurgeable = true;//from   www . jav  a 2 s.c o m
    opt.inInputShareable = true;

    InputStream is = new FileInputStream(file);
    return BitmapFactory.decodeStream(is, null, opt);
  }

}

Related Tutorials