大图处理
闲着没事写的一个方法
public Bitmap getTargetBitmap(int iamgeResource,int targetWidth,int targetHeight) {
BitmapFactory.Options options = new BitmapFactory.Options();
//设置options
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(),iamgeResource,options);
int outWidth = options.outWidth;
int outHeight = options.outHeight;
//计算宽高比
int widthB = outWidth / targetWidth;
int heightB = outHeight / targetHeight;
//使用合适的比例
int targetComple = widthB > heightB ? widthB : heightB;
//重新设置options
options.inSampleSize = targetComple;
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(getResources(),iamgeResource,options);
}