首页 > 其他 > 详细

gif显示

时间:2015-11-13 14:35:10      阅读:419      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!