Android:在 ImageView(或任何其他位图兼容小部件)上绘制一个可移动且可调整大小的矩形并裁剪所选区域

发布于 2023-02-23 00:19:47 字数 305 浏览 27 评论 0原文

我想裁剪显示在 ImageView 上的图像。 我想要如何去做是我想要一个可调整大小的矩形显示在图像上。 该矩形将具有可移动的角(我可以通过触摸拖动角)以增加/减小其大小。 下图说明了我想开发的东西的演示。

PS 我不太确定如何表达我的问题。 我想要的是: http://imageshack.us/photo/my-images/832/customcropbox。图片/

I want to crop my image which is being displayed on an ImageView. How I want to go about it is that I want a re-sizable rectangle to be displayed on the image. That rectangle will have moveable corners (which I can drag around with touch) to increase/decrease its size. The image below illustrates a demo of something I would like to develop.

P. S. I am not quite sure how to phrase my question.
What I want:
http://imageshack.us/photo/my-images/832/customcropbox.jpg/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水水月牙 2023-03-02 00:19:47

经过大量研究,我得出的最终解决方案是:

扩展 ImageView 以制作我自己的自定义视图。

@Override onDraw 方法并在该方法中进行我的自定义绘图。

在视图上实现 onTouchListener 以获取触摸事件并根据它们的位置进行处理。

例如,

我检查了触摸是否在我在覆盖的 onDraw 方法中绘制的可移动矩形周围绘制的锚点圆的半径内。

编辑:
对不起,伙计们,我没有那段代码了,我很长时间后才来到这里,否则我会很乐意帮助你。

心痛。

The final solution I came up with after ample research was:

Extend ImageView to make my own custom view.

@Override onDraw method and do my custom drawing there in that method.

Implement onTouchListener on the view to get the touch events and process them according to their position.

e. g.

I checked whether the touch was in the radius of the anchor point circle I drew around the movable rectangle that I was drawing in my overriden onDraw method.

Edit:
I am sorry guys I don't have that piece of code anymore, I came here after a very long time otherwise would have loved to help you out.

Heartache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击“接受”或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文