I want to crop an image in my application when it is selected from gallery.My cropping code work from the simulator but not properly work on phones. I set outputX=400 and outputY =487. In my simulator i get the output bitmap with 400 x 487 resolution,but when i cropped the image from phone gallery i get the output bitmap with 145 x 177 resolution. Why does it happen? My code for cropping is given below
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 500);
intent.putExtra("aspectY", 750);
intent.putExtra("scale", true);
intent.putExtra("outputX", 400);
intent.putExtra("outputY", 487);
intent.putExtra("return-data", true);
startActivityForResult(Intent.createChooser(intent,"Complete action using"), PICK_FROM_GALLERY);
On onActivityResult
if (requestCode == PICK_FROM_GALLERY) {
Bundle extras2 = data.getExtras();
if (extras2 != null) {
Bitmap bm = extras2.getParcelable("data");
imgview.setImageBitmap(photo);}
I think this will address the issue.
http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/
PS: This code may or may not work on all devices. This bit of code relies on code that is not part of the API. The only way to do cropping is to put the code directly in your app.
or Refer these sites for more help:
http://www.londatiga.net/featured-articles/how-to-select-and-crop-image-on-android/ http://www.androidhub4you.com/2012/07/how-to-crop-image-from-camera-and.html