title: Android bitmap image size
body: <p>I am downloading images from web and i use Gallery widget to display the images.</p>
  
  <p>If the downloaded image size is huge, my application crashes with the below log.</p>
  
  <pre><code>"E/GraphicsJNI( 3378): VM won't let us allocate 5591040 bytes"
  </code></pre>
  
  <p>I want to scale down the downloaded image size only when the image size is more to an extent that it will crash the app. I have written the code to scale down the image size but i am not sure how to find the bitmap size so i can decide on whether to scale or not</p>
  
  <pre><code>   BitmapFactory.Options o = new BitmapFactory.Options();
     o.inSampleSize = 2;
     Bitmap bit = BitmapFactory.decodeStream(inputStream,null,o);
     Bitmap scaled = Bitmap.createScaledBitmap(bit, 200, 200, true);
     bit.recycle();
     return scaled;
  </code></pre>