在从ByteArray解码时,BitmapFactory默认会尝试对图像进行缩放以适应屏幕密度。如果你想要避免这种行为,可以使用以下方法:
public static Bitmap decodeByteArrayWithoutScaling(byte[] data, int offset, int length, BitmapFactory.Options options) {
options = new BitmapFactory.Options();
// 将inScaled设置为false以避免缩放
options.inScaled = false;
return BitmapFactory.decodeByteArray(data, offset, length, options);
}
然后,你可以通过调用该方法来解码ByteArray,并在不需要缩放的情况下获取图像的原始大小。