|
|
@ -65,14 +65,14 @@ public class ImageGetterUtils {
|
|
|
|
int width = bitmap.getWidth();
|
|
|
|
int width = bitmap.getWidth();
|
|
|
|
int height = bitmap.getHeight();
|
|
|
|
int height = bitmap.getHeight();
|
|
|
|
//设置想要的大小
|
|
|
|
//设置想要的大小
|
|
|
|
int newWidth = width;
|
|
|
|
int newWidth = textView.getMeasuredWidth(); //width;
|
|
|
|
int newHeight = height;
|
|
|
|
int newHeight = textView.getMeasuredHeight(); //height;
|
|
|
|
//计算压缩的比率
|
|
|
|
//计算压缩的比率
|
|
|
|
float scaleWidth = ((float) newWidth) / width;
|
|
|
|
float scaleWidth = ((float) newWidth) / width;
|
|
|
|
float scaleHeight = ((float) newHeight) / height;
|
|
|
|
float scaleHeight = ((float) newHeight) / height;
|
|
|
|
//获取想要缩放的matrix
|
|
|
|
//获取想要缩放的matrix
|
|
|
|
Matrix matrix = new Matrix();
|
|
|
|
Matrix matrix = new Matrix();
|
|
|
|
matrix.postScale(scaleWidth, scaleHeight);
|
|
|
|
matrix.postScale(scaleWidth, scaleWidth);
|
|
|
|
//获取新的bitmap
|
|
|
|
//获取新的bitmap
|
|
|
|
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
|
|
|
|
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
|
|
|
|
|
|
|
|
|
|
|
|