0

我在本地画廊中有一个大小为 1.61 mb 的图像,但是当我使用下面的代码选择图像并记录大小时,它变成了 6mb!图像大小怎么可能变大,或者我的计算或获取字节的方式是错误的。

使用它选择图像。

 Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, SELECT_PHOTO);

使用它获取位图字节。

bytes = bitmap.getRowBytes() * bitmap.getHeight();

public static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
4

0 回答 0