80,351
社区成员
发帖
与我相关
我的任务
分享
ImageView oldImageView = (ImageView) currentView.findViewById(R.id.imageview);
oldImageView.setDrawingCacheEnabled(true);
Bitmap oldBitmap = oldImageView.getDrawingCache();
oldImageView.setDrawingCacheEnabled(false);
Bitmap newBitmap = exchangeBitmapSize(oldBitmap, 0.75f, 0.75f);
....
//变换图片的方法
public static Bitmap exchangeBitmapSize(Bitmap bitmap, float scaleX, float scaleY) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Matrix matrix = new Matrix();
matrix.postScale(scaleX, scaleY);
//下面这行代码报错
return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
}