Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { private static final int ZEN_IMAGE_WIDTH = 480; public static Bitmap decodeImage(String path) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); options.inJustDecodeBounds = false; int be = (int) (options.outWidth / (float) ZEN_IMAGE_WIDTH); if (be <= 0) { be = 1; } options.inSampleSize = be; Bitmap bitmap = BitmapFactory.decodeFile(path, options); return bitmap; } catch (OutOfMemoryError error) { error.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return null; } }