图片压缩计算inSampleSize为什么除以500这个值
Closed this issue · 1 comments
drkingwater commented
`
public static Bitmap getDecodeAbleBitmap(String picturePath) {
try {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(picturePath, options);
int sampleSize = Math.min(options.outHeight, options.outWidth) / 500;
if (sampleSize <= 0) {
sampleSize = 1;
}
options.inSampleSize = sampleSize;
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(picturePath, options);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
`
这是库中的代码,想问下int sampleSize = Math.min(options.outHeight, options.outWidth) / 500; 为什么要除500,而不是400或者其他
devilsen commented
这只是找了一些图片和手机测试出来的,你可以自己进行一些优化