Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

GDI+ throw OutOfMemoryException when draw a smill dash line.

23 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Colin Han

ungelesen,
07.10.2007, 02:19:0107.10.07
an
I was write follow code in my product.
-----------------------------------------
public void Test(Graphics g)
{
using (Pen pen = new Pen(Color.Red))
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
pen.DashOffset = 1;

g.DrawLine(pen, 0, 0, 1, 0);
}
}
-----------------------------------------
An OutOfMemoryException was be throw when we excute it.

The key points about above code is :
1. The Alpha channel of the pen's color is 255. Otherwise, the exception
is not throw, but the drawing is error.
2. All visible points of the line is blank. (in above code, I adjust the
dashoffset to 1 to ignore the first point about dot line).

I think it is bug for GDI+ or .NET FWK. But I must use it in my product. and
catch the exception is so slow for performance view.
Who can help me or tall me why this problem ocurre or help me to avoid this
problem.

------------------------------------------
Sorry, My English is so poor. orz
Thanks...

Bob Powell [MVP]

ungelesen,
07.10.2007, 06:13:2907.10.07
an
I think this is definitely a bug. It reproduces on my system as
described. The effect is not seen when we use a GraphicsUnit such as
inch or millimeter but is seen when we use default or display.

Because I cannot debug into the unmanaged DLL I don't know exactly why
the problem occurs but it's a problem.

I will try to escalate this to Microsoft.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

Patrick van Dijk

ungelesen,
08.10.2007, 02:59:2308.10.07
an
Colin,

We've experienced 'Out of memory exceptions' on a lot of occassions
when Drawing very small stuff.
Lines, Polygon, whatever, so we decided to put a try catch block
around it and are now considering moving to WPF.

Patrick

Colin Han

ungelesen,
08.10.2007, 03:52:0208.10.07
an
Bob Powell,

> I will try to escalate this to Microsoft.
Thanks for you help. Thanks vary much.

Colin Han

ungelesen,
08.10.2007, 03:54:0008.10.07
an
Because it is in painting logic, And it will be call more times. So, add try
catch block may take preformance problems. :(

Thanks.

0 neue Nachrichten