Here's how you do it:

1) Create a new winform c# project.
2) Drag a Button and a Picturebox from your Toolbox then drop those
controls on your form.
    Set aside enough space for your picturebox.
3) Double-click on your Button control and type this line:

   private button1_Click(object sender, EventArgs e)
   {
        markImage(0,0);     // the only line to type.
   }


4) On your pictureBox Mouse click event, type this line:

    private void pictureBox1_MouseClick(object sender, MouseEventArgs
e)
    {
          markImage(e.X, e.Y);  // the only line to type.
    }


Now type the definition of the markImage() routine like so:


        private void markImage(int x, int y)
        {
            Bitmap myBitmap = new Bitmap("sample.jpg");
            Graphics g = Graphics.FromImage(myBitmap);

            g.TextRenderingHint =
System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.DrawString("X", new Font("Tahoma", 20), Brushes.Red, new
PointF(x, y));

            pictureBox1.Image = myBitmap;
        }


g.DrawString() places an red "X" at the point where you click a region
in the image
with your mouse as indicated in your parameters (x and y).



Cheers!



Benj











On Mar 31, 6:43 pm, Clyde Smith <[email protected]> wrote:
> Hi There
>
> I have an image that the user browse and select. Once this image has been
> selected I want to display the image and the user clicks on the location on
> the image and where it was clicked I must place an x there. How can I do
> this is C#
>
> Thx
> Clyde
>
> --
> ----------------------------------------
> Kamnandi Web Hostinghttp://www.kamnandi.co.za
> -------------------------------------------

Reply via email to