2D FillRegion Performance on Large Region
Is there a staightforward way of improving the performance of FillRegion when drawing a very small window on a very large region? The C# example below illustrates the issue - it takes about 5 seconds on my 3GHz PC. We also tried using SetClip on the Graphics with similar results.
If not, do we have to manipulate the PathData directly and is there a good example?
Thanks in advance...
private void Form1_Paint(object sender, PaintEventArgs e)
{
// points for the path
Point[] pts = new Point[7];
pts[0] = new Point(-50000000, 0);
pts[1] = new Point(-25000000, -6000000);
pts[2] = new Point(0, -3000000);
pts[3] = new Point(25000000, -10000000);
pts[4] = new Point(50000000, -1000000);
pts[5] = new Point(0, 10000000);
pts
= new Point(-40000000, 5000000);
// type of each point
byte[] types = new byte[7];
types[0] = (byte)PathPointType.Line;
types[1] = (byte)PathPointType.Line;
types[2] = (byte)PathPointType.Line;
types[3] = (byte)PathPointType.Line;
types[4] = (byte)PathPointType.Line;
types[5] = (byte)PathPointType.Line;
types
= (byte)PathPointType.Line;
// make a region from the path
GraphicsPath path = new GraphicsPath(pts, types, FillMode.Alternate);
System.Drawing.Region region = new Region(path);
// make a rectangle the size of the form and use it to clip the region
Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
region.Intersect(rect);
// fill the region
Brush brush = new SolidBrush(Color.Beige);
e.Graphics.FillRegion(brush, region);
}

