gpt4 book ai didi

c# - 如何转换二进制图像并在 Repeater 中显示?

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:03 26 4
gpt4 key购买 nike

protected void rptProducts1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Image img = (Image)e.Item.FindControl("imgProduct");
if (img != null)
{
var Binary = img.ImageUrl;
img.ImageUrl = "data:image/png;base64," + (lstProductModel.Select(v => v.Picture = "" + Convert.ToBase64String(v.PictureBinary)));
}
}

错误是当我尝试将二进制图像格式转换为 base64string 时图像未显示。所以请帮我解决这个问题。谢谢和问候。

最佳答案

从sql server数据库中读取/检索以二进制形式存储的图像并显示在Repeater数据控件中

bytes = (byte[])dt.Rows[i]["BookPic"];
base64String = Convert.ToBase64String(bytes, 0, bytes.Length);

Image img = (Image)rptBooks.Controls[i].FindControl("ImgBookPic");
img.ImageUrl = "data:image/png;base64," + base64String;

点击http://www.webcodeexpert.com/2014/04/upload-and-save-image-in-binary-format.html

关于c# - 如何转换二进制图像并在 Repeater 中显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31428376/

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