hWndC := capCreateCaptureWindowA('教师资格照片采集',WS_CHILD or WS_VISIBLE ,Panel1.Left+5,Panel1.Top+5,640,480,Form1.Handle,0);
//显示的视频在Panel1控件上,并调整好视频大小和位置
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0);
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
end;
2.2 截取整幅图像
截取整幅图像保存成一个BMP文件,并通过Image控件显示出来:
procedure TForm1.Button1Click(Sender: TObject);
var
bakrec:TRect;
begin
if hWndC<>0 then
begin
if pregrab then
begin
SendMessage(hWndc,WM_CAP_SET_PREVIEWRATE,30,0) ;
SendMessage(hWndc,WM_CAP_SET_PREVIEW,WPARAM(true),0);
pregrab:=false;
end
else
|