473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GDI+ question-rounded label border does not draw correctly

I'm trying to create a form with some rounded controls, and I'm having
some problems with the rounding not working correctly. I've tried a
couple of different methods for creating the graphics path, including
the one from the GDI+ FAQ. It's a pretty simple path, and
mathematically it looks just fine. When I apply it to a control
though, I have two problems. First, the corners on the right side of
the control are obviously not rounded as much as the ones on the left
side, and if I attempt to add an outline to the control (by drawing the
path), I get missing pixels that break my lines. Essentialy, here's
what I'm doing in my derived label class (I included the gradient brush
code in case that might be affecting things):

Rectangle rect = new Rectangle(0, 0, Width, Height);
LinearGradientB rush GBrush = new LinearGradientB rush(
new Point(0, 0),
new Point((int)(Wid th*1.2), 0), cLeft, cRight);
this.region=Cre ateRoundedRectP ath(rect, 6);
e.Graphics.Fill Rectangle(GBrus h, rect);
Pen p = new Pen(Color.Gray, 2);
e.Graphics.Draw Path(p, path);
SolidBrush drawBrush = new SolidBrush(this .ForeColor);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment .Center;
RectangleF rectF = new RectangleF(0, 0, this.Width, this.Height);
e.Graphics.Draw String(this.Tex t, this.Font, drawBrush, rect, sf);

I'm using this code from the FAQ to calculate the path:

gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius *
2, 270, 90);

gp.AddLine(X + width, Y + radius, X + width, Y + height -
(radius * 2));

gp.AddArc(X + width - (radius * 2), Y + height - (radius *
2), radius * 2, radius * 2, 0, 90);

gp.AddLine(X + width - (radius * 2), Y + height, X +
radius, Y + height);

gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius
* 2, 90, 90);

gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

gp.CloseFigure( );
return gp;

Anyone have any idea what's going on? Is this just a limitation of
GDI+ that you're never going to get things correct to the pixel? I
have to doubt it, simply because the labels are very obviously lopsided
with broken outlines.

Thanks in advance!

Chris

Sep 25 '06 #1
0 2035

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

Similar topics

12
2396
by: Charles Law | last post by:
If I draw a rectangle, 6 inches by 2 inches, on a user control with a PageUnit of Inches, I get a rectangle of 7 by 2.2 inches. Is this what people would expect? I would have hoped that it was at least scaled consistently. Charles
1
1277
by: P1ayboy | last post by:
How efficient is it to use GDI to create images. Instead of having to create loads of titles for a web site, i would like to use the GDI. My concern is how intensive it is on the processor. Anyone have any opinions?? Thanks Rob
1
1696
by: David Sobey | last post by:
Hi I'm making a custom component using GDI+, a calendar grid thingy. I paint the grid and numbers in my overrided OnPaint. However, when i go to paint other things at other times in other functions, like cute little rectangles or fancy text, it calls OnPaint and I'm fairly sure it's painting over what i just painted 3 nanoseconds ago, coz nothing is appearing. Good way around this prob? cheers
7
2944
by: | last post by:
We create VC++ programs that does some GDI drawing functionality. I discovered GDI+ and this seems to be a big step forward, and appears to be standard available in Windows XP and Windows Server 2003. But since .NET also uses it, does that mean that it gets automatically installed when I install a .NET framework on a Windows 2000?
3
3173
by: Daniel | last post by:
hi , was just wondering if anyone could tell me how to use the gdi++ i cant seem to find out .. soz i know this is a very newb question but i have to ask it Regards , >> Daniel <<
2
1484
by: SStory | last post by:
Question #1) If I do Image.Save with the same filepath that I got the image from, it bombs with "A generic error occurred in GDI+" Any ideas? I prompt the user before overwriting, but if they want to do it, I would like to offer the ability. Question #2) I have my cropping working, using my own rubber banding selector widget, but I am wondering how to best allow them to hold SHIFT and maintain aspect ratio like Photoshop and others...
7
5976
by: Marcin Rzeznicki | last post by:
Hello, Do you think it is legitimate practice to mix GDI+ and GDI calls (via Get/ReleaseHDC()) in paint event of a control? I've heard there is possibility of performance loss while "locking" Graphics object which is done as a side-effect to GetHDC() call - could you confirm? Another question that comes to my mind when planning mentioned operation is: if the control painted on uses double-buffering style, will GDI calls make use of "back...
3
3654
by: Asfar | last post by:
Hi, Can some one tell me from where can I download the GDI+ SDK to use with VC6. Thanks, -Asfar
0
1277
by: Tao | last post by:
hi.. group, Is there a easy way (or a safe way, whatever you call it) to transfer a DirectX output to GDI image? For example: Somebody draws a rectangle using DirectX with C++. I need to implement this rectange with GDI using C#. Is there a way I can copy and paste some code from him? Maybe I can grab DirectX output and transform it to GDI.
2
3785
by: user | last post by:
Hi all... i am trying to print an image using GDI - but the only thing i get is a black rectangle. Does anybody know what is wrong, or how else to get the bitmap on the printer (GDI+ is not possible. it is a POS printer (for restaurants) and the printer internal fonts are a MUST for printing speed. as far as i know printer internal fonts are only accessable through GDI, so all my printing is GDI up to now)
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.