基本信息
源码名称:winform 垂直交错效果显示图像 例子
源码大小:0.04M
文件格式:.zip
开发语言:C#
更新时间:2013-06-01
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



 

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;

namespace UprightnessInterleaving
{
    public partial class Frm_Main : Form
    {
        Bitmap myBitmap;
        public Frm_Main()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp|*.jpg;*.jpeg;*.bmp";			//设置文件的类型
            openFileDialog1.ShowDialog(); 									//打开文件对话框
            Image myImage = System.Drawing.Image.FromFile(openFileDialog1.FileName); 	//根据文件的路径实例化Image类
            myBitmap = new Bitmap(myImage);	 							//实例化Bitmap类
            this.BackgroundImage = myBitmap; 								//显示打开的图片
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                int intWidth = this.BackgroundImage.Width;						//获取背景片的宽度
                int intHeight = this.BackgroundImage.Height;					//获取背景片的高度
                Graphics myGraphics = this.CreateGraphics(); 					//创建窗体的Graphics类
                myGraphics.Clear(Color.WhiteSmoke); 							//以指定的颜色清除
                Bitmap bitmap = new Bitmap(intWidth, intHeight); 					//实例化Bitmap类
                int i = 0;
                //通过调用Bitmap对象的SetPixel方法实现垂直交错效果显示图像
                while (i <= intHeight / 2)
                {
                    for (int m = 0; m <= intWidth - 1; m  )
                    {
                        bitmap.SetPixel(m, i, myBitmap.GetPixel(m, i));				//设置当前象素的颜色值
                    }
                    for (int n = 0; n <= intWidth - 1; n  )
                    {
                        bitmap.SetPixel(n, intHeight - i - 1, myBitmap.GetPixel(n, intHeight - i - 1)); //设置当前象素的颜色值
                    }
                    i  ;
                    this.Refresh();										//工作区无效
                    this.BackgroundImage = bitmap; 							//显示垂直交错的图片
                    System.Threading.Thread.Sleep(10);							//线程挂起
                }
            }
            catch { }
        }
    }
}