调用笔记本摄像头,图像没有显示
drawdibdraw(hd,bitmap.canvas.handle,0,0,bmpinfo.bmiheader.biwidth div 2 ,bmpinfo.bmiheader.biheight div 2,@bmpinfo.bmiheader,lpvhdr^.lpdata,0,0,bmpinfo.bmiheader.biwidth div 2,bmpinfo.bmiheader.biheight div 2,0);

把bitmap.canvas.handle换成capwnd2(panel2.handle),可以显示.几分钟后出错。‘out of memory’.procedure TForm1.Button3Click(Sender: TObject);
begin
capwnd2:=getdc(panel2.Handle;)
end;急等解决。。,请大侠指点

解决方案 »

  1.   

    这个程序function framecallback(hwnd: hwnd; lpvhdr: pvideohdr): longint;stdcall;
    var hd:thandle;
    jpg:tjpegimage;
    memstream :tmemorystream;
    bitmap:tbitmap;
    begin bitmap:=tbitmap.create;
    bitmap.width :=bmpinfo.bmiheader.biwidth;
     // new size of bitmap
    bitmap.height:=bmpinfo.bmiheader.biheight;
    hd:= drawdibopen;
    //drawdibdraw(hd,bitmap.canvas.handle,0,0,bmpinfo.bmiheader.biwidth div 2 ,bmpinfo.bmiheader.biheight div 2,@bmpinfo.bmiheader,lpvhdr^.lpdata,0,0,bmpinfo.bmiheader.biwidth div 2,bmpinfo.bmiheader.biheight div 2,0);
    drawdibdraw(hd,capwnd2,0,0,bmpinfo.bmiheader.biwidth,bmpinfo.bmiheader.biheight,@bmpinfo.bmiheader,lpvhdr^.lpdata,0,0,bmpinfo.bmiheader.biwidth,bmpinfo.bmiheader.biheight,0);
    drawdibclose(hd);
    //deletedc(capwnd2);
    //releasedc(capwnd2,capwnd22);
    //·¢ËÍÊý¾Ý
    {memstream := tmemorystream.create;
    jpg := tjpegimage.create; jpg.assign(bitmap);
    jpg.compressionquality := 10;
    jpg.jpegneeded;
    jpg.compress;
    jpg.savetostream(memstream);
    jpg.free;
    form1.idudpclient1.broadcastenabled:=true;
    if memstream.size>form1.idudpclient1.buffersize then
    form1.idudpclient1.sendbuffer('192.168.0.255',9001,memstream.memory^,form1.idudpclient1.buffersize)
    else
    form1.idudpclient1.sendbuffer('192.168.0.255',9001,memstream.memory^,memstream.size);
    memstream.free;  }
    bitmap.free;
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    capwnd := capcreatecapturewindow('MY', ws_visible or ws_child,//
    0, //
    0, //
    panel1.width, //
    panel1.height, //
    panel1.handle, //
    0); //
    if capwnd = 0 then exit; 
    capsetcallbackonframe(capwnd,@framecallback);
    capparms.dwrequestmicrosecperframe:=1;
    capparms.flimitenabled:=false;
    capparms.fcaptureaudio:=false;
    capparms.fmcicontrol:=false;
    capparms.fyield:=true;
    capparms.vkeyabort:=vk_escape;
    capparms.fabortleftmouse:=false;
    capparms.fabortrightmouse:=false; //
    capcapturesetsetup(capwnd,@capparms,sizeof(tcaptureparms));
    cappreviewrate(capwnd,33); //
    capcapturesequencenofile(capwnd); //
    capdriverconnect(capwnd,0); //
    capgetvideoformat(capwnd, @bmpinfo,sizeof(tbitmapinfo)); 
    cappreviewscale(capwnd,true); 
    capoverlay(capwnd,true); //
    cappreview(capwnd,true);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
    capcaptureabort(capwnd); //
    capdriverdisconnect(capwnd); //
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
    capwnd2:=getdc(panel2.Handle;)
    end;
      

  2.   

    drawdibdraw(hd,bitmap.canvas.handle,0,0,bmpinfo.bmiheader.biwidth div 2 ,bmpinfo.bmiheader.biheight div 2,@bmpinfo.bmiheader,lpvhdr^.lpdata,0,0,bmpinfo.bmiheader.biwidth div 2,bmpinfo.bmiheader.biheight div 2,0);
     这个怎么显示不笔记本自带的摄像头图像呢