Modify Android crop intent

2019-06-14 06:36发布

I have created a sample app for cropping images and I am calling the built-in crop intent.

Here is my code:

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");                  
intent.setData(mImageCaptureUri);
intent.putExtra("outputX", 200);
intent.putExtra("outputY", 200);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);

How can I modify the crop area as per the user's input?

2条回答
看我几分像从前
2楼-- · 2019-06-14 07:19

Yes you can, you need to change outputX/outputY and aspectX/aspectY according to your need. See also

查看更多
神经病院院长
3楼-- · 2019-06-14 07:26

Just remove the output/aspect/scale parameters.

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");                  
intent.setData(mImageCaptureUri);
intent.putExtra("return-data", true);

If this doesn't give you the result you want, try adding some of those parameters again, but not all.

Note! This action is not supported on all devices, so you should also check for ActivityNotFoundException when you start the activity, find an alternative way to crop on those devices or ask the user to install an app for that such as QuickPic.

查看更多
登录 后发表回答