You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
882 B
32 lines
882 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ShenTun.IcCard.Common
|
|
{
|
|
public class ImageHelper
|
|
{
|
|
public static string ToBase64(Bitmap bmp, System.Drawing.Imaging.ImageFormat format)
|
|
{
|
|
try
|
|
{
|
|
MemoryStream ms = new MemoryStream();
|
|
bmp.Save(ms, format);
|
|
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;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception("ImgToBase64String 转换失败 Exception:" + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|