read Bitmap from a File - Android Graphics

Android examples for Graphics:Bitmap Read

Description

read Bitmap from a File

Demo Code


//package com.java2s;

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 w ww.  j  a  v  a2 s  .c  o m*/
        opt.inInputShareable = true;

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

Related Tutorials