title: Crop a bitmap to particular width and height without losing resolution
body: <p>I need to crop an image from gallery and save to the server. This is my code for cropping image</p>
  
  <pre><code>   private void startCropImage() {
  
      Intent intent = new Intent("com.android.camera.action.CROP");
      intent.setDataAndType(mImageCaptureUri, "image/*");
  
      intent.putExtra("crop", "true");
      intent.putExtra("aspectX", 1);
      intent.putExtra("aspectY", 1);
          //indicate output X and Y
      intent.putExtra("outputX", 400);
      intent.putExtra("outputY", 487);
  
      intent.putExtra("return-data", true);
      intent.putExtra("scale", true);
      startActivityForResult(intent, CROP_FROM_GALLERY);
  }
  </code></pre>
  
  <p>I need the output in 400*487,but after cropping the image when i check the width it's only 160 on device, but on AVD it shows the correct width. why does it happen? The following is my onActivityResult code</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  Bundle extras2 = data.getExtras();
  if (extras2 != null) {
  
  Bitmap bm2 = extras2.getParcelable("data");
  
  imgview.setImageBitmap(bm2);
  
  int width = bm2.getWidth();}
  </code></pre>