hi all
i need a function to draw circle in a pictuerBox
Draw circle
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
AlanRank #669 · 3.6K reputationPosted Jun 18, 2007, 6:04 AM EDT
Bitmap
bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); Pen blackPen = new Pen(Color.Black);int
x = pictureBox1.Width/4; int y = pictureBox1.Height/4; int width = pictureBox1.Width / 2; int height = pictureBox1.Height / 2; int diameter = Math.Min(width, height);g.DrawEllipse(blackPen, x, y, diameter, diameter);
pictureBox1.Image = bmp;
If the PictureBox already contains a bitmap, replace the first and second lines with:Graphics g = Graphics.FromImage(pictureBox1.Image);
Essam Ali21 reputationPosted Jun 18, 2007, 7:19 AM EDT
Mahesh ChandRank #1 · 393.3K reputationPosted Jun 18, 2007, 8:14 AM EDT
This is Mahesh from C# Corner. Can you contact me when you get a chance through this site by selecting Contact Author on my author profile page here:
http://www.c-sharpcorner.com/Authors/AuthorDetails.aspx?AuthorID=mahesh
Thanks,
Mahesh
Mahesh ChandRank #1 · 393.3K reputationPosted Jun 19, 2007, 5:07 AM EDT
Check your online email account from which you contacted me.
Best,
Mahesh