您的位置:程序门 -> vb -> 多媒体



很奇怪的现象?????


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


很奇怪的现象?????
发表于:2007-12-11 21:45:37 楼主
我做了一个视频程序,在显示图像的同时录取avi文件,
就是在一个do   while循环里反复调用两个函数,在vb环境
下编译后执行无问题,但是做成可执行文件后每次执行
exe文件,执行程序都自动退出,编译后执行和直接执行
exe文件有什么不同吗???????????
发表于:2007-12-11 22:36:121楼 得分:0
你可以f8一下。

你可以看看编译执行你退出的时候内存是否还有exe的存在
发表于:2007-12-12 09:05:182楼 得分:0
也许你的程序里使用了复制内存,hook,子类化等操作.....

如果生成后出现问题,试一下在编译选项里面选择"不优化"看看.

这样有时可以解决一些内存复制上的问题
发表于:2007-12-12 09:15:303楼 得分:0
编译的时候选择代码速度优先,不要选择p代码。
发表于:2007-12-12 22:01:334楼 得分:0
都是过了,还是不行啊!!急死,明天就要去给客户安装了!!那位给详细讲讲???????
万谢!!!!!!!!!!!!!!
发表于:2007-12-12 22:51:335楼 得分:0
有可能是不同的函数使用相同的系统资源的问题,在适当地方加延时或用doevents
发表于: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


快速检索

最新资讯
热门点击