【发布时间】:2013-04-15 13:44:56
【问题描述】:
我正在使用 DrawtoBitmap 将图形从面板保存到特定位置,但是当我打开文件时,图像的右下角部分应该是空白的。 这个空白矩形的大小似乎因绘图而异。 这是我的代码:
Bitmap bmp = new Bitmap(panel1.Width, panel1.Height);
Graphics g = Graphics.FromImage(bmp);
Rectangle rect = panel1.RectangleToScreen(panel1.ClientRectangle);
g.CopyFromScreen(rect.Location, Point.Empty, panel1.ClientSize);
g.Dispose();
panel1.DrawToBitmap(bmp, rect);
然后我使用 SaveFileDialog 来存储位图。 问题可能是我绘制的面板停靠在父 toolStripContainer.ContentPanel 中,我不确定。
非常感谢您对此问题的任何想法或解决方案!
【问题讨论】:
-
你试过不同的边距和内边距吗?
-
显示快照也会很有帮助。