资源简介

在winform中播放gif动画图片;ImageAnimator的使用

资源截图

代码片段和文件信息

//显示gif图片
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WFApp_Flash
{
    public partial class gifFrm : Form
    {
        private Image m_img = null;
        private EventHandler evtHandler = null;
        public gifFrm()
        {
            InitializeComponent();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (m_img != null)
            {
                UpdateImage();//画下一帧
                e.Graphics.DrawImage(m_img new Rectangle(145 140 m_img.Width m_img.Height));
            }
        }

        private void gifFrm_Load(object sender EventArgs e)
        {
            evtHandler = new EventHandler(OnImageAnimate);
            string fileName = Application.StartupPath + “\\Image\\漏斗.gif“;
            if (System.IO.File.Exists(fileName) == true)
            {
                m_img = Image.FromFile(fileName);

                BeginAnimate();
            }
        }
        private void BeginAnimate()
        {
            if (m_img != null)
            {
                //当gif动画每隔一定时间后,都会变换一帧那么就会触发一事件,该方法就是将当前image每变换一帧时,都会调用当前这个委托所关联的方法。
                ImageAnimator.Animate(m_img evtHandler);
            }
        }
        private void OnImageAnimate(object sender EventArgs e)//初始化
        {
            this.Invalidate();
        }
        private void UpdateImage()
        {
            ImageAnimator.Updateframes(m_img);
        }
        private void StopAnimate()//停止动画        
        {
            m_img = null;
            ImageAnimator.StopAnimate(m_img evtHandler);
        }

        private void gifFrm_FormClosing(object sender FormClosingEventArgs e)
        {
            StopAnimate();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        875  2011-06-21 10:22  WFApp-gif\WFApp-Flash.sln

    ..A..H.     27648  2011-07-08 16:18  WFApp-gif\WFApp-Flash.suo

     文件        871  2011-07-08 16:11  WFApp-gif\说明.txt

     文件        493  2011-07-08 16:15  WFApp-gif\WFApp-Flash\Program.cs

     文件       5460  2011-07-08 16:16  WFApp-gif\WFApp-Flash\WFApp-Flash.csproj

     文件       2104  2011-07-08 16:18  WFApp-gif\WFApp-Flash\gifFrm.cs

     文件       1589  2011-06-21 12:40  WFApp-gif\WFApp-Flash\gifFrm.Designer.cs

     文件       5817  2011-06-21 12:40  WFApp-gif\WFApp-Flash\gifFrm.resx

     文件       6870  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件      17408  2011-06-21 10:30  WFApp-gif\WFApp-Flash\obj\x86\Debug\AxInterop.ShockwaveFlashobjects.dll

     文件        847  2011-06-24 16:50  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.Form1.resources

     文件        180  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.Properties.Resources.resources

     文件       1664  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\GenerateResource.read.1.tlog

     文件       6702  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       8704  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp-Flash.exe

     文件       3355  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp-Flash.csproj.FileListAbsolute.txt

     文件      44544  2011-06-21 10:57  WFApp-gif\WFApp-Flash\obj\x86\Debug\AxInterop.WMPLib.dll

     文件        737  2011-06-24 16:50  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.playerFrm.resources

     文件        180  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.gifFrm.resources

     文件      22016  2011-06-22 17:34  WFApp-gif\WFApp-Flash\obj\x86\Debug\Interop.ShockwaveFlashobjects.dll

     文件     262144  2011-06-22 17:34  WFApp-gif\WFApp-Flash\obj\x86\Debug\Interop.WMPLib.dll

     文件        843  2011-06-22 17:34  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp-Flash.csproj.ResolveComReference.cache

     文件        180  2011-06-24 16:50  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.loadingFrm.resources

     文件      15412  2011-06-24 16:50  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.pictureFrm.resources

     文件       4377  2011-06-24 16:50  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp_Flash.loadingFrom2.resources

     文件      58880  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\WFApp-Flash.pdb

     文件      24646  2011-07-08 16:12  WFApp-gif\WFApp-Flash\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件      11147  2011-07-08 16:16  WFApp-gif\WFApp-Flash\obj\x86\Debug\ResolveAssemblyReference.cache

     文件      11600  2011-07-08 16:11  WFApp-gif\WFApp-Flash\bin\Debug\WFApp-Flash.vshost.exe

     文件       8704  2011-07-08 16:16  WFApp-gif\WFApp-Flash\bin\Debug\WFApp-Flash.exe

............此处省略30个文件信息

评论

共有 条评论