如何在.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();
}
}
}
Run Code Online (Sandbox Code Playgroud)