Get Bitmap Width And Height Without Loading To Memory
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.??
Solution 1:
You can set the BitmapFactory.Options with inJustDecodeBounds to get the image width and height without loading the bitmap pixel in memory
BitmapFactory.OptionsbitmapOptions=newBitmapFactory.Options();
bitmapOptions.inJustDecodeBounds = true;
BitmapFactory.decodeStream(inputStream, null, bitmapOptions);
intimageWidth= bitmapOptions.outWidth;
intimageHeight= 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.
Post a Comment for "Get Bitmap Width And Height Without Loading To Memory"