//在图像上增加时间 procedure TFromVdisplayWin.AddTimeTitle(var lpVhdr: PVIDEOHDR); var pDataBuf,pBitsMem : Pointer; DC : HDC; BMHandle : HBITMAP; b : TBitmap; sDatetime : string; begin try // 视频数据缓冲区列表 if FVideoBufList=nil then exit; // 视频数据读取标志,正在读取时为True if FVideoStreamReading then exit; FVideoStreamReading := true; if lpVhdr^.lpData=nil then begin FVideoStreamReading := False; Exit; end; if bBitMapInFo=nil then begin FVideoStreamReading := false; Exit; end; pDataBuf := lpVhdr^.lpData; DC := GetDC(0); try BMHandle := CreateDIBSection(DC,bBitMapInFo^,DIB_RGB_COLORS,pBitsMem,0,0); if BMHandle<>0 then begin try Move(pDataBuf^,pBitsMem^,lpvhdr^.dwBytesUsed); except DeleteObject(BMHandle); BMHandle :=0; end; end; finally ReleaseDC(0,DC); end; if BMHandle=0 then begin FVideoStreamReading := False; Exit; end; b := TBitmap.Create; b.Handle := BMHandle; SetBkMode(b.Canvas.Handle,TRANSPARENT); b.Canvas.Font.Size :=16 ; sDatetime := DateToStr(Now)+' '+ FormatDateTime('HH:mm:ss',now); B.Canvas.Font.Color := clBlack; b.Canvas.TextOut(20,5,sDatetime); try Move(pBitsMem^,pDataBuf^,lpvhdr^.dwBytesUsed); except FVideoStreamReading := False; end; b.Free; except on E:Exception do begin
procedure TFromVdisplayWin.AddTimeTitle(var lpVhdr: PVIDEOHDR);
var
pDataBuf,pBitsMem : Pointer;
DC : HDC;
BMHandle : HBITMAP;
b : TBitmap;
sDatetime : string;
begin
try
// 视频数据缓冲区列表
if FVideoBufList=nil then exit;
// 视频数据读取标志,正在读取时为True
if FVideoStreamReading then exit;
FVideoStreamReading := true; if lpVhdr^.lpData=nil then
begin
FVideoStreamReading := False;
Exit;
end; if bBitMapInFo=nil then
begin
FVideoStreamReading := false;
Exit;
end; pDataBuf := lpVhdr^.lpData;
DC := GetDC(0);
try
BMHandle := CreateDIBSection(DC,bBitMapInFo^,DIB_RGB_COLORS,pBitsMem,0,0);
if BMHandle<>0 then
begin
try
Move(pDataBuf^,pBitsMem^,lpvhdr^.dwBytesUsed);
except
DeleteObject(BMHandle);
BMHandle :=0;
end;
end;
finally
ReleaseDC(0,DC);
end; if BMHandle=0 then
begin
FVideoStreamReading := False;
Exit;
end; b := TBitmap.Create;
b.Handle := BMHandle;
SetBkMode(b.Canvas.Handle,TRANSPARENT);
b.Canvas.Font.Size :=16 ;
sDatetime := DateToStr(Now)+' '+ FormatDateTime('HH:mm:ss',now);
B.Canvas.Font.Color := clBlack;
b.Canvas.TextOut(20,5,sDatetime); try
Move(pBitsMem^,pDataBuf^,lpvhdr^.dwBytesUsed);
except
FVideoStreamReading := False;
end;
b.Free;
except
on E:Exception do
begin
end;
end;
end;