How to know a Bitmap size from InputStream before creating the Bitmap?
<p>I need to scale an image before creating it and I want to do it only if it exceeds 1024KB (for example).</p>

<p>By doing the following I can scale the image but I only need to scale the ones that are bigger than the given size.</p>

<pre><code>Bitmap bmImg = null;
InputStream is = url.openStream();
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 10;
bmImg = BitmapFactory.decodeStream(is,null,opts);
</code></pre>

<p>How can I get the size of the Bitmap? (I'm happy knowing the amount of bytes, not the size after decompressing).</p>

<p><strong>Edit:</strong></p>

<p>I'm trying this:</p>

<pre><code>BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
Bitmap bmImg=BitmapFactory.decodeStream(is,null,opts);
Log.e("optwidth",opts.outWidth+"");
Bitmap bmImg1 = BitmapFactory.decodeStream(is);
</code></pre>

<p>The first time I use the InputStream (is) to decode it with the "inJustDecodeBounds" works fine and I can get the Bitmap dimensions.
The problem is that the second time I use it to actually decode the image, no image is shown.</p>

<p>What am I doing wrong? </p>
