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