首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >C# 获取GIF帧率-每张图像的时间间隔

C# 获取GIF帧率-每张图像的时间间隔

作者头像
云未归来
发布2025-07-18 12:27:31
发布2025-07-18 12:27:31
350
举报

public int GetDelay(string sfile)         {             Image img = Image.FromFile("D:\\000.gif");//加载Gif图片             FrameDimension dim = new FrameDimension(img.FrameDimensionsList[0]);             int framcount = img.GetFrameCount(dim);             if (framcount <= 1)                 return 0;             else             {                 int delay = 0;                 bool stop = false;                 for (int i = 0; i < framcount; i++)//遍历图像帧                 {                     if (stop == true)                         break;                     img.SelectActiveFrame(dim, i);//激活当前帧                     for (int j = 0; j < img.PropertyIdList.Length; j++)//遍历帧属性                     {                         if ((int)img.PropertyIdList.GetValue(j) == 0x5100)//如果是延迟时间                         {                             PropertyItem pItem = (PropertyItem)img.PropertyItems.GetValue(j);//获取延迟时间属性                             byte[] delayByte = new byte[4];//延迟时间,以1/100秒为单位                             delayByte[0] = pItem.Value[i * 4];                             delayByte[1] = pItem.Value[1 + i * 4];                             delayByte[2] = pItem.Value[2 + i * 4];                             delayByte[3] = pItem.Value[3 + i * 4];                             delay = BitConverter.ToInt32(delayByte, 0) * 10; //乘以10,获取到毫秒                             stop = true;                             break;                         }                     }                 }                 return delay;             }         }

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-02-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档