private static final double MAX_BITMAP_SIZE = 5e6; spa
private String handleChoosedPicture(Bitmap bitmap,String path) {
if(bitmap == null || bitmap.isRecycled()){
return "";
}
if(DEBUG){
Log.d(TAG, "handleChoosedPicture path : " + path);
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();get
/*it
1. MAX_BITMAP_SIZE是你设置的容许的最大大小 若是宽*高小于于这个大小就不进行压缩,大于就压缩。io
2.开方是由于: 若是 除完是0.81 那么 长宽各缩小为以前的0.9就能够啦 0.9*0.9=0.81sed
3.任意一个大于1的数,开根号后的值都是大于1的。map
*/
float ratio = (float) Math.sqrt(MAX_BITMAP_SIZE/(w*h));
if(DEBUG){
Log.d(TAG, "handleChoosedPicture ratio = " + ratio);
}
ratio = ratio > 1 ? 1 : ratio;
int degree = mImageRotate == 0 ? BitmapUtil.readPictureDegree(path) : mImageRotate;
if(DEBUG){
Log.d(TAG, "handleChoosedPicture degree = " + degree);
}
bitmap = BitmapUtil.rotateAndScaleImageView(degree, bitmap, ratio);
String resultPath = FileUtil.genPath();
BitmapUtil.saveBitmap(resultPath, bitmap);
return resultPath;
}float