在图像上定义多边形

在图像上定义多边形

本文介绍了在图像上定义多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我正在尝试在Image上动态定义多边形..即用户将在单击鼠标时定义多边形点,然后定义的区域的颜色将改变..

请请帮我...

在此先感谢

Hello,


I am trying to define polygon over Image Dynamically....i.e. User will define polygon points on mouse click and after that defined area''s color will change..

please please help me ...

Thanks in advance

推荐答案

GraphicsPath path = new GraphicsPath();


在鼠标Down事件中,在路径中添加以下行:


In your mouse Down event, add lines to the path:

path.AddLine(oldPoint, newPoint);

其中0old点是上一次鼠标单击的位置.
处理任何保存图像的对象的Paint事件,并从GraphicsPath构造一个Region.然后,您可以根据需要在该区域内绘制:

Where 0old point is the previous mouse click location.
Handle the Paint event for whatever object holds your image, and construct a Region from the GraphicsPath. You can then draw as needed within the region:

Region r = new Region(path);
e.Graphics.FillRegion(Brushes.Red, r);



这篇关于在图像上定义多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:42