using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Ex13_28
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Bitmap MyBitmap;
private void button2_Click(object sender, EventArgs e)
{
//
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = " (JPeg, Gif, Bmp, etc.)|*.jpg;*.jpeg;*.gif;*.bmp;*.tif; *.tiff; *.png| JPeg (*.jpg;*.jpeg)|*.jpg;*.jpeg |GIF (*.gif)|*.gif |BMP (*.bmp)|*.bmp|Tiff (*.tif;*.tiff)|*.tif;*.tiff|Png (*.png)| *.png | (*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//
Bitmap SourceBitmap = new Bitmap(openFileDialog.FileName);
//
MyBitmap = new Bitmap(SourceBitmap, this.pictureBox1.Width, this.pictureBox1.Height);
this.pictureBox1.Image = MyBitmap;
}
}
private void button1_Click(object sender, EventArgs e)
{
//
try
{
int width = this.pictureBox1.Width; //
int height = this.pictureBox1.Height; //
Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Gray); //
Bitmap bitmap = new Bitmap(width, height);
int x = 0;
while (x <= height / 2)
{
for (int i = 0; i <= width - 1; i++)
{
bitmap.SetPixel(i, x, MyBitmap.GetPixel(i, x));
}
for (int i = 0; i <= width - 1; i++)
{
bitmap.SetPixel(i, height - x - 1, MyBitmap.GetPixel(i, height - x - 1));
}
x++;
this.panel1.Refresh();
g.DrawImage (bitmap,0,0);
System.Threading.Thread.Sleep(10);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, " ");
}
}
}
}