如何从Android中的图像裁剪矩形 [英] How to crop a rectangle from an image in android

查看:841
本文介绍了如何从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.

这篇关于如何从Android中的图像裁剪矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆