百叶窗效果显示图片源码(c#)
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
顯示圖片:
this.pictureBox.Image = Image.FromFile("image.jpg", false);?
百葉窗有兩種顯示效果,一種是垂直百葉窗,另一種是水平百葉窗。
?
實(shí)現(xiàn)百葉窗顯示圖像有兩種方式:一是根據(jù)窗口或圖像 的高度或?qū)挾群投ㄖ频陌偃~窗顯示條寬度計(jì)算百葉窗的顯示的條數(shù)量;二是根據(jù)窗口或圖像的高度或?qū)挾群投ㄖ频陌偃~窗顯示條數(shù)量計(jì)算百葉窗的顯示的條寬度。
垂 直百葉窗實(shí)現(xiàn)代碼如下:
?
private void button1_Click(object sender, EventArgs e)
{
? //垂直百葉窗顯示圖像
? try
? {
? MyBitmap = (Bitmap)this.pictureBox1.Image.Clone();
? int dw = MyBitmap.Width / 30;
? int dh = MyBitmap.Height;
? Graphics g = this.pictureBox1.CreateGraphics();
? g.Clear(Color.Gray);
? Point[] MyPoint = new Point[30];
? for (int x = 0; x < 30; x++)
? {
? MyPoint[x].Y = 0;
? MyPoint[x].X = x * dw;
? }
? Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);
? for (int i = 0; i < dw; i++)
? {
? for (int j = 0; j < 30; j++)
? {
? for (int k = 0; k < dh; k++)
? {
? bitmap.SetPixel(MyPoint[j].X + i, MyPoint[j].Y + k, MyBitmap.GetPixel(MyPoint[j].X + i, MyPoint[j].Y + k));
? }
? }
? this.pictureBox1.Refresh();
? this.pictureBox1.Image = bitmap;
? System.Threading.Thread.Sleep(100);
? }
? }
? catch (Exception ex)
? {
? MessageBox.Show(ex.Message, "信息提示");
? }
}?
?
水平百葉窗實(shí)現(xiàn)代碼如下:
?
private void button3_Click(object sender, EventArgs e)
{
? //水平百葉窗顯示圖像
? try
? {
? MyBitmap = (Bitmap)this.pictureBox1.Image.Clone();
? int dh = MyBitmap.Height / 20;
? int dw = MyBitmap.Width;
? Graphics g = this.pictureBox1.CreateGraphics();
? g.Clear(Color.Gray);
? Point[] MyPoint = new Point[20];
? for (int y = 0; y < 20; y++)
? {
? MyPoint[y].X = 0;
? MyPoint[y].Y = y * dh;
? }
? Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);
? for (int i = 0; i < dh; i++)
? {
? for (int j = 0; j < 20; j++)
? {
? for (int k = 0; k < dw; k++)
? {
? bitmap.SetPixel(MyPoint[j].X + k, MyPoint[j].Y + i, MyBitmap.GetPixel(MyPoint[j].X + k, MyPoint[j].Y + i));
? }
? }
? this.pictureBox1.Refresh();
? this.pictureBox1.Image = bitmap;
? System.Threading.Thread.Sleep(100);
? }
? }
? catch (Exception ex)
? {
? MessageBox.Show(ex.Message, "信息提示");
? }
}?
轉(zhuǎn)載于:https://my.oschina.net/duluo180/blog/8130
總結(jié)
以上是生活随笔為你收集整理的百叶窗效果显示图片源码(c#)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: RHEL5下DNS配置详解3
- 下一篇: C#得到CPU的序列号、硬盘序列号、网卡