Android Bitmap Scale zoomImg(Bitmap bm, int newWidth, int newHeight)

Here you can find the source of zoomImg(Bitmap bm, int newWidth, int newHeight)

Description

zoom Img

Declaration

public static Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {
    public static Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) {
        int width = bm.getWidth();
        int height = bm.getHeight();
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);
        Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,
                true);//  w w  w  .  j  a  v a  2s.  c  om
        return newbm;
    }
}

Related

  1. scaleBitmap(Bitmap bitmap, float scale)
  2. scaleBitmapDown(Bitmap bitmap)
  3. scaleToFit(Bitmap bm, float width_Ratio, float height_Ratio)
  4. stretchImage(Bitmap image, float xscale, float yscale)
  5. stretchImage(Bitmap image, int xsize, int ysize)
  6. getSmallBitmap(String filePath)
  7. getScaledBitmap(String picturePath, int width, int height)
  8. cleanStretchImage(Bitmap image, int xsize, int ysize)
  9. cleanStretchImageY(Bitmap image, int ysize)