How do I edit an image in VS 2003?

I need to open and edit a JPG file, but don't know how.

Can anybody please explain?

Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Please define what you mean by "edit"...

You can open an image and modify it using the Graphics class using code like the below:

            String fileName = @"c:\someFile.jpg";

            // open the image and create a copy
            // so that we can release the file lock
            // on the original image
            Image img = Image.FromFile(fileName);
            Bitmap bmp = new Bitmap(img);

            // get a graphics so we can draw
            Graphics g = Graphics.FromImage(bmp);

            // do something with "g"
            g.DrawString("Hello World!", this.Font, Brushes.Black, new PointF(0, 0));

            // release the graphics

            // save the changes in the original fileName
            bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
ba272Author Commented:
Thanks. But I'm having a hard time finding the necessary using statements to include.  Have you got them handy?
ba272Author Commented:

I initially wanted to simply open the image editor in VS 2003, but upon seeing your code, decided to try it and see if I could edit these files programatically.  

I have it working now.  

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.