1、1图像的百叶窗效果(程序在最后)23using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace 图像的百叶窗特效public partial class Form1 : Formpublic Form1()InitializeComponent();Bitmap MyBitmap;private void button1_
2、Click(object sender, EventArgs e)this.openFileDialog1.ShowDialog();if (this.openFileDialog1.FileName.Trim() = “)return;try/得到原始图像Bitmap SrcBitmap = new Bitmap(this.openFileDialog1.FileName);/得到缩放后的图像MyBitmap = new Bitmap(SrcBitmap, this.pictureBox1.Width, this.pictureBox1.Height);this.pictureBox1.Im
3、age = MyBitmap;catch (Exception Err)MessageBox.Show(this, “打开图像任务出错!“, “信息提示“, MessageBoxButtons.OK, MessageBoxIcon.Information);private void button2_Click(object sender, EventArgs e) /水平百叶窗MyBitmap = (Bitmap)this.pictureBox1.Image.Clone();int dh = MyBitmap.Height / 20;int dw = MyBitmap.Width;4Graph
4、ics g = this.pictureBox1.CreateGraphics();g.Clear(Color.Gray);Point mypoimt = new Point20;for (int y = 0; y 20; y+)mypoimty.X = 0;mypoimty.Y = y * dh;Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);for (int i=0;idh ;i+)for (int j=0;j20;j+)for (int k=0;kdw ;k+)bitmap .SetPixel (mypoimt j
5、.X +k,mypoimt j.Y +i ,MyBitmap .GetPixel (mypoimt j.X +k,mypoimt j.Y +i );this .pictureBox1 .Refresh ();this .pictureBox1 .Image =bitmap ;System .Threading .Thread .Sleep (200);private void button4_Click(object sender, EventArgs e)this.Close();private void button3_Click(object sender, EventArgs e) /
6、垂直百叶窗MyBitmap = (Bitmap)this.pictureBox1.Image.Clone();int dh = MyBitmap.Height ;int dw = MyBitmap.Width/30;Graphics g = this.pictureBox1.CreateGraphics();g.Clear(Color.Gray);Point mypoimt = new Point30;for (int x = 0; x 30; x+)5mypoimtx.Y = 0;mypoimtx.X = x*dw;Bitmap bitmap = new Bitmap(MyBitmap.Wi
7、dth, MyBitmap.Height);for (int i=0;idw ;i+)for (int j=0;j30;j+)for (int k=0;kdh ;k+)bitmap .SetPixel (mypoimt j .X +i,mypoimt j.Y +k ,MyBitmap .GetPixel (mypoimt j.X +i, mypoimt j.Y +k);this .pictureBox1 .Refresh ();this .pictureBox1 .Image =bitmap ;System .Threading .Thread .Sleep (10);private void pictureBox1_Click(object sender, EventArgs e)