我具体的需求是这样的:我通过摄像头获得一幅图像,我通过点击获取头像按钮后,出现在image上一固定大的矩形方框,可以拖动此方框取得方框内的图像信息,然后保存下来,请问如何实现谢谢!

解决方案 »

  1.   

    给你一个抓成bmp的代码,要求图像未被遮拦。JPG格式的,自己在此基础上转换就是。
    当然你也可用硬件设备提供的API之类的抓图,这样无论图像是否被遮盖,都可取得正确的图。
    var
      ImageDir : string;
      bmpFileName : string;
      PicHWnd,iDC : LongWord;
    begin
      MainForm.WindowState := wsMaximized;  if ForceCreateImageDir(CapTime,ImageDir) then  
              //ForceCreateImageDir 是我自己写的一个创建目录的函数
      begin
        if not Assigned(VehBmp) then
        begin
          VehBmp := TBitmap.Create;
        end;    VehBmp.Width := pnlVehPic.Width;   //宽度与高度,现在应当由你的拖拉来实现了。
        VehBmp.Height := pnlVehPic.Height; //这里    PicHWnd := pnlVehPic.Handle;
        iDC:=GetDC(PicHWnd);    Bitblt(VehBmp.Canvas.Handle,0,0,VehBmp.Width,VehBmp.Height,
               iDC,0,0,SRCCOPY);
        ReleaseDC(PicHWnd,iDC);
             
        bmpFileName := SysSettings.ImageRoot+ '\tmpVeh.bmp';
        VehBmp.SaveToFile(bmpFileName);
    end;
      

  2.   

    看我BLOG中的文章:
    http://blog.csdn.net/xzhifei/archive/2007/07/17/1695258.aspx