This is a tutorial on how to make a program that opens and allows you to view pictures! You will need to start by creating a new c# windows forms application. On the form, add 4 buttons, 1 openfiledialog, 1 savefiledialog, and 1 picture box. Double-click the form and make sure that your program is using System.Drawing.Imaging. Name the first button, 'Open Picture File', name the second button, 'Save Image', name the third button, 'Rotate Clockwise', and name the final button, 'Rotate Counter Clockwise'. Double-click the 'Open Picture File' and add this code:

Spoiler:
Code:
DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                Image img = Image.FromFile(openFileDialog1.FileName);
                pictureBox1.Image = img;
                pictureBox1.Width = img.Width;
                pictureBox1.Height = img.Height;
            }
            button2.Enabled = true;


            button3.Enabled = true;


            button4.Enabled = true;
            MessageBox.Show("Picture loaded!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Now, double-click the 'Save Image' button and add this code:

Spoiler:
Code:
DialogResult svd = saveFileDialog1.ShowDialog();

            if (svd == DialogResult.OK)
            {
                string ext = System.IO.Path.GetExtension(saveFileDialog1.FileName);
                ext = ext.ToLower();
                saveImage(ext);
                MessageBox.Show("Picture saved!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Now, double-click the 'Rotate Clockwise' button and add this code:

Spoiler:
Code:
rotateImage(1);
Finally, double-click the 'Rotate Counter Clockwise' button and add this code:

Spoiler:
Code:
rotateImage(0);


Now, you will notice that you are getting some errors so you need to call some new voids.

SaveImage void
Spoiler:
Code:
private void saveImage(string ext)        {
            ImageFormat format = null;
            if (ext == ".gif")
                format = ImageFormat.Gif;
            else if (ext == ".jpg" || ext == ".jpeg")
                format = ImageFormat.Jpeg;
            else if (ext == "png")
                format = ImageFormat.Png;
            else if (ext == ".bmp")
                format = ImageFormat.Bmp;


            pictureBox1.Image.Save(saveFileDialog1.FileName, format);
        }


Rotate image void
Spoiler:
Code:
 private void rotateImage(int angle)        {
            Bitmap img = new Bitmap(pictureBox1.Image);
            if (angle == 0)
                img.RotateFlip(RotateFlipType.Rotate90FlipNone);
            else if (angle == 1)
                img.RotateFlip(RotateFlipType.Rotate90FlipXY);


            pictureBox1.Size = img.Size;
            pictureBox1.Image = img;
        }


Well, it looks like you are done! You can now debug your application and test the cool functions out.