public static string ImageToBase64(string fileFullName)
{
try
{
Bitmap bmp = new Bitmap(fileFullName);
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();
return Convert.ToBase64String(arr);
}
catch (Exception ex)
{
return null;
}
}
public static LinkedResource GetEmbeddedImage(String filePath, string contentId)
{
LinkedResource res = new LinkedResource(Path.Combine(filePath), MediaTypeNames.Image.Jpeg);
res.ContentId = contentId;
res.TransferEncoding = TransferEncoding.Base64;
return res;
}