简体   繁体   中英

Android: How to get width and height of an image without using JavaX's ImageIO?

Given an image stored in a File object, how would I get the width and height of that image without using the javax.imageio module, since Android does not allow you to use that module?

Use something like this:

BitmapFactory.Options bmpOptions = new BitmapFactory.Options();

bmpOptions.inJustDecodeBounds = true;

BitmapFactory.decodeFile(yourFile, bmpOptions);

bmpOptions will have outWidth and outHeight with your image dimensions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM