如何从android中的图像裁剪矩形

Pau*_*eno 5 android

我正在使用示例裁剪从库中选择的图像,但问题是该示例仅裁剪正方形.是否可以裁剪矩形而不仅仅是正方形?在该示例中,如果我移动一侧,则相邻侧移动,使其保持方形选择.

谢谢.

Pau*_*eno 12

我发现可以使用内置的Android裁剪处理程序裁剪矩形.(com.android.camera.action.CROP).要裁剪矩形,您需要删除我之前传递的示例的以下参数:

intent.putExtra("outputX", 200); //Set this to define the max size of the output bitmap
intent.putExtra("outputY", 200); //Set this to define the max size of the output bitmap
intent.putExtra("aspectX", 1); //Set this to define the X aspect ratio of the shape
intent.putExtra("aspectY", 1); //Set this to define the Y aspect ratio of the shape
Run Code Online (Sandbox Code Playgroud)

设置aspectX和aspectY将强制android在移动其中一个时移动形状的两侧.注释这些线条,你就可以随意移动形状了.