C# - Base64 编码的 JPEG 到 Base64 编码的 BMP

标签 c# base64

byte[] bytes = Convert.FromBase64String(in);
Image image = Image.FromStream(new MemoryStream(bytes));
MemoryStream objMS = new MemoryStream();
image.Save(objMS, System.Drawing.Imaging.ImageFormat.MemoryBmp);
string out = Convert.ToBase64String(objMS.ToArray())
objMS.Close();

上面的代码失败了,并出现了一条毫无用处的错误信息:

'Value cannot be null. Parameter name: encoder'

最佳答案

您不应该使用 ImageFormat.MemoryBmp,它仅用于表示内存中的位图。没有任何编码器可以将其保存为文件。

使用ImageFormat.Bmp

关于C# - Base64 编码的 JPEG 到 Base64 编码的 BMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12210738/

相关文章:

C# 应用程序 - 无法添加先决条件文件

c# - 将包含 base64 的字符串转换为有效的 base64 字符串

jquery - jquery json 的字符

c# - C# 中的对象事务

c# - 在 C# 中检测您的操作系统上安装了哪个版本的 IE?

c# - 错误 :Index (zero based) must be greater than or equal to zero and less than the size of the argument list

Java 8 Base64 流包装器吃掉最后两个字符?

c# - 将 excel 函数转换为 c# Math.pow 不会产生相同的值

java - BASE64Encoder 结果从 Windows 到 Unix 不同

css - CSS中的Base64?怎么看代码