You can get a Graphics reference to the image by using the Graphics.FromImage() function. Then I would use the function in the
Graphics
class called
DrawEllipse[
^]. It has an overload that allows you to pass a
Pen
(i.e.
Pens.Red
) and a
Rectangle
. The rectangle will define the location and the size that identify where and how big to make the ellipse.
Graphics gfx = Graphics.FromImage ( tempImage );
gfx.DrawEllipse ( Pens.Red, new Rectangle ( tempPoint, tempSize ) );
[EDIT]
Here is a basic example of how to do it, it assumes that you have a form with a PictureBox on it. You will need to modify this to suit your needs, but this will help you understand what the process is:
public partial class Form1 : Form
{
Rectangle circle_bounds = new Rectangle ();
public Form1 ()
{
InitializeComponent ();
}
private void Form1_Load ( object sender, EventArgs e )
{
this.pictureBox1.Load ( @"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg" );
}
private void pictureBox1_MouseDown ( object sender, MouseEventArgs e )
{
this.circle_bounds.Location = e.Location;
}
private void pictureBox1_MouseUp ( object sender, MouseEventArgs e )
{
this.circle_bounds.Size = new Size ( e.X - this.circle_bounds.X, e.Y - this.circle_bounds.Y );
using ( Graphics gfx = Graphics.FromImage ( this.pictureBox1.Image ) )
{
gfx.DrawEllipse ( Pens.Red, this.circle_bounds );
this.pictureBox1.Refresh ();
}
}
}
[/EDIT]