title: Trying to scale down a Bitmap in Android not working
body: <p>I'm trying to scale down a bitmap. In short, the image is originally from a ByteArray with a width of 4016. After I scale the image down with factory options, it still reports the image with a width of 4016.</p>
  
  <p>Here are two clips of my code:</p>
  
  <pre><code>Bitmap myBitmap = null;
          @Override
          protected byte[] doInBackground(Object... params) {
  
  
              final BitmapFactory.Options options = new BitmapFactory.Options();
              options.inJustDecodeBounds = true;
  
              if (options.outHeight &gt; options.outWidth) {
                  options.inSampleSize = calculateInSampleSize(options, 640, 960);
              } else {
                  options.inSampleSize = calculateInSampleSize(options, 960, 640);
              }
  
              options.inJustDecodeBounds = false;
  
              //myImageByteArray is 4016 wide
              myBitmap = BitmapFactory.decodeByteArray(myImageByteArray, 0, myImageByteArray.length, options);
  
              //This log statement outputs 4016!!! Shouldn't it be smaller since I just decoded the byteArray with options?
              Log.d("bitmap", myBitmap.getWidth()+"");
  
  }
  
          public int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
              // Raw height and width of image
              final int height = options.outHeight;
              final int width = options.outWidth;
              int inSampleSize = 1;
  
              if (height &gt; reqHeight || width &gt; reqWidth) {
  
                  // Calculate ratios of height and width to requested height and
                  // width
                  final int heightRatio = Math.round((float) height / (float) reqHeight);
                  final int widthRatio = Math.round((float) width / (float) reqWidth);
  
                  // Choose the smallest ratio as inSampleSize value, this will
                  // guarantee
                  // a final image with both dimensions larger than or equal to
                  // the
                  // requested height and width.
                  inSampleSize = heightRatio &lt; widthRatio ? heightRatio : widthRatio;
              }
  
              return inSampleSize;
          }
  </code></pre>
  
  <h2>Update:</h2>
  
  <p>Here are two clips of my code:</p>
  
  <pre><code>Bitmap myBitmap = null;
          @Override
          protected byte[] doInBackground(Object... params) {
  
  
              final BitmapFactory.Options options = new BitmapFactory.Options();
              options.inJustDecodeBounds = true;
              //myImageByteArray is 4016 wide
              myBitmap = BitmapFactory.decodeByteArray(myImageByteArray, 0, myImageByteArray.length, options);
              if (options.outHeight &gt; options.outWidth) {
                  options.inSampleSize = calculateInSampleSize(options, 640, 960);
              } else {
                  options.inSampleSize = calculateInSampleSize(options, 960, 640);
              }
  
              options.inJustDecodeBounds = false;
  
              //myImageByteArray is 4016 wide
              myBitmap = BitmapFactory.decodeByteArray(myImageByteArray, 0, myImageByteArray.length, options);
  
              //This log statement outputs around 1000 now. 
              Log.d("bitmap", myBitmap.getWidth()+"");
  
  }
  
          public int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) {
              // Raw height and width of image
              final int height = options.outHeight;
              final int width = options.outWidth;
              int inSampleSize = 1;
  
              if (height &gt; reqHeight || width &gt; reqWidth) {
  
                  // Calculate ratios of height and width to requested height and
                  // width
                  final int heightRatio = Math.round((float) height / (float) reqHeight);
                  final int widthRatio = Math.round((float) width / (float) reqWidth);
  
                  // Choose the smallest ratio as inSampleSize value, this will
                  // guarantee
                  // a final image with both dimensions larger than or equal to
                  // the
                  // requested height and width.
                  inSampleSize = heightRatio &lt; widthRatio ? heightRatio : widthRatio;
              }
  
              return inSampleSize;
          }
  </code></pre>