Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndrewWang1993/d90c78c2f461e9e36688 to your computer and use it in GitHub Desktop.
Save AndrewWang1993/d90c78c2f461e9e36688 to your computer and use it in GitHub Desktop.
使用BitmapFactory对象测量一个图片的高和宽而不用分配内存
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true; // Don't allocated memory
BitmapFactory.decodeResource(getResources(), R.id.myimage, options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
String imageType = options.outMimeType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment