Rounded corner button

R

RahulH

Hi,
I am a novice to System.Drawing namespace. I want to create a web custom
button control with rounded images.
I can create rounded corners, and image of text. but is there a way that i
can now join these images into a single image.
Thanks in advance,
RahulH
 
P

Phillip Williams

Hi RahulH,

To get a corner button you might draw a polygon on the graphics object of
your bitmap as this:

//create a graphics object from the bitmap
Graphics g= Graphics.FromImage (bitmap);
//paint the background as specified by the user or else paint it as the
default
g.Clear (bgColor);
//add border to mark a button shape
Point[] poly = {new Point(10, 3), new Point(bitmapWidth-10, 3), new
Point(bitmapWidth-5, 5),
new Point(bitmapWidth-3, 10), new Point(bitmapWidth-3, bitmapHeight-10),
new Point(bitmapWidth-5, bitmapHeight-5), new Point(bitmapWidth-10,
bitmapHeight-3),
new Point(10, bitmapHeight-3), new Point(5, bitmapHeight-5),
new Point(3, bitmapHeight-10), new Point(3, 10),
new Point(5, 5), new Point(10, 3)};
g.FillPolygon (new SolidBrush (buttonBGColor), poly);

As for placing the text and the polygon on the same bitmap, you may review
demo#2 from my website: http://www.societopia.net/Samples/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top