Code Snippet
  1. public string ImageToBase64(Image image,
  2.   System.Drawing.Imaging.ImageFormat format)
  3. {
  4.   using (MemoryStream ms = new MemoryStream())
  5.   {
  6.     // Convert Image to byte[]
  7.     image.Save(ms, format);
  8.     byte[] imageBytes = ms.ToArray();
  9.     // Convert byte[] to Base64 String
  10.     string base64String = Convert.ToBase64String(imageBytes);
  11.     return base64String;
  12.   }
  13. }
<!>