如何在C#中将Base64 PNG图像字符串转换为PNG格式 [英] How to convert a Base64 PNG image string to PNG Format in C#

查看:607
本文介绍了如何在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
}

这篇关于如何在C#中将Base64 PNG图像字符串转换为PNG格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆