0

I am developing app where i want to crop image taken from camera and upload to sftp server. I am using following code to crop image:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1; 
Bitmap bm = BitmapFactory.decodeFile(imagePath, opts);
Intent intent = new Intent("com.android.camera.action.CROP");              
intent .setDataAndType(outputFileUri, "image/*");
intent.putExtra("outputX",bm.getWidth());
intent.putExtra("outputY", bm.getHeight());
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", false); 
startActivityForResult(intent, 2);

With this I am getting a resizable rectangle. But while resizing cropped area width and height are changing proprtionally like this . enter image description here

I want to change width and height of cropped area independently like in PhotoCrop app

enter image description here

I hope you have understand my problem.

EDIT: ****Also image cropping is not working on Samsung galaxy S3 and another thing is that when i resize cropping area, it is zooming the image too much and image is getting blur..****

Linus Kleen
  • 33,871
  • 11
  • 91
  • 99
Umesh
  • 1,609
  • 1
  • 17
  • 28
  • 1
    Don't define the aspects? Generally this is not a public API, and you should integrate the code in your project. Otherwise your app may not work on phones that replace the default camera and gallery app (which host the cropping intent). – Nikolay Elenkov Dec 14 '12 at 06:53
  • Ya that's right.When we don't define aspects it will change height and width of cropped area independently. – Umesh Dec 14 '12 at 07:09
  • And then you accept some other answer :) Really though, integrate this into your app if you want to make sure it works on all devices. – Nikolay Elenkov Dec 14 '12 at 07:27

1 Answers1

4

Try This :

 intent.putExtra("aspectX", 0);
 intent.putExtra("aspectY", 0);

Hope it helps you.

Thanks.

Pratik Sharma
  • 13,307
  • 5
  • 27
  • 37
  • Hi can u give me some advise?......... image cropping is not working samsung galaxy S3 and more thing when i resize cropping area, it is zooming the image too much and image is getting blurre.. Please advice.. – Umesh Dec 17 '12 at 06:31
  • @Umesh post another question if does not with working samsung galaxy S3 and more thing when i resize cropping area, it is zooming the image too much and image is getting blurre. And keep this answer as accepted because what you asked is solved by this solution. – Pratik Sharma Dec 17 '12 at 07:44
  • Sorry,Its my bad.I have accepted your answer and I have put new question http://stackoverflow.com/questions/13910842/android-cropped-image-so-much-zoomed-and-looking-blurre).Please give some advise. – Umesh Dec 17 '12 at 08:47