public Bitmap resizeImage(Bitmap bitmap, int width, int height) { int bmpWidth = bitmap.getWidth(); int bmpHeight = bitmap.getHeight(); float scaleWidth = ((float) width) / bmpWidth; float scaleHeight = ((float) height) / bmpHeight; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true); }
PS:自用的不解释。。。 作者:一个吃货帅锅
Add。。好像。。。
canvas.drawBitmap(bmp, null, new RectF(0, 0, width, height), null);