Pre-guess size of Bitmap from the actual Uri, before scale-loading

試著忘記壹切 提交于 2019-11-28 09:09:31

See the Android guide to handling large bitmaps.

Specifically this section:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.id.myimage, options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;

EDIT

In your case, you'll replace the decodeResource line with:

BitmapFactory.decodeFileDescriptor(fileDescriptor.getFileDescriptor(), null, options);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!