捕获图像到图片框并传递给已经加载的表单。如何做到这一点? [英] Capturing image in to picture box and pass to already loaded form.how to do that?

查看:31
本文介绍了捕获图像到图片框并传递给已经加载的表单。如何做到这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含opwn网络摄像头按钮的配置文件创建表单,一旦我点击它将通过网络摄像头拍摄另一种形式picturebox.i需要将图片框图像传递给已经加载的form.with使用show()



我的尝试:



个人资料创建表单buttonLlick

I having profile creation form which contains opwn webcam button ,once i click it will take image via webcam in another form picturebox.i need to pass the picture box image to already loaded form.with using show()

What I have tried:

Profile creation form buttonclick

private void Button1_Click(object sender, EventArgs e)
      {
          ProfilepictureCapture imc = new ProfilepictureCapture();
          imc.ShowDialog(this);

          //ProfilepictureCapture pictureForm = new ProfilepictureCapture();
          //pictureForm.MyFirstForm = this;
          //pictureForm.Show();
      }



捕获图像表格btnclick


Capture image form btnclick

private void btnCapture_Click(object sender, EventArgs e)
       {
           pictureBox2.Image = imgVideo.Image;
       }

       private void btnok_Click(object sender, EventArgs e)
       {


           NewClient pictureSource=new NewClient();
           pictureSource.PBProfilePic.Image = this.pictureBox2.Image;

           this.Hide();
       }

推荐答案

因为每次单击Button1都会创建表单的新实例,所以不应该隐藏它 - 相反,转到ProfilepictureCapture表单,并将btnok按钮的DialogResult属性设置为DialogResult.OK

现在,当用户单击确定按钮时,表单将关闭,控件将返回到原始表格。

在ProfilepictureCapture表单中添加一个属性:

Because you create a new instance of the form each time you click Button1, you shouldn't Hide it - instead, go to the ProfilepictureCapture form, and set the DialogResult property of the btnok button to DialogResult.OK
Now, when the user clicks the OK button, the form will close and control will return to the original form.
Add a property to the ProfilepictureCapture form:
public Image ProfilePic
   {
   get { return pictureBox2.Image; }
   }

然后在您的呼叫表单中使用该属性:

And then use that property in your calling form:

private void Button1_Click(object sender, EventArgs e)
      {
          ProfilepictureCapture imc = new ProfilepictureCapture();
          if (imc.ShowDialog(this) == DiralogResult.OK)
          {
              Image myPicture = imc.ProfilePic;
              ...
          }
      }


这篇关于捕获图像到图片框并传递给已经加载的表单。如何做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆