|
|
|
@ -188,39 +188,6 @@ namespace Ems.CollectService.Common
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <param name="strbase64">64Base码</param>
|
|
|
|
|
/// <param name="path">保存路径</param>
|
|
|
|
|
/// <param name="filename">文件名称</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool Base64ToImage(string strbase64, string path, string filename)
|
|
|
|
|
{
|
|
|
|
|
bool Flag = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//base64编码的文本 转为 图片
|
|
|
|
|
//图片名称
|
|
|
|
|
byte[] arr = Convert.FromBase64String(strbase64);//将指定的字符串(它将二进制数据编码为 Base64 数字)转换为等效的 8 位无符号整数数组。
|
|
|
|
|
using (MemoryStream ms = new MemoryStream(arr))
|
|
|
|
|
{
|
|
|
|
|
Bitmap bmp = new Bitmap(ms);//加载图像
|
|
|
|
|
if (!Directory.Exists(path))//判断保存目录是否存在
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
}
|
|
|
|
|
bmp.Save((path + "\\" + filename + ".png"), System.Drawing.Imaging.ImageFormat.Png);//将图片以JPEG格式保存在指定目录(可以选择其他图片格式)
|
|
|
|
|
ms.Close();//关闭流并释放
|
|
|
|
|
if (File.Exists(path + "\\" + filename + ".png"))//判断是否存在
|
|
|
|
|
{
|
|
|
|
|
Flag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("图片保存失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return Flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取时间戳
|
|
|
|
|