C#获取gif帧数
C#获取gif帧数
/// <summary> /// 获取gif帧数 /// </summary> /// <param name="gifBytes"></param> /// <returns></returns> public static int GetGifFrameNum(string etc, byte[] gifBytes) { try { if (etc == ".gif") { MemoryStream ms = new MemoryStream(gifBytes); Image gif = Image.FromStream(ms); FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]); int count = gif.GetFrameCount(fd); ms.Dispose(); gif.Dispose(); return count; } else { return 1; } } catch (Exception ex) { LogHelper.WriteLog(ex); return 0; } }
博客内容仅代表个人观点,如发现阐述有误,麻烦指正,谢谢!