如何获取FrameCount

本文关键字:FrameCount 获取 何获取 | 更新日期: 2023-09-27 18:23:59

我只是对代码的语法有点问题。这是我的代码

int frames = Properties.Resources.LOGODENTER.GetFrameCount(FrameDimension.Time);
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
       pictureBox1.Enabled = true;
        pictureBox1.Image = Properties.Resources.LOGODENTER;
        if (frames == 7)
        {
            pictureBox1.Enabled = false;
        }       
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
        pictureBox1.Enabled = true;
        pictureBox1.Image = Properties.Resources.LOGOLEAVE1;
        if (frames == 6)
        {
            pictureBox1.Enabled = false;
        }
}

基本上,我真正想发生的是,当我的指针进入控件picturebox1时,它会用GIF(LOGODENTER)更改其图像,当鼠标离开其区域时,它再次用GIF(LOGOLEAVE1)更改其图像。我了解imageAnimator.Animate/StopAnimate,但不知道如何使用它。但我想你也了解我的代码逻辑。

这是我关于阻止gif循环的第二篇文章。这是第一个System.Drawing.ImageAnimator.Animate和System.Drawing.ImageAnimator.StopAnimate解释

如何获取FrameCount

在我看来,你做得很好。我使用这个视频将图像添加到我的资源中,并使用了带有以下代码的pictureBox

private void InitializeComponent()
  {
     this.pictureBox1 = new System.Windows.Forms.PictureBox();
     this.pictureBox1.Location = new System.Drawing.Point(35, 28);
     this.pictureBox1.Name = "pictureBox1";
     this.pictureBox1.Size = new System.Drawing.Size(100, 50);
     this.pictureBox1.TabIndex = 0;
     this.pictureBox1.TabStop = false;
     this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
     this.pictureBox1.MouseEnter += new System.EventHandler(this.pictureBox1_MouseEnter);
     pictureBox1.Image = Properties.Resources.confirmation;
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
     pictureBox1.Image = Properties.Resources.error;
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
     pictureBox1.Image = Properties.Resources.confirmation;
}

它起到了的作用

让我知道是否有任何东西丢失