我正在创建一个 WinForm 应用程序,它用网络摄像头拍摄一个人的照片,现在正在尝试创建倒计时效果。我有 4 张图像想要循环浏览,但事实证明这很难完成。
我使用了秒计时器,但所发生的只是应用程序有点滞后,然后显示最后一张图像。有谁知道我如何实现这个目标?
这是我的代码:
int counter = 0;
// start the counter to swap the images
tmCountDown.Start();
while (counter < 4)
{
// holding off picture taking
}
// reset counter for timer
counter = 0;
tmCountDown.Stop();
/// <summary>
/// timer event to switch between the countdown images
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tmCountDown_Tick(object sender, EventArgs e)
{
counter++;
//MessageBox.Show("c:/vrfid/apppics/" + counter + ".jpg");
pbCountDown.Image = new Bitmap("c:/vrfid/apppics/" + counter + ".jpg");
}
你应该使用
counter++;
this.SuspendLayout();
pbCountDown.Image = new Bitmap("c:/vrfid/apppics/" + counter + ".jpg");
this.ResumeLayout();
我测试了一下,效果很好,希望对你有帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)