C++/CLI Windows 将 gif 格式转换为图像

C++/CLI Windows Form change gif then to image

代码很简单。按下按钮后,将当前图像更改为gif,然后更改为gif之后的图像。

目标是播放gif,然后切换到jpg。从一开始,这是行不通的。我尝试过不同的计时技术,例如使用 Sleep()、for 循环以及两者的混合。这不是这根本没有给 gif 播放时间。图像仍然是主要图像,延迟多长时间并跳转到 jpg。

按下按钮后如何按指定的顺序更改图像,甚至是 gif,每个图像之间有指定的延迟时间?

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                pictureBox1->Load("gif");
                pictureBox1->Load("jpg");
             }

试试这个

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
         {
            pictureBox1->Load("gif");
            Timer->Enabled=true;
         }

private: System::Void Timer_tick(System::Object^  sender, System::EventArgs^  e) 
         {
           pictureBox1->Load("jpg");
         }

感谢发帖的 Michail 的帮助,我找到了解决问题的方法。表格在 pictureBox1 中有一个预先确定的 jpg。此代码允许 gif 在 pictureBox1 中播放一段确定的时间。一旦达到该时间,它将 pictureBox1 中的图像更改为与以前不同的 jpg。如果找到一种方法来应用此方法,则此方法也可以用作定时加载屏幕。希望这对以后的人有帮助。

    #pragma endregion

        public:
            static int second = 0;

        private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
        {
            if(second != 42)
            {
                second++;
            }
            if(second >= 42)
            {
                pictureBox1->Load(".jpg");
                timer1->Enabled=false;
            }
        }

        private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            pictureBox1->Load(".gif");
            timer1->Enabled=true;
        }