⌘BABAKOV.NET Let's code!
100% [dark] [ru]
~/tags/picturebox $

#picturebox

1 posts

1 total

Cutting a rectangular area of an image in C#

From the archive... Recently, I had to make a simple image cropping tool, so that the user could manually select an area on the source image and cut it out. In principle, nothing complicated, the most difficult thing is probably drawing the selection rectangle when you click the mouse button and move it over the image - highlighting the necessary area.<br><br>First, the most important thing. On the image <b>pictureBox</b> immediately set the <b>SizeMode</b> property to <i>AutoSize</i>, without any <i>Zoom-ы</i> if you don't want to deal with scaling.<br><br>Next - we need to make it work so that scrolling works when selecting with the mouse. It just so happened that this is a painful place in .NET (it doesn't work on its own, and that's it).<br><br>To make it work, do this:

243 views 0 comments 0 likes ./Read →