我使用AVICAP32.DLL来捕获图像,捕完并保存到文件后,当我关闭它后.那个黑块的窗体一直在那里,如果让它消失呢?
我的部分代码如下:
//开启摄像头
hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top+29,Panel1.Width,Panel1.Height,Form3.Handle,0);
hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top+29,Panel1.Width,Panel1.Height,Form3.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_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;
//关闭摄像头
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
//捕获保存图像
var
path1,path2:string;
f: file of Byte;
size: Longint;
MyBitmap:TBitmap;
begin
try
path1:=extractfilepath(paramstr(0));
path2:=path1+'\temp.bmp';
if hWndC <> 0 then
SendMessage(hWndC,WM_CAP_SAVEDIB,0,longint(pchar(path2)));
MyBitmap:=TBitmap.Create();
MyBitmap.LoadFromFile(pchar(path2));
BmpToJpeg(MyBitmap,75);
path2:=path1+'\temp.jpg';
AssignFile(f, path2);
Reset(f);
size := FileSize(f);
if size<110000 then
begin
CloseFile(f);
if adotable1.State=dsbrowse then
adotable1.Edit;
DBImage1.Picture.LoadFromFile(path2);
dbimage1.CopyToClipboard;
dbimage1.PasteFromClipboard;
if adotable1.State=dsbrowse then
adotable1.Post;
end
else application.MessageBox('图像太大了,可能是您使用的拍照工具解晰度太高引起.请使用<从照片文件导入>方式添加照片,要求文件小于100K','提示',mb_ok);
finally
mybitmap.Free;
end;
end;
////////////////////////////////////////////////////////////
我一般是先点击开启摄像头,然后捕获保存图像,再关闭摄像头
但是最后那个黑块还是留在窗体上.如何关闭让它消失呢?
我的部分代码如下:
//开启摄像头
hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top+29,Panel1.Width,Panel1.Height,Form3.Handle,0);
hWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top+29,Panel1.Width,Panel1.Height,Form3.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_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;
//关闭摄像头
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
//捕获保存图像
var
path1,path2:string;
f: file of Byte;
size: Longint;
MyBitmap:TBitmap;
begin
try
path1:=extractfilepath(paramstr(0));
path2:=path1+'\temp.bmp';
if hWndC <> 0 then
SendMessage(hWndC,WM_CAP_SAVEDIB,0,longint(pchar(path2)));
MyBitmap:=TBitmap.Create();
MyBitmap.LoadFromFile(pchar(path2));
BmpToJpeg(MyBitmap,75);
path2:=path1+'\temp.jpg';
AssignFile(f, path2);
Reset(f);
size := FileSize(f);
if size<110000 then
begin
CloseFile(f);
if adotable1.State=dsbrowse then
adotable1.Edit;
DBImage1.Picture.LoadFromFile(path2);
dbimage1.CopyToClipboard;
dbimage1.PasteFromClipboard;
if adotable1.State=dsbrowse then
adotable1.Post;
end
else application.MessageBox('图像太大了,可能是您使用的拍照工具解晰度太高引起.请使用<从照片文件导入>方式添加照片,要求文件小于100K','提示',mb_ok);
finally
mybitmap.Free;
end;
end;
////////////////////////////////////////////////////////////
我一般是先点击开启摄像头,然后捕获保存图像,再关闭摄像头
但是最后那个黑块还是留在窗体上.如何关闭让它消失呢?
解决方案 »
- delphi如何处理 中文乱码 ?
- 一个画圆的算法,大家看看什么地方错了
- 在线急等-100分. 一个获取光标位置的问题.
- 数据库中关于时间的格式
- 求助【delphi怎么随即文本内容】
- 世界上最简单的问题
- ‘createoleobject’出错,在线等待!!!急急!这里有例子,请帮我分析一下
- 紧急问题!!!请问如何用delphi向SQL Server表中的smalldatetime类型的字段添加记录?谢谢
- 我在程序中直接用DATABASE连接ODBC,但在没有安装DELPHI的机子上就不能运行,错误提示是:
- 类释放是否有冲突,造成空指针错误?
- 一个调用Dll子窗体如何释放的问题!
- 如何在delphi中调用EnumWindows(@EnumWindowsProc, 0);
试过了,我对窗体和PANEL等相关的控件分别和一起进行了REFRESH动作试验,结果还是不能去掉它.但是当我占击它时黑块后面的IMAGE控件还可以显示出来冲掉黑块.明显是刷新问题. 请再帮我想想办法好吗?
//关闭摄像头
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
SendMessage(hWndC, WM_CLOSE, 0, 0);
hWndC := 0;
end;OK,完事了.