IVideoWindow界面不会在UserControl中正确显示视频帧

时间:2012-05-03 09:12:45

标签: directshow directshow.net

我正在使用DirectShow.NET库[http://directshownet.sourceforge.net/],我使用下面的代码来显示视频流。

videowindow.put_Owner(handle);
videowindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);
videowindow.put_WindowState(DirectShowLib.WindowState.Show);

注意:句柄是System.Windows.Forms.UserControl句柄[this-> Handle]

问题是:

  • 在我的用户控件中,视频帧显示不正确:我看到了一半 视频帧和另一半是屏幕外。
  • 此外,当我扩展用户控件时,视频流帧也不是 缩放。

这可能是什么原因造成的?我该如何解决?

更新

根据罗马答案,我添加了以下代码:

videoWindow.SetWindowPosition(this.ClientRectangle.Left,
                this.ClientRectangle.Top,
                this.ClientRectangle.Width,
                this.ClientRectangle.Height);

现在我能够正确地在用户控制矩形中看到视频帧....

1 个答案:

答案 0 :(得分:1)

除了将视频渲染器的窗口作为子控件并提供窗口类型之外,您还应该设置IVideoWindow.SetWindowPosition。当窗口布局发生变化时,您还有责任更新它。

相关问题