gpt4 book ai didi

c# - 将 Base64 字符串转换为位图或图像 Xamarin 或 Android

转载 作者:太空宇宙 更新时间:2023-11-03 11:42:34 25 4
gpt4 key购买 nike

<分区>

我正在尝试将 Base64 字符串转换为图像并使用同一图像设置 ImageView。我知道如何用 Java 完成它,但我在 C# 中遇到了麻烦。任何人都知道如何在 C# 中完成它?

我试过的一些代码;

public Image Base64ToImage(string base64String)
{
// Convert base 64 string to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
// Convert byte[] to Image
using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
{
Image image = Image.FromStream(ms, true);
return image;
}
}

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