c# picturebox 刷新_c# – 更新PictureBox时可能导致ArgumentException的原因是什么?
我決定嘗試使用
AForge進行視頻和圖像處理,我試圖實現
this simple demo:
private void Main_Load(object sender, EventArgs e)
{
// enumerate video devices
FilterInfoCollection videoDevices = new FilterInfoCollection(
FilterCategory.VideoInputDevice);
// create video source
VideoCaptureDevice videoSource = new VideoCaptureDevice(
videoDevices[0].MonikerString);
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
// start the video source
videoSource.Start();
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
this.pictureBox1.Image = eventArgs.Frame;
}
問題是我總是得到一個ArgumentException,雖然并不總是立即發生.它彈出Application.Run(new Main());,但堆棧跟蹤的頂部如下所示:
>在System.Drawing.Image.get_Size_Size()的System.Drawing.Image.get_Width()處
>在System.Windows.Forms.PictureBox.ImageRectangleFromSizeMode(PictureBoxSizeMode模式)
>在System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
不確定這是否相關,但異常的ParamName屬性為null.我試過在try … catch塊中包裝圖像賦值,但這沒有幫助.我還檢查過以確保圖像在分配之前不為空.我還檢查了非null,但是0x0大小的圖像.
我做錯了什么?任何人都可以建議解決方法?
總結
以上是生活随笔為你收集整理的c# picturebox 刷新_c# – 更新PictureBox时可能导致ArgumentException的原因是什么?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: radio单选框操作
- 下一篇: Dubbo服务暴露流程