/**
* 根据给定的宽和高进行拉伸
*
* @param origin 原图
* @param newWidth 新图的宽
* @param newHeight 新图的高
* @return new.json Bitmap
*/
private Bitmap scaleBitmap(Bitmap origin, float newWidth, float newHeight) {
if (origin == null) {
return null;
}
int height = origin.getHeight();
int width = origin.getWidth();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);// 使用后乘
Bitmap newBM = Bitmap.createBitmap(origin, 0, 0, width, height, matrix, false);
return newBM;
}