📄 videocard.pas
字号:
unit videocard;
interface
uses
windows,SysUtils;
type
TVideoCard = class
public
constructor Create(ID:LongInt);
destructor Destroy();override;
function Connect():Boolean;
procedure Disconnect();
function SetParam():Boolean;
function SetChannel(channel:Byte):Boolean;
function SetVideoInfo(param,value:LongInt):Boolean;
procedure GetCurDib(Image:Pointer);
procedure SavePics(filename:string;image:Pointer;quality:Integer);
procedure StartCap();
procedure StopCap();
private
m_nCardId:Integer;
m_hCard:Integer; //卡句柄
m_Cs:TRTLCriticalSection;
protected
end;
////////////////////////////////////////////////////////////////////////////////
function Card_Connect(id:Integer):Integer;cdecl;external 'videocard.dll';
procedure Card_Disconnect(hcard:Integer);cdecl;external 'videocard.dll';
procedure Card_SetParam(hcard:Integer);cdecl;external 'videocard.dll';
procedure Card_SetVideoInfo(hcard:Integer; prop:Integer; value:Integer);cdecl;external 'videocard.dll';
procedure Card_SetChannel(hcard:Integer;channel:Integer);cdecl;external 'videocard.dll';
procedure Card_GetCurDib(hcard:Integer; image:Pointer);cdecl;external 'videocard.dll';
procedure Card_SaveJpgFile(hcard:Integer;image:Pointer; filename:PChar; quality:Integer);cdecl;external 'videocard.dll';
procedure Card_StartCap(hcard:Integer; snapfunc:Pointer);cdecl;external 'videocard.dll';
procedure Card_StopCap(hcard:Integer);cdecl;external 'videocard.dll';
implementation
uses
MainForm;
procedure CallBack(id:Integer;var bmi:TBITMAPINFOHEADER;image:PByte); cdecl;
begin
Form1.HandleImage(image);
end;
constructor TVideoCard.Create(ID:LongInt);
begin
m_nCardID:=ID;
Connect();
SetParam();
SetChannel(0);
end;
destructor TVideoCard.Destroy();
begin
Disconnect();
end;
/////////////////////////////////////////////////////////////////////////////////
function TVideoCard.Connect():Boolean;
begin
m_hCard:=Card_Connect(m_nCardID);
Result:=true;;
end;
procedure TVideoCard.Disconnect();
begin
Card_Disconnect(m_hCard);
end;
function TVideoCard.SetParam():Boolean;
begin
Card_SetParam(m_hCard);
Result:=true;;
end;
function TVideoCard.SetChannel(channel:Byte):Boolean;
begin
Card_SetChannel(m_hCard,channel);
Result:=true;;
end;
function TVideoCard.SetVideoInfo(param,value:LongInt):Boolean;
begin
Card_SetVideoInfo(m_hCard,param,value);
Result:=true;;
end;
procedure TVideoCard.SavePics(filename:string;image:Pointer;quality:Integer);
begin
Card_SaveJpgFile(m_hCard,image,PChar(filename),quality);
end;
procedure TVideoCard.GetCurDib(Image:Pointer);
begin
Card_GetCurDib(m_hCard,Image);
end;
procedure TVideoCard.StartCap();
begin
Card_StartCap(m_hcard,@CallBack);
end;
procedure TVideoCard.StopCap();
begin
Card_StopCap(m_hCard);
end;
end.
/////////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -