Skip to content

Instantly share code, notes, and snippets.

@nalitzis
Created June 7, 2014 20:39
Show Gist options
  • Save nalitzis/d4fdbf768d457ee16ce9 to your computer and use it in GitHub Desktop.
Save nalitzis/d4fdbf768d457ee16ce9 to your computer and use it in GitHub Desktop.
Bitmap info
private void readBitmapInfo() {
final Resources res = getActivity().getResources();
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, R.drawable.brasil, options);
final float imageHeight = options.outHeight;
final float imageWidth = options.outWidth;
final String imageMimeType = options.outMimeType;
Log.d(TAG, "w,h, type:"+imageWidth+", "+imageHeight+", "+imageMimeType);
Log.d(TAG, "estimated memory required in MB: "+imageWidth * imageHeight * BYTES_PER_PX/MemUtils.BYTES_IN_MB);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment