C#DirectShow.Net中心带背景的视频

C#DirectShow.Net中心带背景的视频,c#,directshow,directshow.net,C#,Directshow,Directshow.net,我正在使用DirectShow.NET以C#形式在控件中显示视频。当窗体变大/变小时,我需要视频来填充控件,因此控件变大/变小(MainForm_ResizeMove的if分支处理此问题)。如果设置了属性,我还需要保持源视频大小。MainForm_ResizeMove的else部分中的代码处理此问题。我的问题是,当else部分将我的视频放置在以控件为中心的正确位置时,背景是灰色的。由于我已将视频位置设置为视频的大小,因此不会应用边框颜色(因为在这种情况下没有边框)。有人能告诉我最好的解决方案是什

我正在使用DirectShow.NET以C#形式在控件中显示视频。当窗体变大/变小时,我需要视频来填充控件,因此控件变大/变小(MainForm_ResizeMove的if分支处理此问题)。如果设置了属性,我还需要保持源视频大小。MainForm_ResizeMove的else部分中的代码处理此问题。我的问题是,当else部分将我的视频放置在以控件为中心的正确位置时,背景是灰色的。由于我已将视频位置设置为视频的大小,因此不会应用边框颜色(因为在这种情况下没有边框)。有人能告诉我最好的解决方案是什么吗

private IVMRWindowlessControl9 windowlessCtrl = null;

...
private void MainForm_Paint(object sender, PaintEventArgs e)
    {           
        if (windowlessCtrl != null)
        {
            IntPtr hdc = e.Graphics.GetHdc();
            int hr = windowlessCtrl.SetBorderColor(0x00FFFFFF);
            hr = windowlessCtrl.RepaintVideo(this.Handle, hdc);
            e.Graphics.ReleaseHdc(hdc);
        }
    }

    private void MainForm_ResizeMove(object sender, EventArgs e)
    {
        if (windowlessCtrl != null)
        {
            if (fillScreen || (this.ClientRectangle.Width < streamFrameWidth) || (this.ClientRectangle.Height < streamFrameHeight))
            {
                int hr = windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.ClientRectangle));
            }
            else
            {
                Rectangle rect = new Rectangle((this.ClientRectangle.Width / 2) - (streamFrameWidth / 2), 
                                               (this.ClientRectangle.Height/ 2) - (streamFrameHeight / 2), 
                                                streamFrameWidth, streamFrameHeight);
                int hr = windowlessCtrl.SetVideoPosition(null, rect);  
            } 
        }
    }
private IVMRWindowLessControl 9 windowlessCtrl=null;
...
私有void MainForm_Paint(对象发送器,PaintEventArgs e)
{           
if(windowlessCtrl!=null)
{
IntPtr hdc=e.Graphics.GetHdc();
int hr=windowlessCtrl.SetBorderColor(0x00FFFFFF);
hr=windowlessCtrl.repainvideo(this.Handle,hdc);
e、 图形发布hdc(hdc);
}
}
private void MainForm_ResizeMove(对象发送方,事件参数e)
{
if(windowlessCtrl!=null)
{
if(fillScreen | | |(this.ClientRectangle.Width
事实上很简单,将控件的背景颜色设置为黑色