public string ImageToBase64(Image myImage) { byte[] data; WriteableBitmap bmp = new WriteableBitmap((BitmapSource)myImage.Source); using (MemoryStream stream = new MemoryStream()) { bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100); data = new byte[stream.Length]; // Read the entire file and then close it stream.Read(data, 0, data.Length); stream.Close(); } string base64 = System.Convert.ToBase64String(data); return base64; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)