title: Differences between BitmapFactory.decodeResource and BitmapFactory.decodeStream
body: <p>I've got an if-else scenario where the if-path uses this code:</p>
  
  <pre><code>BitmapFactory.Options options = new BitmapFactory.Options();
  options.inScaled = false;
  options.inPurgeable = true;
  options.inInputShareable = true;
  bitmap = BitmapFactory.decodeResource(getResources(), resourceId, options);
  </code></pre>
  
  <p>And the else-path uses this code:</p>
  
  <pre><code>InputStream is = getContentResolver().openInputStream(Uri.fromFile(file));
  BitmapFactory.Options options = new BitmapFactory.Options();
  options.inScaled = false;
  options.inPurgeable = true;
  options.inInputShareable = true;
  bitmap = BitmapFactory.decodeStream(is, null, options);
  </code></pre>
  
  <p>Now to me, reading the short description from the API, testing and Googling I can't quite figure out the difference, but there seems to be a suble one.</p>
  
  <p>The first piece of code scales to fit the width of the screen when applied to a ImageView (within a RelativeLayout, within a ScrollView). The second piece of code does not, which is my problem. It seems to loose it's aspect ratio somehow as well, because if I apply:</p>
  
  <pre><code>imageView.setAdjustViewBounds(true);
  imageView.setScaleType(ImageView.ScaleType.FIT_XY);
  </code></pre>
  
  <p>It manages to fit it to the width, but messes up the height (making it shorter than it should be). <b>Any input would be greatly appreciated!</b></p>
  
  <p>(I've already tried to change the first piece of code to see if I had messed something else up, but this rewrite of the if-path gave the same error:)</p>
  
  <pre><code>BitmapFactory.Options options = new BitmapFactory.Options();
  options.inScaled = false;
  options.inPurgeable = true;
  options.inInputShareable = true;
  bitmap= BitmapFactory.decodeStream(getResources().openRawResource(resourceId), null, options);
  </code></pre>