【问题标题】:How to getFrameCount如何获取帧数
【发布时间】:2013-07-19 19:26:31
【问题描述】:

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

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 and System.Drawing.ImageAnimator.StopAnimate explanation

【问题讨论】:

    标签: c# winforms gif


    【解决方案1】:

    在我看来,你做得很好。 我使用this 视频将图像添加到我的资源中,并使用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;
    }
    

    成功了

    如果有什么遗漏请告诉我

    【讨论】:

      猜你喜欢
      • 2012-08-17
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 1970-01-01
      • 2012-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多