using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace advancedpictureviewer { public partial class Form1 : Form { Bitmap bitmap1; public Form1() { InitializeComponent(); } private void openToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); bitmap1 = (Bitmap)Bitmap.FromFile(openFileDialog1.FileName); pictureBox1.Image = bitmap1; fileSizeLabel.Text = openFileDialog1.FileName.Length.ToString(); } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if ( saveFileDialog1.ShowDialog() == DialogResult.OK ) { int width = Convert.ToInt32(pictureBox1.Image.Width); int height = Convert.ToInt32(pictureBox1.Image.Height); using (Bitmap bmp = new Bitmap(width, height)) { pictureBox1.DrawToBitmap( bmp, new Rectangle( 0,0, width, height ) ); bmp.Save( saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png ); } } } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void toolButton_FlipX_Click(object sender, EventArgs e) { bitmap1.RotateFlip(RotateFlipType.RotateNoneFlipX); pictureBox1.Image = bitmap1; } private void toolButton_FlipY_Click(object sender, EventArgs e) { bitmap1.RotateFlip(RotateFlipType.RotateNoneFlipY); pictureBox1.Image = bitmap1; } private void toolButton_RotY_Click(object sender, EventArgs e) { bitmap1.RotateFlip(RotateFlipType.Rotate90FlipNone); pictureBox1.Image = bitmap1; } private void toolButton_RotL_Click(object sender, EventArgs e) { bitmap1.RotateFlip(RotateFlipType.Rotate270FlipNone); pictureBox1.Image = bitmap1; } } }