Android Bitmap Scale getScaleBitmap(Bitmap origialBitmap, int dstWidth, int dstHeight)

Here you can find the source of getScaleBitmap(Bitmap origialBitmap, int dstWidth, int dstHeight)

Description

get Scale Bitmap

Declaration

public static Bitmap getScaleBitmap(Bitmap origialBitmap, 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   w  w  w. j a  v  a  2 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. scaleToScreen(Activity activity, Bitmap bitmap)
  2. scaleImage(Bitmap image, float scale)
  3. scaleImg(Bitmap bitmap, float scale)
  4. scaleImg(Bitmap bitmap, int newWidth, int newHeight)
  5. scaleImg(File file, int newWidth, int newHeight)
  6. getScaleBitmap(Context context, int resId, int dstWidth, int dstHeight)
  7. getScaleImage(final Bitmap bitmap, final float boundBoxInDp)
  8. generateScaledBitmap(Bitmap bitmap, int width, int height)
  9. generateScaledBitmap(Drawable drawable, int width, int height)