GDI + DashStyle在.NET中引发OutOfMemoryException [英] GDI+ DashStyle throws OutOfMemoryException in .NET
问题描述
我在渲染对象层次结构时使用了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像素可避免错误.
- 我正在使用
LineCapRound
和DashCapRound
,切换到LineCapSquare
和DashCapFlat
避免了错误 - 错误来自尝试平整路径(大概是圆角的末端)
- 笔的宽度为零.
- The line length was exactly the custom dash pattern length. Changing the line length +/- 1 pixel avoided the error.
- I was using
LineCapRound
andDashCapRound
, switching toLineCapSquare
andDashCapFlat
avoided the error - The error came from trying flatten the path (presumably from the rounded ends)
- The pen width was zero.
我的最终解决方案是不画零宽度的线!
My final solution was to not draw zero width lines!
这篇关于GDI + DashStyle在.NET中引发OutOfMemoryException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!