java更改图像的宽度和高度 11 月,3 周 Questions & Answers 1895 我想更改图像的高度和宽度。使用canvas显示图像: canvas.drawBitmap (_image, 0, 0, null); 如何更改位图的大小
# 2 楼答案 使用矩阵: 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 楼答案
或
Bitmap.createScaledBitmap(...)
# 2 楼答案
使用矩阵: