Utils.java :  » UnTagged » tesis-ar » org » tesis » Android Open Source

Android Open Source » UnTagged » tesis ar 
tesis ar » org » tesis » Utils.java
package org.tesis;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class Utils 
{
  public static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) 
  {
    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 resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);

    return resizedBitmap;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.