PC Review


Reply
Thread Tools Rate Thread

2D FillRegion Performance on Large Region

 
 
rlg
Guest
Posts: n/a
 
      30th Aug 2006
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 rect 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);
}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Large file performance texicaliblues Microsoft Excel Misc 4 12th Apr 2008 05:28 PM
Calculating Max, Min, Ave etc of a large region Jim Brass Microsoft Excel Programming 5 30th Dec 2005 05:07 AM
Control.Region performance =?Utf-8?B?SmVsbGUgdmFuIGRlciBCZWVr?= Microsoft Dot NET Framework Forms 0 15th Nov 2005 02:59 PM
Xbox360 CPU taking large performance hit? only 60-70% performance of what MS was expecting? R500 Xenon ATI Video Cards 0 9th May 2005 05:01 AM
Xbox360 CPU taking large performance hit? only 60-70% performance of what MS was expecting? R500 Xenon Processors 0 9th May 2005 05:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:22 PM.