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_26
{
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.MyBitmap.Width; //
int height = this.MyBitmap.Height; //
Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Gray); //
for (int x = 1; x <= width; x++)
{
Bitmap bitmap=MyBitmap.Clone (new Rectangle(0,0,x ,height),System.Drawing .Imaging.PixelFormat .Format24bppRgb );
g.DrawImage (bitmap,0,0);
System.Threading.Thread.Sleep(10);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, " ");
}
}
}
}