是这样的,最近我正在用.NET做一个摄像头的捕获,从网上获得了一个开源的类可以捕获摄像头
我试验过了 也没问题,但是他的捕获是将一个 PICTUREBOX的句柄传过去 然后那个图片框就有我当前的图像了、、
我尝试 PictureBox.Image 居然说我的Image 为 null
虽然它有自带的截图方法,是通过SENDMESSAGE --> API 发送消息的
但是我感觉不好。。我的问题是 请问什么办法能我只通过我的PictureBox.Handle来获得这个PictureBox中正在显示的图像呢?
谢谢 !!

解决方案 »

  1.   

    这个PictureBox是你程序的还是别的程序的?
    都开源了,直接使用源代码了
      

  2.   

    你想把PictureBox的图片保存起来?
      

  3.   

    Graphics graph=new Graphics(); graph=Graphics.FromHwnd(pictureBox.Handle); 
      

  4.   

           private void button1_Click(object sender, EventArgs e)
            {
                Image img = (Image)pictureBox1.Image;
                img.Save("c:\\ssssss.jpg");
            }
      

  5.   

    JeffChung 兄 你那个方法我尝试过了 得到的IMAGE 是空的ZengHD 兄 看我的问题 我的 PictrueBox.Image 都是空了 还怎么保存?
      

  6.   

    PictrueBox里有图片但PictrueBox.Image为空??
    怎么弄出来的?
      

  7.   

    我的摄像头捕获程序 是 capCreateCaptureWindowA API弄出来的
    你们不信可以加我QQ 我给你们程序 你们试试看
    能看到图像 但是PICTUREBOX.Image 的确是null
      

  8.   

    可能PictureBox上的图像不是被设置到Image属性上,而是在Paint方法中直接画出来的
    所以PictureBox的Image属性为nullLZ有没有试过PictureBox的DrawToBitmap方法的?
    public void DrawToBitmap(
        Bitmap bitmap,
        Rectangle targetBounds
    )
      

  9.   

    定义一个函数GrabImage,点击保存按钮时直接保存。 
    public void GrabImage(IntPtr hWndC, string path)
            {
                IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
                VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SAVEDIB, 0, hBmp.ToInt32());
            }   private void btnPz_Click(object sender, EventArgs e)
            {
                video.GrabImage(pictureBox1.Handle, "d:\\a.bmp");
            }