I have a program for image segmentation in WinForms Application C#, and I have an image loaded in a pictureBox. I need to draw a small circle(or an ellipse, it does not matter) on that image (inside a region of interest, and allowing it to grow outwards until it reaches the desired boundary).
And the question is how can I draw that circle anywhere on that image? (and if it`s possible to draw that circle in a different color, red for example)
Thank you.
Sure take the graphic instance of the control anddraw on it . It will be reflected only when its repainted or Invalidated. Use DrawEllipse Method of Graphic Class to draw circle.
here is the code:
Graphics gf = picturebox1.CreateGraphics();
//A circle with Red Color and 2 Pixel wide line
gf.DrawEllipse(new Pen(Color.Red, 2),new Rectangle(0, 0, 200, 200));
Invalidate it to actually draw it on the control (picturebox)
picturebox1.Invalidate();
It will draw a circle 200 pixel in diameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With