首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

怎么使用PB实现视频照相功能?

2012-08-13 
如何使用PB实现视频照相功能????如何使用PB实现视频照相功能????希望各位老兄,多指点!!!![解决办法]OLE方

如何使用PB实现视频照相功能????
如何使用PB实现视频照相功能????希望各位老兄,多指点!!!!

[解决办法]
OLE方式,调用摄像头控件应该能实现

[解决办法]
主要是调用摄像头的控件,声明一些外部函数罢了,可以看一下说明书,网上很多,可以搜索一下
[解决办法]
将以下代码存为uo_custom.sru,然后导入PBL中。
将uo_custom放入任意一个window内,打开这个window即可使用摄像头并拍照。

SQL code
$PBExportHeader$uo_custom.sruforwardglobal type uo_custom from userobjectend typetype cb_3 from commandbutton within uo_customend typetype cb_2 from commandbutton within uo_customend typetype cb_1 from commandbutton within uo_customend typetype st_1 from statictext within uo_customend typetype p_1 from picture within uo_customend typeend forwardglobal type uo_custom from userobjectinteger width = 2939integer height = 1400long backcolor = 67108864string text = "none"long tabtextcolor = 33554432long picturemaskcolor = 536870912cb_3 cb_3cb_2 cb_2cb_1 cb_1st_1 st_1p_1 p_1end typeglobal uo_custom uo_customtype prototypesfunction ulong capCreateCaptureWindowA(string lpszWindowName,ulong dwStyle,long li_x ,long li_y ,long nWidth ,long nHeight ,ulong ParentWin ,long  nId ) LIBRARY 'AVICAP32.DLL' end prototypestype variablesPrivate:uint lhandConstant long WM_USER=1024Constant long WM_CAP_START = WM_USER Constant long WM_CAP_STOP = WM_CAP_START + 68 Constant long WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10 Constant long WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11 Constant long WM_CAP_SAVEDIB = WM_CAP_START + 25 Constant long WM_CAP_GRAB_FRAME = WM_CAP_START + 60 Constant long WM_CAP_SEQUENCE = WM_CAP_START + 62 Constant long WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20 Constant long WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+  63 Constant long WM_CAP_SET_OVERLAY =WM_CAP_START+  51 Constant long WM_CAP_SET_PREVIEW =WM_CAP_START+  50 Constant long WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6 Constant long WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2 Constant long WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3 Constant long WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5 Constant long WM_CAP_SET_SCALE=WM_CAP_START+  53 Constant long WM_CAP_SET_PREVIEWRATE=WM_CAP_START+  52 end variableson uo_custom.createthis.cb_3=create cb_3this.cb_2=create cb_2this.cb_1=create cb_1this.st_1=create st_1this.p_1=create p_1this.Control[]={this.cb_3,&this.cb_2,&this.cb_1,&this.st_1,&this.p_1}end onon uo_custom.destroydestroy(this.cb_3)destroy(this.cb_2)destroy(this.cb_1)destroy(this.st_1)destroy(this.p_1)end onevent destructor;if lhand <> 0 then     send(lhand, WM_CAP_DRIVER_DISCONNECT, 0, 0)    lhand =0end ifend eventtype cb_3 from commandbutton within uo_custominteger x = 430integer y = 1252integer width = 325integer height = 100integer taborder = 90integer textsize = -9fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"string text = "关闭摄像头"end typeevent clicked;send(lhand, WM_CAP_DRIVER_DISCONNECT, 0, 0)lhand =0cb_1.enabled = trueend eventtype cb_2 from commandbutton within uo_custominteger x = 782integer y = 1252integer width = 325integer height = 100integer taborder = 80integer textsize = -9fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"string text = "拍照"end typeevent clicked;string s_maps_map='C:\save.bmp'if lhand <> 0 then     if FileExists(s_map) then FileDelete(s_map)    Send(lhand,WM_CAP_SAVEDIB,0,s_map);    p_1.picturename = s_map    send(lhand, WM_CAP_DRIVER_DISCONNECT, 0, 0)    lhand =0    messagebox('提示','照片已存为'+s_map)else    messagebox('提示','请先打开摄像头')end ifend eventtype cb_1 from commandbutton within uo_custominteger x = 78integer y = 1252integer width = 325integer height = 100integer taborder = 70integer textsize = -9fontcharset fontcharset = gb2312charset!fontpitch fontpitch = variable!string facename = "宋体"string text = "打开摄像头"end typeevent clicked;string lpszName,sulong l1setpointer(hourglass!)l1=handle(st_1)lpszName='摄像头'lhand=capCreateCaptureWindowA(lpszName,262144+12582912+1073741824 + 268435456,0,0,UnitsToPixels(st_1.width,XUnitsToPixels!),UnitsToPixels(st_1.height,YUnitsToPixels!),l1,0)if lhand <> 0 then     send(lhand, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)   send(lhand, WM_CAP_SET_CALLBACK_ERROR, 0, 0)   send(lhand, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)   send(lhand, WM_CAP_DRIVER_CONNECT, 0, 0)   send(lhand, WM_CAP_SET_SCALE, 1, 0)   send(lhand, WM_CAP_SET_PREVIEWRATE, 66, 0)   send(lhand, WM_CAP_SET_OVERLAY, 1, 0)  send(lhand, WM_CAP_SET_PREVIEW, 1, 0)   cb_2.enabled = true  this.enabled = falseend if    setpointer(arrow!)end eventtype st_1 from statictext within uo_custominteger x = 18integer y = 12integer width = 1435integer height = 1184integer textsize = -9integer weight = 400fontcharset fontcharset = ansi!fontpitch fontpitch = variable!fontfamily fontfamily = swiss!string facename = "Arial"long textcolor = 33554432long backcolor = 67108864boolean enabled = falsealignment alignment = center!boolean border = trueboolean focusrectangle = falseend typetype p_1 from picture within uo_custominteger x = 1472integer y = 12integer width = 1435integer height = 1184boolean enabled = falseboolean originalsize = trueboolean border = trueboolean focusrectangle = falseend type 


[解决办法]
gz

热点排行