Android:在ImageView(或任何其他位图兼容的小部件)上绘制可移动且可大小的矩形并裁剪选定的区域(Android: Draw a moveable and sizeable rectang

编程入门 行业动态 更新时间:2024-10-28 00:16:13
Android:在ImageView(或任何其他位图兼容的小部件)上绘制可移动且可大小的矩形并裁剪选定的区域(Android: Draw a moveable and sizeable rectangle on ImageView(Or any other bitmap compatible widget) and crop the selected region)

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

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

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/

最满意答案

经过充分研究后,我想出的最终解决方案是:

扩展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.

更多推荐

本文发布于:2023-08-06 11:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1448466.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位图   矩形   部件   大小   区域

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!