Android examples for android.graphics:Bitmap Size
Resize a Bitmap by height
import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap getResizedBitmap(Bitmap bm, int newHeight) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleHeight * 1.2f, scaleHeight); // "RECREATE" THE NEW BITMAP Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); return resizedBitmap; }//from w ww .j a va 2 s . c o m }