首页 新闻 会员 周边

C# winform 如何实现图像在一定时间的滚动播放

0
悬赏园豆:10 [已解决问题] 解决于 2020-06-15 15:15

如题,我想用picturebox实现图像的3秒内滚动播放,开始使用的timer但播放过程中发现
跳转到文件夹时速度越来越快,有没有大佬实现过,问一下思路

张飞吃豆芽的主页 张飞吃豆芽 | 初学一级 | 园豆:177
提问于:2020-06-15 12:49
< >
分享
最佳答案
0

是不是你代码有问题, 是不是每次会重新创建timer, 造成多个timer 在运行。

收获园豆:10
Tom.汤 | 老鸟四级 |园豆:3028 | 2020-06-15 13:07

我关掉之后,每次图片都不刷新,固定为同一张

张飞吃豆芽 | 园豆:177 (初学一级) | 2020-06-15 13:08

@张飞吃豆芽: 你要自己检查下代码, 我说说没用的,具体问题要具体分析

Tom.汤 | 园豆:3028 (老鸟四级) | 2020-06-15 13:10

@Tom.汤: 这是我的相关代码
timer= new System.Timers.Timer();
timer.Interval = 1000/curFrameRate;
int j = 0;
timer.Elapsed += delegate
{
j++;
play_pics(tmpPicsPath, j);
};
timer.AutoReset = true;
timer.Start();
this.progress.Text = curVideoTime.ToString();

    }
    private void play_pics(List<string> tmpPicsPath,int j)
    {
        Image image = Image.FromFile(tmpPicsPath[j]);

        pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
        pictureBox1.Image = image;
        MessageBox.Show("j:" + j.ToString() + "count:" + tmpPicsPath.Count.ToString());
        // pictureBox1.Refresh();
        //  MessageBox.Show(tmpPicsPath[j]);
        if (j == tmpPicsPath.Count - 1)
        {
            j = 0;
            MessageBox.Show("begin"); // 该段代码也没执行
        }
张飞吃豆芽 | 园豆:177 (初学一级) | 2020-06-15 13:12

@张飞吃豆芽:
timer.AutoReset = true; 这里为什么是true, 如果是true 就只执行一次了啊?

Tom.汤 | 园豆:3028 (老鸟四级) | 2020-06-15 13:29

@Tom.汤: true为重复,false是一次

张飞吃豆芽 | 园豆:177 (初学一级) | 2020-06-15 14:00

已经解决了,是我从视频取图的问题,谢谢啦

张飞吃豆芽 | 园豆:177 (初学一级) | 2020-06-15 15:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册