Im a newbie in android, So i would like to know is there any way to get the dimensions of a Bitmap without loading the bitmap into memory.??
You can set the BitmapFactory.Options with inJustDecodeBounds to get the image width and height without loading the bitmap pixel in memory
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; BitmapFactory.decodeStream(inputStream, null, bitmapOptions); int imageWidth = bitmapOptions.outWidth; int imageHeight = bitmapOptions.outHeight; inputStream.close();
For more details:
public boolean inJustDecodeBounds Since: API Level 1 If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
public boolean inJustDecodeBounds
Since: API Level 1 If set to true, the decoder will return null (no bitmap), but the out... fields will still be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels.
http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inJustDecodeBounds
2.1m questions
2.1m answers
60 comments
57.0k users