Here you can find the source of getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight)
public static Bitmap getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight)
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight) { Bitmap origialBitmap = BitmapFactory.decodeResource( context.getResources(), resId); Bitmap scaleBitmap = Bitmap.createScaledBitmap(origialBitmap, dstWidth, dstHeight, true); if (origialBitmap != null && !origialBitmap.isRecycled()) { origialBitmap.recycle();//from www . j a v a2 s . c o m } return scaleBitmap; } public static Bitmap getScaleBitmap(Bitmap origialBitmap, int dstWidth, int dstHeight) { Bitmap scaleBitmap = Bitmap.createScaledBitmap(origialBitmap, dstWidth, dstHeight, true); if (origialBitmap != null && !origialBitmap.isRecycled()) { origialBitmap.recycle(); } return scaleBitmap; } }