如何百叶窗显示图片

SpxImage1_thumb%5B1%5D.jpg

 

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
 
 
private void button2_Click(object sender, System.EventArgs e)
        {//水平百叶窗显示图像
            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);
            }            
        }
 
 
 
        private void button3_Click(object sender, System.EventArgs e)
        {//垂直百叶窗显示图像
            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);
            }            
        }
MyBitmap 是Bitmap类的对象
public sealed class Bitmap : System.Drawing.Image
    System.Drawing 的成员
 
 
摘要:
 封装 GDI+ 位图,此位图由图形图像及其属性的像素数据组成。System.Drawing.Bitmap 对象是用于处理由像素数据定义的图像的对象。  

public int Height [  get]
    System.Drawing.Image 的成员
 
摘要:
 获取此 System.Drawing.Image 对象的高度。  

 

public int Width [  get]
    System.Drawing.Image 的成员
 
摘要:
 获取此 System.Drawing.Image 对象的宽度。  

 

public System.Drawing.Graphics CreateGraphics (  )
    System.Windows.Forms.Control 的成员
 
摘要:
 为控件创建 System.Drawing.Graphics 对象。  
 
返回值:
 控件的 System.Drawing.Graphics 对象。  
 
 
 
public void Clear ( System.Drawing.Color color )
    System.Drawing.Graphics 的成员
 
摘要:
 清除整个绘图面并以指定背景色填充。  
 
参数:
color: System.Drawing.Color 结构,它表示绘图面的背景色。 
 
返回值:
 此方法不返回值。  

 

public void SetPixel ( System.Int32 x , System.Int32 y , System.Drawing.Color color )
    System.Drawing.Bitmap 的成员
 
摘要:
 设置 System.Drawing.Bitmap 对象中指定像素的颜色。  
 
参数:
x: 要设置的像素的 x 坐标。 
y: 要设置的像素的 y 坐标。 
color: System.Drawing.Color 结构,它表示要分配给指定像素的颜色。 
 
返回值:
 此方法不返回值。  

 

 

public static void Sleep ( System.TimeSpan timeout )
    System.Threading.Thread 的成员
 
摘要:
 将当前线程阻塞指定的时间。  
 
参数:
timeout: 设置为线程被阻塞的时间量的 System.TimeSpan。指定零以指示应挂起此线程以使其他等待线程能够执行。指定 System.Threading.Timeout.Infinite 以无限期阻塞线程。 
 
异常:
System.ArgumentOutOfRangeException: timeout 的值为负,而且不等于 System.Threading.Timeout.Infinite(以毫秒为单位),或者大于 System.Int32.MaxValue 毫秒。 

转载于:https://www.cnblogs.com/zbqy/archive/2007/02/18/652349.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值