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();
The code above fails with a very unhelpful error message:
'Value cannot be null. Parameter name: encoder'
You shoudn’t use
ImageFormat.MemoryBmp, that’s only for representing bitmaps in memory. There isn’t any encoder for saving that as a file.Use
ImageFormat.Bmp.