Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Directshow.net未在视频上显示覆盖图像_C#_Overlay_Video Capture_Directshow_Directshow.net - Fatal编程技术网

C# Directshow.net未在视频上显示覆盖图像

C# Directshow.net未在视频上显示覆盖图像,c#,overlay,video-capture,directshow,directshow.net,C#,Overlay,Video Capture,Directshow,Directshow.net,在我的Directshow.net应用程序中,我使用BufferCB在每个帧上绘制时间戳。时间戳显示在屏幕上和快照中,但在写入AVI文件时不会显示。 我错过了什么 int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen) { int stride = 0; int scan0 = 0; Bitmap FrameShot = null; GCHandle handl

在我的Directshow.net应用程序中,我使用BufferCB在每个帧上绘制时间戳。时间戳显示在屏幕上和快照中,但在写入AVI文件时不会显示。 我错过了什么

int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen) {
    int stride = 0;
    int scan0 = 0;
    Bitmap FrameShot = null;
    GCHandle handle;

    // Draw Time Stamp
    if (overlayBitmap != null & overlayEnabled) {
        // Create image to draw on camera frame shot
        Graphics g = Graphics.FromImage(overlayBitmap);
        g.Clear(Color.Transparent);
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.TextRenderingHint = TextRenderingHint.AntiAlias;
        DateTime now = DateTime.Now;
        string format = "M/d/yyy HH:mm:ss.fff";
        g.DrawString(now.ToString(format), fontOverlay, textYellow, 4, SnapShotHeight - FontSize * 2);

        // Draw image on camera frame shot
        stride = SnapShotWidth * 3;
        FrameShot = new Bitmap(SnapShotWidth, SnapShotHeight, stride, PixelFormat.Format24bppRgb, pBuffer);
        Graphics g2 = Graphics.FromImage(FrameShot);
        g2.SmoothingMode = SmoothingMode.AntiAlias;
        overlayBitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
        g2.DrawImage(overlayBitmap, 0, 0, overlayBitmap.Width, overlayBitmap.Height);

        g.Dispose();
        g2.Dispose();
        FrameShot.Dispose();
    }
    //Has a snapshot been requested?
    if (frameCaptured) {
        return 0;
    }
    frameCaptured = true;
    bufferedSize = BufferLen;

    stride = SnapShotWidth * 3;
    Marshal.Copy(pBuffer, savedArray, 0, BufferLen);

    handle = GCHandle.Alloc(savedArray, GCHandleType.Pinned);
    scan0 = (int)handle.AddrOfPinnedObject();
    scan0 += (SnapShotHeight - 1) * stride;
    FrameShot = new Bitmap(SnapShotWidth, SnapShotHeight, -stride, PixelFormat.Format24bppRgb, (IntPtr)scan0);
    handle.Free();

    // Return bitmap by an event
    FrameEvent2(FrameShot);
    return 0;
   }

使用
BufferCB
您拥有一份数据副本,您所做的更改会对进一步的数据流产生影响
SampleCB
相反,它会公开实际数据,并允许您在进一步发送之前更改有效负载。

感谢您的快速响应,我不知道BufferCB和SampleCB之间的区别。不幸的是,这并没有解决问题。在进一步检查后,我注意到文本显示在几个框架上,但太少了,似乎没有框架显示它。如有任何进一步建议,将不胜感激。