GraphicsPath的和OutOfMemoryException异常 [英] GraphicsPath and OutOfMemoryException

查看:413
本文介绍了GraphicsPath的和OutOfMemoryException异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下

private bool IsPathVisible(Rectangle detectorRectangle, GraphicsPath path, Pen pen)
{
    path.Widen(pen);
    return IsPathVisible(detectorRectangle, path);
}

路径点是同一个点,我收到了OutOfMemoryException异常(使用拓宽函数)。

When path points are the same point, I receive a OutOfMemoryException (using Widen function).

我该如何管理呢?

推荐答案

这是用钢笔和拓宽方法的错误。确保你的路径和路径的终点的起始点是不一样的。

That's a bug with the pen and the widen method. Make sure your startpoint of the path and the endpoint of the path are not the same.

这是一个演示:

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);
  }
}

下面是它被报告给微软:<一href="http://connect.microsoft.com/VisualStudio/feedback/details/98287/graphicspath-widen-throw-outofmemoryexception-if-the-path-has-a-single-point"相对=nofollow> GraphicsPath.Widen抛出OutOfMemoryException异常如果路径中有一个单点

Here is where it was reported to Microsoft: GraphicsPath.Widen throw OutOfMemoryException if the path has a single point

这篇关于GraphicsPath的和OutOfMemoryException异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆