0
使用directshow.net我可以能够录制视频和记录我在做文本覆盖为了这个,我配置的样本采集和buffercb方法我工作的框架这里是代码..文字叠加问题?
int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)
{
Graphics g;
String s;
float sLeft;
float sTop;
SizeF d;
g = Graphics.FromImage(bitmapOverlay);
g.Clear(System.Drawing.Color.Transparent);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// Prepare to put the specified string on the image
g.DrawRectangle(System.Drawing.Pens.Transparent, 0, 0, 240 - 1, 176 - 1);
g.DrawRectangle(System.Drawing.Pens.Transparent, 1, 1, 240 - 3, 176 - 3);
d = g.MeasureString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay);
sLeft = (240 - d.Width)/2;
sTop = (176 - d.Height)/2;
g.DrawString(m_String + "\n" + DateTime.Now.ToString("G"), fontOverlay, System.Drawing.Brushes.Black,
sLeft, sTop, System.Drawing.StringFormat.GenericTypographic);
// need to flip the bitmap so it's the same orientation as the
// video buffer
bitmapOverlay.RotateFlip(RotateFlipType.RotateNoneFlipY);
// create and copy the video's buffer image to a bitmap
Bitmap v;
v = new Bitmap(240, 176, 1056,
PixelFormat.Format24bppRgb, pBuffer);
g = Graphics.FromImage(v);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
// draw the overlay bitmap over the video's bitmap
g.DrawImage(bitmapOverlay, 0, 0, bitmapOverlay.Width, bitmapOverlay.Height);
// dispose of the various objects
g.Dispose();
v.Dispose();
// Increment frame number. Done this way, frame are zero indexed.
m_Count++;
return 0;
}
我的问题是,当我开始程序时,它显示我在预览窗口中的文本覆盖,但是当我打开记录文件覆盖文字不会继续..我想我缺少一些帧..在一些帧覆盖是他们,但它不会继续。 。轻弹。 任何人都可以帮忙吗?