C# 图片转为Base64
标签:raw for class 图片 efi ima img stat osi
///
/// 图片转Base64
///
/// 图片的完整路径
///
public static string ImgToBase64(string ImageFileName)
{
try
{
Bitmap bmp = new Bitmap(ImageFileName);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception)
{
return null;
}
}
C# 图片转为Base64
标签:raw for class 图片 efi ima img stat osi
原文地址:https://www.cnblogs.com/flamegreat/p/12195742.html
评论