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

问题描述:

我使用的例子裁剪被从库中选择的图像,但问题是,例如只作物正方形。有没有可能对作物的矩形,而不是唯一的广场?在这个例子中,如果我移动一边邻边一起移动,保持一个正方形的选择。

i'm using this example to crop an image that was selected from the gallery but the problem is that example only crop squares. Would it be possible to crop rectangles instead of only squares? In that example if I move one side the adjacent side moves along, keeping it a square selection.

感谢。

我发现这是可以修剪使用内置Android裁剪处理的矩形。(com.android.camera.action.CROP)。要裁剪矩形,你需要删除我之前通过例如下列参数:

i found that's possible to crop rectangles using the built-in Android cropping handler.(com.android.camera.action.CROP). To crop rectangles you need to remove the following parameters of the example that i passed before:

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

设置aspectX和aspectY将迫使Android的,当你移动其中一个移动形状的两侧。注释这些行,你就可以自由移动的形状。

Setting the aspectX and aspectY will force the android to move both sides of the shape when you move one of them. Comment those lines and you'll be free to move the shape.