日期:2014-05-19  浏览次数:20980 次

c# 怎么将gif动画放到imagelist里面呀?
我不想在硬盘上单独存储每张图片。

如果就一个gif图片,能把它的每一帧分开,然后放到一个imagelist里面吗?

------解决方案--------------------
mark
------解决方案--------------------
/// <summary>
/// Class that contains an animated gif image.
/// </summary>
public class AnimatedGif
{
// fields
Image _img;
FrameDimension _dim;
int _frameCount;
int _frameIndex;

// ctor
public AnimatedGif(Image img)
{
_img = img;
if (img != null)
{
_dim = new FrameDimension(img.FrameDimensionsList[0]);
_frameCount = img.GetFrameCount(_dim);
}
}

// expose contained image
public Image Image
{
get { return _img; }
}

// determines whether image is animated
public bool IsAnimated
{
get { return _frameCount > 1; }
}

// move to next frame
public void NextFrame()
{
if (_frameCount > 1)
{
_frameIndex = (_frameIndex + 1) % _frameCount;
_img.SelectActiveFrame(_dim, _frameIndex);
}
}
}

------解决方案--------------------
观注