如何在 .net 中将动画 gif 拆分为其组成部分?
具体来说,我想将它们加载到内存中的 Image(s) (System.Drawing.Image) 中。
=======================
根据 SLaks 的回答,我现在有了这个
public static IEnumerable<Bitmap> GetImages(Stream stream)
{
using (var gifImage = Image.FromStream(stream))
{
//gets the GUID
var dimension = new FrameDimension(gifImage.FrameDimensionsList[0]);
//total frames in the animation
var frameCount = gifImage.GetFrameCount(dimension);
for (var index = 0; index < frameCount; index++)
{
//find the frame
gifImage.SelectActiveFrame(dimension, index);
//return a copy of it
yield return (Bitmap) gifImage.Clone();
}
}
}