CapWnd:THandle; //定義捕捉窗句柄
CapParms:TcaptureParms; //用於設置設備屬性的結構變量
BMPINFO:TBitmapInfo; //BMP圖像信息
開始按鈕代碼
CapWnd := capCreateCaptureWindow(
if CapWnd =
CapSetCallbackOnFrame(CapWnd
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapCaptureSetSetup(capWnd
CapPreviewRate(capWnd
CapCaptureSequenceNoFile(capWnd); //如果要捕捉視頻流
capGetVideoFormat(capWnd
CapPreviewScale(capWnd
CapOverlay(capWnd
回調函數代碼
var hd:Thandle;
jpg:TJpegImage;
memStream :TMemoryStream;
Bitmap:TBitmap;
begin //將數據顯在Image
Bitmap:=TBitmap
Bitmap
// New size of Bitmap
Bitmap
hd:= DrawDibOpen; DrawDibDraw(hd
BMPINFO
@BMPINFO
BMPINFO
DrawDibClose(hd); //發送數據
memStream := TMemoryStream
jpg := TJpegImage
jpg
jpg
jpg
jpg
jpg
jpg
Form
if memStream
//向
Form
memStream
Bitmap
End;
停止代碼
capCaptureAbort(CapWnd); //停止捕捉 capDriverDisconnect(CapWnd); //將捕捉窗同驅動器斷開
完整的視頻聊天軟件服務器代碼
unit Unit
interfaceuses Windows
Button
Button
IdUDPClient
procedure Button
procedure Button
private { Private declarations }
public { Public declarations }
end;
var Form
CapWnd:THandle; //定義捕捉窗句柄
CapParms:TcaptureParms; //用於設置設備屬性的結構變量
BMPINFO:TBitmapInfo; //BMP圖像信息
implementation{$R *
function FrameCallBack(hWnd: HWND; lpVHdr: PVIDEOHDR): LongInt;stdcall;
var hd:Thandle;
jpg:TJpegImage;
memStream :TMemoryStream;
Bitmap:TBitmap;
begin //將數據顯在Image
Bitmap:=TBitmap
Bitmap
// New size of Bitmap
Bitmap
hd:= DrawDibOpen;
DrawDibDraw(hd
bmiheader
lpVHdr^
DrawDibClose(hd);
//發送數據
memStream := TMemoryStream
jpg := TJpegImage
jpg
//jpg壓縮質量
jpg
jpg
jpg
jpg
//因為UDP數據包有大小限制
Form
if memStream
//向
Form
else
Form
memStream
Bitmap
end;
procedure TForm
begin
CapWnd := capCreateCaptureWindow(
panel
panel
panel
if CapWnd =
CapSetCallbackOnFrame(CapWnd
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapParms
CapCaptureSetSetup(capWnd
CapPreviewRate(capWnd
CapCaptureSequenceNoFile(capWnd); //如果要捕捉視頻流
CapDriverConnect(CapWnd
CapPreviewScale(capWnd
CapOverlay(capWnd
begin capCaptureAbort(CapWnd); //停止捕捉
capDriverDisconnect(CapWnd); //將捕捉窗同驅動器斷開
end;
end
From:http://tw.wingwit.com/Article/program/Delphi/201311/24744.html