zoom Image - Android android.graphics

Android examples for android.graphics:Image Operation

Description

zoom Image

Demo Code

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);
    return newbm;
  }//from w  w  w . j  a  v  a 2 s  .c  om

}

Related Tutorials