title: android image not maintain aspect ratio
body: <p>Hello i am new in android. Can anybody help me to maintain aspect ratio of image. In my application i select image from SDCARD and display it in imageview by passing intent to next activity. But most of the times when image is big or small then image is not display properly in my imageview. </p>
  
  <pre><code> BitmapFactory.Options options = new BitmapFactory.Options();  
                  options.inTempStorage = new byte[16 * 1024];  
                  options.inJustDecodeBounds = true;  
                  bitmap = BitmapFactory.decodeStream(getContentResolver()  
                          .openInputStream(mImageCaptureUri));
  
                  ByteArrayOutputStream bs = new ByteArrayOutputStream();
                  bitmap.compress(Bitmap.CompressFormat.PNG, 50, bs);
  
                  Bitmap newbitmap = Bitmap.createScaledBitmap(bitmap, 120,
                          120, true);
  
                  newbitmap.compress(Bitmap.CompressFormat.PNG, 50, bs);
                  Intent photointent = new Intent(MethinkzActivity.this,
                          DisplayImage.class);
                  photointent.putExtra("photo", bs.toByteArray());
  
                  startActivity(photointent);
  </code></pre>
  
  <p>And at other activity i catch that by using following.</p>
  
  <pre><code>    bitmap = BitmapFactory.decodeByteArray(getIntent()
                  .getByteArrayExtra("photo"), 0, getIntent()
                  .getByteArrayExtra("photo").length);
  
  
          final double viewWidthToBitmapWidthRatio = (double) my_image
                  .getWidth() / (double) bitmap.getWidth();
          my_image.getLayoutParams().height = (int) (bitmap.getHeight() * viewWidthToBitmapWidthRatio);
          my_image.setImageBitmap(bitmap);
  </code></pre>
  
  <p>Please help me to find this.</p>