Android Bitmap Scale getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight)

Here you can find the source of getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight)

Description

get Scale Bitmap

Declaration

public static Bitmap getScaleBitmap(Context context, int resId,
            int dstWidth, int dstHeight) 

Method Source Code

//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;
    }
}

Related

  1. scaleImage(Bitmap image, float scale)
  2. scaleImg(Bitmap bitmap, float scale)
  3. scaleImg(Bitmap bitmap, int newWidth, int newHeight)
  4. scaleImg(File file, int newWidth, int newHeight)
  5. getScaleBitmap(Bitmap origialBitmap, int dstWidth, int dstHeight)
  6. getScaleImage(final Bitmap bitmap, final float boundBoxInDp)
  7. generateScaledBitmap(Bitmap bitmap, int width, int height)
  8. generateScaledBitmap(Drawable drawable, int width, int height)
  9. generateScaledBitmap(byte[] bitMapData, int width, int height)