Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; public class Main { public static Bitmap readBitmapFile(String aFileName) { Bitmap bitmap = null; File file = new File(aFileName); try { FileInputStream fis = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fis); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } return bitmap; } public static Bitmap readBitmapFile(String aFileName, Options aOptions) { Bitmap bitmap = null; File file = new File(aFileName); try { FileInputStream fis = new FileInputStream(file); bitmap = BitmapFactory.decodeStream(fis, null, aOptions); fis.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (OutOfMemoryError e) { e.printStackTrace(); } return bitmap; } }