如何在C#中将Base64 PNG图像字符串转换为PNG格式
问题描述:
可能重复:
将基本的64字符串转换为图像并保存它
我有一个编码为Base64字符串的PNG图像。我需要将此字符串转换为PNG格式。
I have a PNG image encoded as a Base64 string. I need to convert this string into PNG format. How can I convert this in C#?
答
using Convert=System.Convert;
using MemoryStream=System.IO.MemoryStream;
using Image=System.Drawing.Image;
//...
byte[] data = Convert.FromBase64String(base64String);
using(var stream = new MemoryStream(data, 0, data.Length))
{
Image image = Image.FromStream(stream);
//TODO: do something with image
}