实现效果:
知识运用:
Bitmap类的GetPixel和SetPixel方法
实现代码:
private void button1_Click(object sender, EventArgs e) { int intWidth = this.BackgroundImage.Width; int intHeight = this.BackgroundImage.Height; Graphics myGraphics = this.CreateGraphics(); Bitmap myBitmap=(Bitmap)this.BackgroundImage.Clone(); Bitmap bitmap = new Bitmap(intWidth,intHeight); myGraphics.Clear(Color.WhiteSmoke); int i=0; while(i<=intWidth/2) { for (int m = 0; m <= intHeight-1; m++) { bitmap.SetPixel(i,m,myBitmap.GetPixel(i,m)); } for (int m = 0; m <=intHeight-1; m++) { bitmap.SetPixel(intWidth - i-1, m, myBitmap.GetPixel(intWidth - i-1, m)); } i++; this.Refresh(); this.BackgroundImage = bitmap; System.Threading.Thread.Sleep(10); } }