我有以下内容
private bool IsPathVisible(Rectangle detectorRectangle, GraphicsPath path, Pen pen)
{
path.Widen(pen);
return IsPathVisible(detectorRectangle, path);
}
Run Code Online (Sandbox Code Playgroud)
当pathpoint是相同的点时,我收到一个OutOfMemoryException(使用Widen函数).
我该如何管理它?
这是笔和扩展方法的错误.确保路径的起点和路径的终点不相同.
这是一个演示:
private void panel1_Paint(object sender, PaintEventArgs e)
{
//This works:
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(new Point(16, 16), new Point(20, 20));
path.Widen(Pens.Black);
e.Graphics.DrawPath(Pens.Black, path);
}
//This does not:
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(new Point(20, 20), new Point(20, 20));
path.Widen(Pens.Black);
e.Graphics.DrawPath(Pens.Black, path);
}
}
Run Code Online (Sandbox Code Playgroud)
以下是向Microsoft报告的地方:如果路径只有一个点,则GraphicsPath.Widen会抛出OutOfMemoryException
| 归档时间: |
|
| 查看次数: |
884 次 |
| 最近记录: |