Reputation: 53
I would like to change the height and width of the image. Displays the image using the canvas
:
canvas.drawBitmap (_image, 0, 0, null);
How to change the size of the bitmap?
Upvotes: 2
Views: 1916
Reputation: 104168
Use a Matrix:
int width = bitmap.getWidth();
int height = bitmap.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
width, height, matrix, true);
Upvotes: 4