我想改变图像的高度和宽度。使用canvas
:
canvas.drawBitmap (_image, 0, 0, null);
如何更改位图的大小?
答案 0 :(得分:4)
使用矩阵:
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);
答案 1 :(得分:1)
或Bitmap.createScaledBitmap(...)