我正在'developer.android.com'上缩小我的位图文件,我发现了一件我不理解的事情.所以我感谢你给我一点帮助.
这是developer.android.com 的一个片段
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
if (width > height) {
inSampleSize = Math.round((float)height / (float)reqHeight);
} else {
inSampleSize = Math.round((float)width / (float)reqWidth);
}
}
return inSampleSize;
}
Run Code Online (Sandbox Code Playgroud)
在if语句中,当"if(width> height)"为什么会计算"(float)height /(float)reqHeight"?
例如,width = 600,height = 800,reqWidth = 100,reqHeight = 100. …