/// <summary>
/// base64轉圖片
/// </summary>
/// <param name="strBase64"></param>
/// <param name="pathName"></param>
public static void Base64StringToImage(string strBase64,string pathName )
{
String inputStr = strBase64;
byte[] arr = Convert.FromBase64String(inputStr);
MemoryStream ms = new MemoryStream(arr);
Bitmap bmp = new Bitmap(ms);
bmp.Save(pathName, ImageFormat.Png);
ms.Close();
}
/// <summary>
/// 圖片轉base64
/// </summary>
/// <param name="Imagefilename"></param>
/// <returns></returns>
//圖片 轉為 base64編碼的文本
public static string ImgToBase64String(string Imagefilename)
{
Bitmap bmp = new Bitmap(Imagefilename);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
String strbaser64 = Convert.ToBase64String(arr);
return strbaser64;
}