在解码文件之前,如何在android中获取图像的高度和宽度?

在解码文件之前,如何在android中获取图像的高度和宽度?,android,Android,如何根据设备设置isSamplesize?e、 g.对于5MP、8MP、13Mp相机,图像大小会有所不同。如何处理此问题?使用BitmapFactory.Options.inJustDecodeBounds(): 从这一点出发,您可以在SampleSize中计算,(尚未测试) BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.d

如何根据设备设置isSamplesize?e、 g.对于5MP、8MP、13Mp相机,图像大小会有所不同。如何处理此问题?

使用
BitmapFactory.Options.inJustDecodeBounds
():

从这一点出发,您可以在SampleSize中计算
,(尚未测试)

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, options);

// now width and height are in options.outWidth and options.outHeight