• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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?

Thanks.
0
ba272
Asked:
ba272
  • 2
1 Solution
 
Mike TomlinsonMiddle 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);
            img.Dispose();

            // 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
            g.Dispose();

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

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.  

Thanks,
Bob
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now