I have a picturebox with image, in which I have drawn a rectangular selection. I want to get the selected portion of image in another picturebox. How can I get that? Please help.
问问题
2000 次
2 回答
0
然后使用选择的坐标创建Rectangle rectangle
:
Bitmap sourceBitmap = new Bitmap(pictureBoxImage);
Bitmap croppedBitmap = sourceBitmap.Clone(rectangle, sourceBitmap.PixelFormat);
之后,您可以croppedBitmap
在另一个图片框中使用。不要忘记处理未使用的图像。就这样。
于 2013-09-26T15:28:26.440 回答
0
假设您传入的rect
是在您的坐标中计算的。您可以像这样使用并在另一个中获取该部分:Rectangle
Graphics.DrawRectangle
pictureBox
RectangleToScreen
RectangleToClient
pictureBox
Rectangle portion = pictureBox2.RectagleToClient(pictureBox1.RectangleToScreen(rect));
//portion is the Rectangle calculated in the coordinates of pictureBox2.
于 2013-09-25T17:09:10.223 回答