C# 常用方法——base64字符串转图片

其他常用方法详见:https://www.cnblogs.com/zhuanjiao/p/12060937.html

         /// <summary>
		/// base64编码的文本转为图片
		/// </summary>
		/// <param name="base64Str"></param>
		/// <param name="savePath"></param>
		public MemoryStream Base64StringToImage(string base64Str)
		{
			try
			{
				//将base64头部信息替换
				base64Str = base64Str.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "")
					.Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");
				byte[] arr = Convert.FromBase64String(base64Str);
				using (MemoryStream ms = new MemoryStream(arr))
				{
					return ms;
				}
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}

  

C# 常用方法——base64字符串转图片

上一篇:easyui 弹出框\windows弹窗 确定和右上角x关闭按钮点击事件


下一篇:C# DataTable和DataRelation