473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Graphics.FillRectangle vs Graphics.FillPath speed

Hi, I would like to know which is the faster method to call,
FillRectangle or FillPath.

I have a path which is essentially a square, except for rounded corners,
so I can end up with 2 almost identical lines of code for the fill, but
want to know which is "more correct".

LinearGradientBrush backColorBrush = new
LinearGradientBrush(this.ClientRectangle, backColor, backColor2,
linearGradientMode);
e.Graphics.FillPath(backColorBrush, path);
-or-
e.Graphics.FillRectangle(backColorBrush, this.ClientRectangle);

Any help or opinion greatly received,

Thanks
May 23 '06 #1
2 7185
Mark,

They both produce the same effect, it's just that calling FillPath will
require more work on your part (since you have to construct the path).

I wouldn't be surprized if FillRectangle called FillPath (at the windows
API layer, not the .NET API layer), doing exactly what you would be doing by
creating the path.

I don't think that any one is "more correct", it's just a matter of how
much extra work you want to do for the same result.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark Ingram" <no****@nowhere.com> wrote in message
news:e2**************@TK2MSFTNGP02.phx.gbl...
Hi, I would like to know which is the faster method to call, FillRectangle
or FillPath.

I have a path which is essentially a square, except for rounded corners,
so I can end up with 2 almost identical lines of code for the fill, but
want to know which is "more correct".

LinearGradientBrush backColorBrush = new
LinearGradientBrush(this.ClientRectangle, backColor, backColor2,
linearGradientMode);
e.Graphics.FillPath(backColorBrush, path);
-or-
e.Graphics.FillRectangle(backColorBrush, this.ClientRectangle);

Any help or opinion greatly received,

Thanks

May 23 '06 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Mark,

They both produce the same effect, it's just that calling FillPath will
require more work on your part (since you have to construct the path).

I wouldn't be surprized if FillRectangle called FillPath (at the windows
API layer, not the .NET API layer), doing exactly what you would be doing by
creating the path.

I don't think that any one is "more correct", it's just a matter of how
much extra work you want to do for the same result.

Hope this helps.


Thanks for the quick reply, the amount of effort required in each is the
same, I have access to both the client rectangle and the graphics path.
Will probably stick with FillPath then.

Thanks,
May 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JBiagio | last post by:
Hello All, I am attempting to learn a bit about the GDI+ transforms and charting data and I feel like I'm getting a handle on how the transforms work. My chart object has a large "canvas" bitmap...
2
by: John Bailo | last post by:
I am walking through some of the very first sample code from the book "Beginning .NET Game Programming" from Apress. I identify his sample code with //SC This code puzzles me: Graphics graph...
0
by: matko | last post by:
When I call the following function, the rectangle will overlap the graphics that is drawn _afterwards_. Why is that? How can I make sure my graphics is drawn in correct order? (Note: If I...
2
by: rushikesh.joshi | last post by:
Hi All, I want to create a webcontrol which will generate a bar (bar chart). I have done some graphics code in my ASPX page and it's working fine, but how do i create a Custom Control or User...
0
by: mrajanikrishna | last post by:
Hello, I have generated an image(T-Shirt). It was drawn using lines, curves. After that I filled with color(gr.fillpath(greenBrush,graphicsPath)). I used blackPen to draw lines and curves with...
1
by: gopal28 | last post by:
HI I am using the Graphics to paint to a a picture box but if i minimise my screen the picture disappears is there anyway i can fix this?? Please Help!! here is my code: PLease Help me it will be...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Email Question: When I send an email (basically a sms to a phone) from ms outlook it works fine. When I try to send it pragmatically I get an error stating that it can’t relay for <the email...
0
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I have a borderless form that has a transparent background. I only wanted the color that I painted the background with to be transparent and not the controls on the form or the box I draw in the...
10
by: eddie tan | last post by:
Hi, I have a picturebox with graphics drawn from different objects. In one object I used Pen P1; P1 = new Pen(Color.Blue, 3); Graphics g = null; g = Graphics.FromImage(image.Image);...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.