基本信息
源码名称:c# winform 播放gif图片实例(可暂停播放) 附完整源码
源码大小:1.28M
文件格式:.zip
开发语言:C#
更新时间:2013-04-28
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
一个播放gif图片的实例,如图
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PlayGifAnimation
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
Bitmap bitmap = new Bitmap(Application.StartupPath "\\1.gif"); //实例化一个GDI 绘图图面对象
bool current = false; //初始化一个bool型的变量current
public void PlayImage()
{
if (!current) //当该值为true时
{
ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged)); //将多帧图片显示为动画图像
current = true; //设定current的值为true
}
}
private void OnFrameChanged(object o, EventArgs e)
{
this.Invalidate(); //使控件的整个图片无效并导致重绘事件
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(this.bitmap, new Point(1, 1)); //从指定的位置绘制图片
ImageAnimator.UpdateFrames(); //使该帧在当前正被图画处理的所有图像中前移
}
private void button1_Click(object sender, EventArgs e)
{
PlayImage(); //播放
ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged)); //将多帧图像显示为动画
}
private void button2_Click(object sender, EventArgs e)
{
ImageAnimator.StopAnimate(bitmap, new EventHandler(this.OnFrameChanged)); //停止
}
}
}