How to select a region in a Windows Forms PictureBox?

百般思念 提交于 2019-12-10 20:50:08

问题


I want to get a part of picture in a PictureBox by allowing the user to select a rectangular region (similar to how it can be done in Photoshop with selection tool).

How I can do this?


回答1:


You would have to draw a rectangle or lines based on where they clicked and dragged. Your starting point would be the mouse x, y and then you would get the last point from mouse release x, y.




回答2:


Catch the mouse events on the Picture Box to define your selection rectangle and use Graphics.DrawRectangle to draw your selection rectangle in the Paint Event of the Picture Box.



来源:https://stackoverflow.com/questions/2456074/how-to-select-a-region-in-a-windows-forms-picturebox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!