将图像添加到资源文件

时间:2020-02-20 16:45:07

标签: c# image winforms

我有一个图片框,在其中显示图像,但是找不到将其保存在资源中的方法。

到目前为止,这是我的代码:

private void imgContact_Click(object sender, EventArgs e)
{
    // open file dialog   
    OpenFileDialog open = new OpenFileDialog();
    // image filters  
    open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
    if (open.ShowDialog() == DialogResult.OK)
    {
        // display image in picture box  
        imgContact.Image = new Bitmap(open.FileName);
        // image file path  
        string imagePath = open.FileName;
     }
}

0 个答案:

没有答案