【发布时间】:2016-08-06 10:53:40
【问题描述】:
我有一个简单的应用程序,比如“paint”,我绘制了一个设置为pictureBox.Image 的位图。我可以在这里绘制多边形并在顶点上捕捉它们并移动,因此必须重新绘制位图。
有repaint方法。
private void DrawFullList()
{
if(pictureBox2.Image != null)
pictureBox2.Image.Dispose();
graphic = new Bitmap(pictureBox2.Width, pictureBox2.Height); // exception here
g = Graphics.FromImage(graphic);
pictureBox2.Image = graphic;
for (int i = 0; i < PointsList.Count; i++)
{
bool yellowframe = false;
if (i == dblclck)
yellowframe = true;
Draw(BrushList[i], PointsList[i], yellowframe);
}
}
所以如果我捕捉到顶点并移动鼠标,DrawFullList() 函数就会在 pictureBox_MouseMove(object sender, MouseEventArgs e) 函数中被激活。当我移动一个顶点几秒钟(例如,制作圆圈)时,抛出异常'System.ArgumentException' occurred in System.Drawing.dll。
这里有什么提示吗? :)
编辑:
有关异常的附加信息:
parameter is invalid
【问题讨论】:
-
是否有特定的消息伴随它?
-
参数无效
-
无效值的值是多少?你打破例外吗?询问价值,看看它不喜欢什么。
-
宽度 = 1328,高度 = 1162;但是位图的大小在移动顶点期间没有改变,并且它在几秒钟内正确创建。