Access GIF frames with C#

后端 未结 2 1989
再見小時候
再見小時候 2020-12-10 03:09

I\'m a beginner in C#. I would like to know if there\'s a way to access different frames inside a GIF animation with C#. I\'m using Visual Studio 2008.

2条回答
  •  孤城傲影
    2020-12-10 03:37

    Try this:

    using System.Drawing;    
    using System.Drawing.Imaging;
    
    Image gifImg = Image.FromFile(pathToGifFile);
    FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]);
    // Number of frames
    int frameCount = gifImg.GetFrameCount(dimension);
    // Return an Image at a certain index
    gifImg.SelectActiveFrame(dimension, index);
    

提交回复
热议问题