| 发表于:2007-12-13 09:12:556楼 得分:0 |
就是这部分出的问题!! private sub command7_click() dim status as hvstatus dim i as integer 'dim popts as long 'creat avi dim file as cfiledlg dim initdir as string dim szoutputavifile as string dim res as long dim pfile as long 'ptr pavifile dim bmp as cdib dim ps as long 'ptr pavistream dim pscompressed as long 'ptr pavistream dim strhdr as avi_stream_info dim bi as bitmapinfoheader1 dim opts as avi_compress_options 'dim popts as long 'dim i as long dim i1 as long dim ntemp as long ntemp = hv_width * hv_height - 1 redim prawbuffer(0 to ntemp) '设置原始图像缓冲区大小 '分配bayer转换后图像数据缓冲 redim pimagebuffer(0 to (hv_width * hv_height * 3 - 1)) 'call avi status = status_ok ' 启动数字摄像机采集图像到内存 bstart = true dim plutr(0 to 255) as byte dim plutg(0 to 255) as byte dim plutb(0 to 255) as byte for i = 0 to 255 plutr(i) = i plutg(i) = i plutb(i) = i next i dim ppbuf(0 to 0) as long ppbuf(0) = varptr(prawbuffer(0)) '改变菜单的状态 ' menustart(2).enabled = false ' menustop(3).enabled = true 'call avi '' set file = new cfiledlg 'get an avi filename from user '' with file '' .defaultext = "avi" '' .dlgtitle = "choose a filename to save avi to..." '' .filter = "avi files ¦*.avi" '' .ownerhwnd = me.hwnd '' end with dim tt, tt1, tt2 as string tt = format(now, "ddddd ttttt") tt1 = replace(tt, " ", "-", (1), (11)) tt2 = replace(tt1, ":", "-", 1) szoutputavifile = "d:\avi\avi" + tt2 + ".avi" '' if file.vbgetsavefilename(szoutputavifile) <> true then exit sub ' open the file for writing res = avifileopen(pfile, szoutputavifile, of_write or of_create, 0&) 'if (res <> avierr_ok) then msgbox ("error") 'goto error 'get the first bmp in the list for setting format ''set bmp = new cdib ''lstdiblist.listindex = 0 ''if bmp.createfromfile(lstdiblist.text) <> true then '' msgbox "could not load first bitmap file in list!", vbexclamation, app.title '' goto error '' end if ' fill in the header for the video stream with strhdr .fcctype = streamtypevideo 'mmiostringtofourcc("vids", 0&) '// stream type video .fcchandler = 0 '// default avi handler .dwscale = 1 .dwrate = 24 'val(txtfps) '// fps .dwsuggestedbuffersize = 100 * 100 * 3 'bmp.sizeimage '// size of one frame pixels call setrect(.rcframe, 0, 0, 100, 100) '// rectangle for stream end with 'validate user input ''' if strhdr.dwrate < 1 then strhdr.dwrate = 1 ''' if strhdr.dwrate > 30 then strhdr.dwrate = 30 ' and create the stream res = avifilecreatestream(pfile, ps, strhdr) ''' if (res <> avierr_ok) then print 11111 'goto error 'goto error 'get the compression options from the user 'careful! this api requires a pointer to a pointer to a udt popts = varptr(opts) res = avisaveoptions(me.hwnd, _ icmf_choose_keyframe or icmf_choose_datarate, _ 1, _ ps, _ popts) 'returns true if user presses ok, false if cancel, or error code ''' if res <> 1 then 'in c true = 1 ''' call avisaveoptionsfree(1, popts) ''goto error ''' end if 'make compressed stream res = avimakecompressedstream(pscompressed, ps, opts, 0&) ''' if res <> avierr_ok then print 111 'goto error res = avistreamsetformat(pscompressed, 0, byval bminfo, 80000) ''' if (res <> avierr_ok) then print 111 'goto error 'delay (0.1) 'keybd_event chr$(38), 0, 0, 0 'delay (0.1) 'keybd_event chr$(38), 0, keyeventf_keyup, 0 ' addch0 = ac6610_ad(hd6610, 0, gain) ' v0 = (addch0 - 2048) * 5000# / 2048# do while bstart status = hvsnapshot(hhv, varptr(ppbuf(0)), 1) hv_verify (status) if (hv_success(status)) then convertbayer2rgb varptr(pimagebuffer(0)), varptr(prawbuffer(0)), hv_width, hv_height, bayer2rgb_neighbour, varptr(plutr(0)), varptr(plutg(0)), varptr(plutb(0)), true, bayer_gr res = avistreamwrite(pscompressed, _ i1, _ 1, _ varptr(pimagebuffer(0)), _ 100 * 100 * 3, _ aviif_keyframe, _ byval 0&, _ byval 0&) '在视图客户区显示图像 stretchdibits form1.hdc, 0, 0, hv_width, hv_height, 0, 0, hv_width, hv_height, pimagebuffer(0), bminfo, dib_rgb_colors, srccopy end if doevents i1 = i1 + 1 '''end if loop 'now close the file ''' set file = nothing ''' set bmp = nothing call avistreamclose(ps) call avistreamclose(pscompressed) call avifileclose(pfile) call avifileexit end sub | | |
|