gpt4 book ai didi

c# - 如何将类型'string'转换为system.drawing.image

转载 作者:搜寻专家 更新时间:2023-10-30 23:43:41 26 4
gpt4 key购买 nike

我只想像其他数据一样从数据库中获取图像到图片框中。我该怎么做?

private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
//shows the data on fields if click on the entries
//on sequence in which the query is

IDtxt.Text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
NAMEtxt.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
F_Nametxt.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
BLOODc_box .Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
CNICtxt .Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();

GENDERc_box .Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
CONTACTtxt.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
JOBtitleText.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
SALARYtxt.Text = dataGridView1.SelectedRows[0].Cells[8].Value.ToString();
ADDRESStxt.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
AGEtxt .Text = dataGridView1.SelectedRows[0].Cells[10].Value.ToString();
pictureBox1 .Image = dataGridView1.SelectedRows[0].Cells[11].Value.ToString();

}

最佳答案

如果你有 base64 字符串,那么试试这个

var image = GetImage("yourBase64String");

public Image GetImage(string value)
{
byte[] bytes = Convert.FromBase64String(value);
Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
}
return image;
}

关于c# - 如何将类型'string'转换为system.drawing.image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872057/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com