码迷,mamicode.com
首页 > 其他好文 > 详细

gif显示

时间:2015-11-13 14:37:04      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:

public void gifplay(string path,ref Panel panel)
        {
            try{
            Bitmap animatedGif = new Bitmap(path );
            Graphics g = panel.CreateGraphics();
            int PropertyTagFrameDelay = 0x5100;
            PropertyItem propItem = animatedGif.GetPropertyItem(PropertyTagFrameDelay);
            byte[] bytes = propItem.Value;
            FrameDimension frameDimension = new FrameDimension(animatedGif.FrameDimensionsList[0]);
            int frameCount = animatedGif.GetFrameCount(FrameDimension.Time);
            int[] delays = new int[frameCount + 1];
            int i = 0;
            for (i = 0; i <= frameCount - 1; i++)
            {delays[i] = BitConverter.ToInt32(bytes, i * 4);}
            while (true)
            {for (i = 0; i <= animatedGif.GetFrameCount(frameDimension) - 1; i++){
                    animatedGif.SelectActiveFrame(frameDimension, i);
                    g.DrawImage(animatedGif, new Point(0, 0));
                    Application.DoEvents();
                    Thread.Sleep(delays[i] * 10);}
            }}
            catch {return;}
        }

 

gif显示

标签:

原文地址:http://www.cnblogs.com/CJSTONE/p/4961949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!