电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

C实现显示图像的动态效果

C实现显示图像的动态效果_第1页
1/12
C实现显示图像的动态效果_第2页
2/12
C实现显示图像的动态效果_第3页
3/12
由于是以动画方式显示图像,这里没办法直接贴静态截图,因此决定给园友开源,将所有的可运行代码附在案例后面,由于所有的动画处理图像的对象放在都 pictureBox 控件中,同时定义的类都大同小异,因此这里先把下面案例中要用到的所有类及装载图像的代码给大家,运行时用这里的代码加下面任意一个实例的代码即可运行程序! private Bitmap SourceBitmap; private Bitmap MyBitmap; private void button2_Click(object sender, EventArgs e) { //打开图像文件 OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "图像文件(JPeg, Gif, Bmp, etc.) |*.jpg;*.jpeg;*.gif;*.bmp;*.tif; *.tiff; *.png| JPeg 图像文件(*.jpg;*.jpeg) |*.jpg;*.jpeg |GIF 图像文件(*.gif)|*.gif |BMP 图像文件(*.bmp)|*.bmp |Tiff 图像文件(*.tif;*.tiff)|*.tif;*.tiff|Png 图像 文件(*.png)| *.png |所有文件(*.*)|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) { //得到原始大小的图像 SourceBitmap = new Bitmap(openFileDialog.FileName); //得到缩放后的图像 MyBitmap = new Bitmap(SourceBitmap, this.pictureBox1.Width, this .pictureBox1.Height); this.pictureBox1.Image = MyBitmap; } } 一、以上下反转的方式显示图像. 原理:计算图像位置和高度后以高度的一半为轴进行对换上下半边的图像。 代码: private void button1_Click(object sender, EventArgs e) { try { int width = this.MyBitmap.Width; //图像宽度 int height = this.MyBitmap.Height; //图像高度 Graphics g = this.panel1.CreateGraphics(); g.Clear(Color.Gray); for (int i = -width / 2; i <= width / 2; i++) { g.Clear(Color.Gray); int j = Convert.ToInt32(i * (Convert.ToSingle(height) / Convert.ToS ingle(width))); Rectangle DestRect = new Rectangle(0, height / 2 -j, width, 2 * j); Rectangle SrcRect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height); g.DrawImage(MyBitmap, DestRect, SrcRect, GraphicsUnit.Pixel); System.Threading.Thread.Sleep(10); } } catch (Exception ex) { MessageBox.Show(ex.Message, "信息提示"); } } 二、以上下对接的...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

C实现显示图像的动态效果

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部