How do you split an animated gif into its component parts in .net?
Specifically I want to load them into Image(s) (System.Drawing.Image) in memory.
======================
Based on SLaks' answer i now have this
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();
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…