I'm looking on 'developer.android.com' to scale down my bitmap file and I found one thing that I don't understand. so I appreciate you give me a little help.
Here's a snippet from 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;
}
in if statement, when " if(width > height)" why do they calculate "(float)height / (float)reqHeight " ?
for example, width=600, height=800, reqWidth=100, reqHeight=100.
In this situation, inSampleSize would be 6 and the dimensions calculated are width=100, height=133. height is still above reqHeight..
so, can anyone explain me about this, please? sorry for complicated explanation but I hope someone give me a idea. :)