Modify Android crop intent

好久不见. 提交于 2019-12-10 11:54:34

问题


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?


回答1:


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

  • Select and crop with a maximum size in android
  • Android Camera Intent with Crop
  • How to crop the parsed image in android?



回答2:


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.



来源:https://stackoverflow.com/questions/11880253/modify-android-crop-intent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!