首先得到原bitmap 宽高
int width = bitmap.getWidth();
int height = bitmap.getHeight();
得到新的宽高与原宽高的比例
float scaleWidth = (newWidth)/width;
float scaleHeight = (newHeight)/height;
使用 Matrix 类
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth,ScaleHeight);
生成新的Bitmap
BItmap newBitmap = Bitmap.createBitmap(bitmap,0,0,width,height,martix,false);