部分代码实例
代码语言:javascript复制 public static string ImageToBase641(string filePath)
{
try
{
Bitmap bmp = new Bitmap(filePath);
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 ex)
{
TLog.Error(ex);
return null;
}
}
点我下载