Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.BitmapFactory; import java.io.File; public class Main { public static Bitmap loadBitmap(byte[] bytes, int width, int height) { BitmapFactory.Options options = new BitmapFactory.Options(); //only load bound information? bound information is regarding property of the picture options.inJustDecodeBounds = true; BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options); //to get the picture's original width and height int w = options.outWidth / width; int h = options.outHeight / height; int scale = w > h ? w : h; options.inSampleSize = scale; options.inJustDecodeBounds = false; return BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options); } public static Bitmap loadBitmap(String path) { File file = new File(path); if (file.exists()) { return BitmapFactory.decodeFile(path); } return null; } }