Scale Bitmap
import android.graphics.Bitmap;
import android.graphics.Matrix;
class Utils {
public static Bitmap scaleBitmap(Bitmap original, int width, int height) {
float scaleWidth = ((float) width) / original.getWidth();
float scaleHeight = ((float) height) / original.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(original, 0, 0, original.getWidth(),
original.getHeight(), matrix, true);
}
}
Related examples in the same category