C# 图片和Base64之间的转换

public static Bitmap GetImageFromBase64String(string strBase)
{
  try
  {
    MemoryStream stream = new MemoryStream(Convert.FromBase64String(strBase));
    Bitmap bitmap = new Bitmap(stream);
    return bitmap;
  }
  catch(Exception ex)
  {
  return null;
  }

}

public static string GetBase64StringFromImage(Image image, ImageFormat imageFormat)
{
  string strRst = string.Empty;
  try
  {
    MemoryStream stream = new MemoryStream();
    image.Save(stream, imageFormat);
    strRst = Convert.ToBase64String(stream.GetBuffer());
  }
  catch (Exception ex)
  {}
return strRst;
}

原文地址:https://www.cnblogs.com/SuperMetalMax/p/6186448.html