各位老大,怎么取得摄象头的图象保存为图片,能不能贴一段代码上来呀,谢谢。
解决方案 »
- 由输入和输出得出公式
- 通过扫描图片得到的HRGN,创建不规则窗体,如何保存HRGN到文件,避免每次扫描
- 怎样设置放解除文件中的某个目录的只读属性?
- 紧急求助!如何对DBgrid的所有行进行循环读取,然后改变DBGrid控件中某几个行的颜色?
- 游戏“连连看”的算法!
- QuikRep预览界面汉化及报表设计?
- 各位大师,哪里有网管软件的源代码,事关我的饭碗,还望... ...
- stringlist搜索问题
- 哪里有下载DELPHI语言的电子书?有没有经典的书?
- delphi工具栏上的checkbox为什么有个像分割条的竖线
- 怎样才能将一个应用程序中已屏蔽的BUTTON恢复?
- 使用IHTMLDocument2的困惑
http://community.csdn.net/Expert/topic/3244/3244287.xml?temp=.4416925
WM_CAP_START = WM_USER;
WM_CAP_SET_CALLBACK_ERROR = WM_CAP_START + 2;
WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3;
WM_CAP_SET_CALLBACK_FRAME = WM_CAP_START + 5;
WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + 6;
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20;
WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25;
WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42;
WM_CAP_SET_PREVIEW = WM_CAP_START + 50;
WM_CAP_SET_OVERLAY = WM_CAP_START + 51;
WM_CAP_SET_PREVIEWRATE = WM_CAP_START + 52;
WM_CAP_SET_SCALE = WM_CAP_START + 53;
WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
WM_CAP_SEQUENCE = WM_CAP_START + 62;
WM_CAP_SEQUENCE_NOFILE = WM_CAP_START + 63;
WM_CAP_STOP = WM_CAP_START + 68;function capCreateCaptureWindow(lpszWindowName: PChar; dwStyle: Longint; x: Integer;
y: Integer; nWidth: Integer; nHeight: Integer; ParentWin: HWND;
nId: Integer): HWND; stdcall;implementationfunction capCreateCaptureWindow; external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';end.//实现
//开始监视
procedure TfrmMain.btn_PrevBeginClick(Sender: TObject);
begin
hWndC := capCreateCaptureWindow('', WS_CHILD or WS_VISIBLE , 40, 30, 320, 240, pal_Prev.Handle, 0);
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0);
SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUS, 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);
btn_PrevBegin.Enabled := False;
btn_PrevEnd.Enabled := True;
btn_CatchBMP.Enabled := True;
btn_RecBegin.Enabled := True;
end;
end;//停止监视
procedure TfrmMain.btn_PrevEndClick(Sender: TObject);
begin
if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
btn_PrevBegin.Enabled := True;
btn_PrevEnd.Enabled := False;
btn_CatchBMP.Enabled := False;
btn_RecBegin.Enabled := False;
end;
end;//抓图
procedure TfrmMain.btn_CatchBMPClick(Sender: TObject);
var
FileName: string;
begin
if hWndC <> 0 then
begin
FileName := CurPath + '\' + FormatDateTime('HHMMSSZZZ', Now) + '.bmp';
SendMessage(hWndC, WM_CAP_FILE_SAVEDIB, 0, Longint(PChar(FileName)));
img_BMP.Picture.LoadFromFile(FileName);
flstbox_BMP.Update;
flstbox_BMP.Selected[flstbox_BMP.Items.Count-1] := True;
end;
end;//开始录像
procedure TfrmMain.btn_RecBeginClick(Sender: TObject);
begin
if hWndC <> 0 then
if sd_AVI.Execute then
begin
SendMessage(hWndC, WM_CAP_FILE_SET_CAPTURE_FILE, 0, Longint(PChar(sd_AVI.FileName)));
SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
btn_RecBegin.Enabled := False;
btn_RecEnd.Enabled := True;
end;
end;//停止录像
procedure TfrmMain.btn_RecEndClick(Sender: TObject);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_STOP, 0, 0);
btn_RecBegin.Enabled := True;
btn_RecEnd.Enabled := False;
end;
end;
ImageEnIO1.Acquire;
// Sets colormapped 256 colors
ImageEnIO1.Params.BitsPerSample:=1;
ImageEnIO1.Params.SamplesPerPixel:=1;
// Sets OS2.x compressed BMP
ImageEnIO1.Params.BMP_Version:=ioBMP_BMOS2V2;
ImageEnIO1.Params.BMP_Compression:=ioBMP_RLE;
// Saves ImageEnIO1.SaveToFile('a.bmp');