by
0
7
205k
1
Top 1% !
Popular
Pearl of Wisdom
Easy-to-find
Specified
Refined
OpenSource
Popularity: 7774th place
Created
Modified Oct 23, 2015
.NETFramework4.5
Architecturex86_64
Extension.cs
InputName0OriginalImage
InputType0System.Drawing.Image
LanguageCSharp
MethodNametoBase64
OutputTypestring

Image toBase64 String

Extension method to convert a System.Drawing.Image to Base64 String
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/720021/Image-toBase64-String?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static string toBase64(this System.Drawing.Image OriginalImage) { using (MemoryStream ms = new MemoryStream()) { OriginalImage.Save(ms, OriginalImage.RawFormat); byte[] imageBytes = ms.ToArray(); return Convert.ToBase64String(imageBytes); } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus