Android Bitmap Resize smallImage(Bitmap bitmap, int Width, int Height)

Here you can find the source of smallImage(Bitmap bitmap, int Width, int Height)

Description

small Image

Declaration

public static Bitmap smallImage(Bitmap bitmap, int Width, int Height) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {
    public static Bitmap smallImage(Bitmap bitmap, int Width, int Height) {
        int oldWidth = bitmap.getWidth();
        int oldHeight = bitmap.getHeight();

        float scaleWidth = ((float) Width) / oldWidth;
        float scaleHeight = ((float) Height) / oldHeight;
        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);

        return Bitmap.createBitmap(bitmap, 0, 0, oldWidth, oldHeight,
                matrix, true);//from   ww  w  .j a va 2 s .  c  om

    }
}

Related

  1. resizeBitmap(Context context, int resId, int w, int h)
  2. resizeBitmapByScale(Bitmap bitmap, float scale, boolean recycle)
  3. resizeDownBySideLength(Bitmap bitmap, int maxLength, boolean recycle)
  4. resizeDrawable(Context context, int resId, int w, int h)
  5. resizePreviewBitmap(Bitmap bm, int width, int height)
  6. zoomBitmap(Bitmap bgimage, int newWidth, int newHeight)
  7. zoomBitmap(Bitmap bitmap, int width, int height)
  8. zoomBitmapAdjustScreen(Activity activity, String imagePath)
  9. zoomImage(Bitmap bgimage, int newWidth, int newHeight)