GDI + DashStyle在.NET中引发OutOfMemoryException [英] GDI+ DashStyle throws OutOfMemoryException in .NET

查看:115
本文介绍了GDI + DashStyle在.NET中引发OutOfMemoryException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在渲染对象层次结构时使用了DashStyle.Dash.我的应用程序广泛使用Graphics.Transform,我发现在某些比例尺值(包括100%的比例尺)和某些旋转角度下,使用带有DashStyle.Dash的笔时Graphics.DrawLine会抛出OutOfMemoryException.使用Google时,我发现这是知名 阻止 问题.到目前为止,我还没有找到解决此问题的方法.

I'm using DashStyle.Dash while rendering my hierarchy of objects. My application uses Graphics.Transform extensively and I find that at some scale values (including a scale of 100%) and some angles of rotation, Graphics.DrawLine throws OutOfMemoryException when using a pen with DashStyle.Dash. Using Google I found that this is a well-known problem. Microsoft tells us that this is not a blocking issue. So far, I have not found a workaround for this problem.

我有什么选择?

推荐答案

我刚刚遇到了相同的问题.经过进一步调查,我发现了以下内容.

I just encountered the same issue. Upon further investigation I discovered the following.

  1. 行长恰好是自定义虚线图案的长度. 更改线长+/- 1像素可避免错误.
  2. 我正在使用LineCapRoundDashCapRound,切换到 LineCapSquareDashCapFlat避免了错误
  3. 错误来自尝试平整路径(大概是圆角的末端)
  4. 笔的宽度为零.
  1. The line length was exactly the custom dash pattern length. Changing the line length +/- 1 pixel avoided the error.
  2. I was using LineCapRound and DashCapRound, switching to LineCapSquare and DashCapFlat avoided the error
  3. The error came from trying flatten the path (presumably from the rounded ends)
  4. The pen width was zero.

我的最终解决方案是不画零宽度的线!

My final solution was to not draw zero width lines!

这篇关于GDI + DashStyle在.NET中引发OutOfMemoryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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