Log.v("HEIGHTRATIO",""+heightRatio);
Log.v("WIDTHRATIO",""+widthRatio);
//如果兩個(gè)比率都大于1,那么圖像的一條邊會(huì)大于屏幕
if (heightRatio > 1 && widthRatio > 1){
if (heightRatio > widthRatio){
//若高度比率更大,則根據(jù)它縮放
bmpFactoryOptions.inSampleSize = heightRatio;
}
else{
//若寬度比率更大,則根據(jù)它縮放
bmpFactoryOptions.inSampleSize = widthRatio;
}
}
// 對(duì)它進(jìn)行真正的解碼
bmpFactoryOptions.inJustDecodeBounds = false;
returnBmp = BitmapFactory.decodeStream(getContentResolver().
openInputStream(imageFileUri), null, bmpFactoryOptions);
} catch (FileNotFoundException e) {
Log.v("ERROR",e.toString());
}
return returnBmp;
}
}