title: How to resize dimension of image before loading bitmap
body: <p>Right now to load an image and then resize it (width/height), I do the following:</p>
  
  <pre><code>BitmapFactory.Options options = new BitmapFactory.Options();
  options.inSampleSize = 1;
  options.inJustDecodeBounds = true;
  BitmapFactory.decodeFile(filepath, options);
  options.inSampleSize = ImageResizer.calculateInSampleSize(options, x, y);
  options.inJustDecodeBounds = false;
  Bitmap src = BitmapFactory.decodeFile(filepath, options);
  
  Matrix matrix = new Matrix();
  matrix.postScale(x, y);
  Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix,true);
  return bmp;
  </code></pre>
  
  <p>The problem with this approach is that I first load the “bad” bitmap as <code>src</code> and then load the good bitmap as <code>bmp</code>. </p>
  
  <p>Bitmaps are expensive. I would rather not load <code>src</code> but rather resize my bitmap before the first and only loading as <code>bmp</code>, perhaps while <code>options.inJustDecodeBounds = true</code>. In any case, does anyone know how I might do this well? <strong>How do I resize the dimensions of an image efficiently?</strong></p>