我有以下内容
private bool IsPathVisible(Rectangle detectorRectangle, GraphicsPath path, Pen pen)
{
path.Widen(pen);
return IsPathVisible(detectorRectangle, path);
}
When path
点是相同的点,我收到 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);
}
}
以下是向 Microsoft 报告的情况:如果路径只有一个点,GraphicsPath.Widen 会抛出 OutOfMemoryException http://connect.microsoft.com/VisualStudio/feedback/details/98287/graphicspath-widen-throw-outofmemoryexception-if-the-path-has-a-single-point
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)