1

我使用了这个控件,但它不支持 GIF 文件格式,因为图片不会像PictureBox.

4

1 回答 1

0

尝试使用简单的事件Bitmap.MakeTransparent和事件:ImageAnimator.UpdateFramesOnPaintPictureBox

private Image animGif;// gif animation file

private void Form1_Load(object sender, EventArgs e)
{
    animGif = new Bitmap("file.png");
    ImageAnimator.Animate(animGif, Animate);
}

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
    ImageAnimator.UpdateFrames();
    var img = new Bitmap(animGif, animGif.Width, animGif.Height);
    img.MakeTransparent(Color.White);
    e.Graphics.Clear(pictureBox1.BackColor);
    e.Graphics.DrawImage(img, new Point(0, 0));
}

private void Animate(object sender, EventArgs e)
{
    pictureBox1.Invalidate();
}
于 2012-08-13T10:32:02.430 回答