Here you can find the source of getBitmapFromFile(String filePath)
public static Bitmap getBitmapFromFile(String filePath)
//License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import org.ixming.android.utils.FrameworkLog; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Bitmap.Config; import android.graphics.BitmapFactory; public class Main{ static final String TAG = "sharebind_bitmaputil"; public static Bitmap getBitmapFromFile(String filePath) { return getBitmapFromFile(new File(filePath)); }/*from w w w. j av a2 s .com*/ public static Bitmap getBitmapFromFile(File file) { FileInputStream fis; try { fis = new FileInputStream(file); } catch (Exception e) { FrameworkLog.e(TAG, "getBitmapFromFile Exception: " + e.getMessage()); return null; } return getBitmapFromFileInputStream(fis); } public static Bitmap getBitmapFromFileInputStream(FileInputStream is) { if (is == null) return null; Bitmap bitmap = null; try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Config.RGB_565; options.inPurgeable = true; options.inInputShareable = true; bitmap = BitmapFactory.decodeFileDescriptor(is.getFD(), null, options); } catch (Exception e) { bitmap = null; FrameworkLog.e(TAG, "getBitmapFromFileInputStream Exception: " + e.getMessage()); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } return bitmap; } }