Here you can find the source of downsampleBitmap(FileDescriptor fd, int maxArea)
public static Bitmap downsampleBitmap(FileDescriptor fd, int maxArea)
//package com.java2s; //License from project: Open Source License import java.io.FileDescriptor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Rect; public class Main { public static Bitmap downsampleBitmap(FileDescriptor fd, int maxArea) { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true;/*from w ww.j a v a2 s . c om*/ Rect outRect = new Rect(); BitmapFactory.decodeFileDescriptor(fd, outRect, opts); int subsample = 1; int width = opts.outWidth; int height = opts.outHeight; while (width * height > maxArea) { width /= 2; height /= 2; subsample++; } opts.inJustDecodeBounds = false; opts.inSampleSize = subsample; Bitmap retval = BitmapFactory.decodeFileDescriptor(fd, null, opts); return retval; } }