是否可以在不返回应用程序的情况下裁剪从 Android 上的相机拍摄的图像?

Is it possible to crop an image captured from the Camera on Android without returning to the app?

目标是允许用户使用 Android 设备上的相机拍摄新图像。我需要最终图像是一个正方形。我看不出有什么方法可以在不使用相机 class 并做更多工作的情况下限制捕获图像的大小。

我想做的是使用 MediaStore.ACTION_IMAGE_CAPTURE Intent 操作启动相机 activity 并在捕获图像后立即执行裁剪操作。从相机返回时,我可以通过在 onActivityResult 中使用 "com.android.camera.action.CROP" 操作来获得所需的行为,但这 returns 用户在开始裁剪操作之前访问我的应用程序。

总而言之,我现在拥有的是:

My-app -> Camera -> My-app -> Crop

理想情况下我想要的是:

My-app -> Camera -> Crop -> My-app

(如果可以在打开相机时告诉图像捕获意图使用特定尺寸,如果我只是想念如何做到这一点,那就太好了。)

提前致谢。

I am able to get the desired behavior by using the "com.android.camera.action.CROP" action in onActivityResult when returning from the camera but this returns the user to my app before starting the Crop action.

Android does not have a CROP Intent。很少有设备具有支持您未记录的 Intent 操作的 activity。

and ideally what I would like is: My-app -> Camera -> Crop -> My-app

欢迎您使用相机 API 和 an image-cropping library 自己完成所有这些工作。

或者,欢迎您继续使用 ACTION_IMAGE_CAPTURE,但请自行裁剪图像。

或者,欢迎您坚持使用现有代码,请记住您的图像不会在大多数 Android 设备上被裁剪。