title: Resizing bitmap from InputStream
body: <p>I trying to resize one image from InputStream, so I use the code in <a href="https://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object/823966#823966">Strange out of memory issue while loading an image to a Bitmap object</a> but I don't know why this code always return Drawable without image.</p>
  
  <p>This one works well:</p>
  
  <pre><code>private Drawable decodeFile(InputStream f){
      try {
          InputStream in2 = new BufferedInputStream(f);
          BitmapFactory.Options o2 = new BitmapFactory.Options();
          o2.inSampleSize=2;
          return new BitmapDrawable(BitmapFactory.decodeStream(in2, null, o2));
      } catch (Exception e) {
          return null;
      }
  }
  </code></pre>
  
  <p>This one does not work:</p>
  
  <pre><code>private Drawable decodeFile(InputStream f){
      try {
          InputStream in1 = new BufferedInputStream(f);
          InputStream in2 = new BufferedInputStream(f);
          //Decode image size
          BitmapFactory.Options o = new BitmapFactory.Options();
          o.inJustDecodeBounds = true;
          BitmapFactory.decodeStream(in1,null,o);
  
          //The new size we want to scale to
          final int IMAGE_MAX_SIZE=90;
  
          //Find the correct scale value. It should be the power of 2.
          int scale = 2;
          if (o.outHeight &gt; IMAGE_MAX_SIZE || o.outWidth &gt; IMAGE_MAX_SIZE) {
              scale = (int)Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / 
                 (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5)));
          }
  
          BitmapFactory.Options o2 = new BitmapFactory.Options();
          o2.inJustDecodeBounds = false;
          o2.inSampleSize=scale;
          return new BitmapDrawable(BitmapFactory.decodeStream(in2, null, o2));
      } catch (Exception e) {
          return null;
      }
  }
  </code></pre>
  
  <p>why one option affect the other? how its possible if I use two different InputStream and Options?</p>