W
whitecloud
Unregistered / Unconfirmed
GUEST, unregistred user!
视频采集中,为何保存位图后,采集窗口会停下来?
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AviCapH, StdCtrls, ExtCtrls,clipbrd;
type
TForm1 = class(TForm)
Button3: TButton;
SaveDialog2: TSaveDialog;
Panel2: TPanel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
CapHandle:THandle;
CaptureParms:TCaptureParms;
procedure CreateCaptureWindow;
public
{ Public declarations }
end;
var
FrameCount : Integer = 0;
Form1: TForm1;
function OnStatus(hWnd:THandle; nID:Integer;lpStatusTextChar):Boolean;stdcall;
function OnError(hWnd:THandle; nErrorID:Integer;lpErrorTextChar):Boolean;stdcall;
function OnYield(hWnd:THandle):Boolean;stdcall;
implementation
{$R *.DFM}
procedure TForm1.CreateCaptureWindow;
begin
CapHandle :=capCreateCaptureWindowA('',WS_VISIBLE+WS_CHILD+WS_BORDER,0,0,Panel2.Width,Panel2.Height,Panel2.Handle,0);
capCaptureGetSetup(CapHandle,Longint(@CaptureParms),Sizeof(TCaptureParms));
with CaptureParms do
begin
dwRequestMicroSecPerFrame := 66667;
fMakeUserHitOKToCapture := False;
fAbortLeftMouse := True;
fAbortRightMouse := True;
dwIndexSize := 34952;
vKeyAbort := 27;
end;
capSetCallbackOnStatus(CapHandle,Longint(@OnStatus));
capSetCallbackOnError(CapHandle,Longint(@OnError));
capSetCallbackOnYield(CapHandle,Longint(@OnYield));
capDriverConnect (CapHandle,0);
capOverlay(CapHandle,Longint(True));
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if AviCap1.cap_Connected then
AviCap1.cap_Connected := False;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
BitMap : TBitMap;
i : Integer;
FileName:array [0..50] of Char;
begin
if not SaveDialog1.Execute then
Exit;
StrPCopy(FileName,SaveDialog1.FileName);
capFileSaveDIB(CapHandle,LongInt(@FileName));
////////////////////////////////////////////////////////////////////////////////////
//????为何此后采集窗口会停下来,而切换窗口后(或用户有其它动作)又会恢复动态显示????//
/////////////////////////////////////////////////////////////////////////////////////
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SaveDialog1.InitialDir := ExtractFilePath(Application.ExeName);
CreateCaptureWindow;
end;
end.
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AviCapH, StdCtrls, ExtCtrls,clipbrd;
type
TForm1 = class(TForm)
Button3: TButton;
SaveDialog2: TSaveDialog;
Panel2: TPanel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
CapHandle:THandle;
CaptureParms:TCaptureParms;
procedure CreateCaptureWindow;
public
{ Public declarations }
end;
var
FrameCount : Integer = 0;
Form1: TForm1;
function OnStatus(hWnd:THandle; nID:Integer;lpStatusTextChar):Boolean;stdcall;
function OnError(hWnd:THandle; nErrorID:Integer;lpErrorTextChar):Boolean;stdcall;
function OnYield(hWnd:THandle):Boolean;stdcall;
implementation
{$R *.DFM}
procedure TForm1.CreateCaptureWindow;
begin
CapHandle :=capCreateCaptureWindowA('',WS_VISIBLE+WS_CHILD+WS_BORDER,0,0,Panel2.Width,Panel2.Height,Panel2.Handle,0);
capCaptureGetSetup(CapHandle,Longint(@CaptureParms),Sizeof(TCaptureParms));
with CaptureParms do
begin
dwRequestMicroSecPerFrame := 66667;
fMakeUserHitOKToCapture := False;
fAbortLeftMouse := True;
fAbortRightMouse := True;
dwIndexSize := 34952;
vKeyAbort := 27;
end;
capSetCallbackOnStatus(CapHandle,Longint(@OnStatus));
capSetCallbackOnError(CapHandle,Longint(@OnError));
capSetCallbackOnYield(CapHandle,Longint(@OnYield));
capDriverConnect (CapHandle,0);
capOverlay(CapHandle,Longint(True));
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if AviCap1.cap_Connected then
AviCap1.cap_Connected := False;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
BitMap : TBitMap;
i : Integer;
FileName:array [0..50] of Char;
begin
if not SaveDialog1.Execute then
Exit;
StrPCopy(FileName,SaveDialog1.FileName);
capFileSaveDIB(CapHandle,LongInt(@FileName));
////////////////////////////////////////////////////////////////////////////////////
//????为何此后采集窗口会停下来,而切换窗口后(或用户有其它动作)又会恢复动态显示????//
/////////////////////////////////////////////////////////////////////////////////////
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SaveDialog1.InitialDir := ExtractFilePath(Application.ExeName);
CreateCaptureWindow;
end;
end.