求教:在视频上画图,图形显示不了!
视频在panl里显示,paintbox重叠在panl上,有视频的部分图形显示不了,没有的就可以显示。请高手解答!谢谢!
[解决办法]
function OnPreview(ph: PBitmapInfoHeader; buff: pbyte): HRESULT; stdcall;
var dc: HDC;
iw, ih: Integer;
bmp , bmpframe: TGpBitmap;
bd: TBitmapData;
gp ,gpframe : TGpGraphics;
begin
if GStopView then Exit;
dc := GetDC(frmMain.pnlVideo.Handle);
bmp := TGpBitmap.Create(ph^.biWidth, ph^.biHeight, pf24bppRGB);
bmpframe := TGpBitmap.Create('E:\Work\Project\Paster\bin\matter\cpic\combine\200003.png');
gpframe := TGpGraphics.Create(bmp);
bd := bmp.LockBits(GpRect(0, 0, bmp.Width, bmp.Height), [imRead], pf24bppRGB);
CopyMemory(bd.Scan0, buff, bd.Height * bd.Stride);
if (PAVIFile <> nil) and (PAVIStream <> nil) and Start then
WriteAviFile(PAVIStream,istep,bd.Scan0,bd.Width,bd.Height,bd.Height * bd.Stride,True);
bmp.UnlockBits(bd);
gpframe.DrawImage(bmpframe,GpRect(0,0,bmp.Width,bmp.Height),0,0,bmpframe.Width,bmpframe.Height,utPixel);
iw := frmMain.pnlVideo.Width;
ih := Round(ph^.biHeight * iw / ph^.biWidth);
gp := TGpGraphics.Create(dc);
gp.DrawImage(bmp, GpRect(0, 0, iw, ih), 0, 0, bmp.Width, bmp.Height, utPixel);
FreeAndNil(bmp);
FreeAndNil(gp);
FreeAndNil(bmpframe);
FreeAndNil(gpframe);
ReleaseDC(frmMain.pnlVideo.Handle, dc);
end;
[解决办法]
如果是对他截获的图片进行处理,不理想!截获视频窗口的窗口过程是最理想的实现方式,因为实际的Panel之上还有一个Video的窗口覆盖在上面!所有的视频的绘制都在这个视频窗口上,实际上视频窗口内部有一个WM_Timer消息再通知视频界面不断的刷新。具体的可以试试!我当时做的时候都是VFW,所以我说的这些都是针对VFW。