G
Guest
I am working on a user control that supports zooming in and out. It appears
that when the user is zoomed out a lot that the GraphicsPath.Widen method is
throwing an OutOfMemoryException.
To simulate this you can run the following code:
PointF[] points = new PointF[] { new PointF(0.06403162f, 244.35968f),
new PointF(242.231628f, 244.402359f) };
using(System.Drawing.Drawing2D.GraphicsPath path =
new System.Drawing.Drawing2D.GraphicsPath())
{
path.AddLine(points[0], points[1]);
using(System.Drawing.Pen pen =
new Pen(Color.Black, 0.00853754953f))
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
float diameter = 6f * 0.00213438738f;
float radius = diameter/2;
foreach(PointF point in points)
{
using(Brush endPointBrush = new SolidBrush(pen.Color))
path.AddEllipse(point.X - radius, point.Y - radius,
diameter, diameter);
}
path.Widen(pen);
}
}
Basically I am trying to understand why the exception is being thrown.
Knowing that I would like to do something that will prevent the exception and
create a region that includes the area I am trying to describe (if its larger
that's ok).
that when the user is zoomed out a lot that the GraphicsPath.Widen method is
throwing an OutOfMemoryException.
To simulate this you can run the following code:
PointF[] points = new PointF[] { new PointF(0.06403162f, 244.35968f),
new PointF(242.231628f, 244.402359f) };
using(System.Drawing.Drawing2D.GraphicsPath path =
new System.Drawing.Drawing2D.GraphicsPath())
{
path.AddLine(points[0], points[1]);
using(System.Drawing.Pen pen =
new Pen(Color.Black, 0.00853754953f))
{
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
float diameter = 6f * 0.00213438738f;
float radius = diameter/2;
foreach(PointF point in points)
{
using(Brush endPointBrush = new SolidBrush(pen.Color))
path.AddEllipse(point.X - radius, point.Y - radius,
diameter, diameter);
}
path.Widen(pen);
}
}
Basically I am trying to understand why the exception is being thrown.
Knowing that I would like to do something that will prevent the exception and
create a region that includes the area I am trying to describe (if its larger
that's ok).