I have got a Base64 image in an HTML embedded, how can I decode this using C# or VB.net.
google.com > base64 image decode c# > http://www.eggheadcafe.com/community/aspnet/2/39033/convert-base64-string-to-image.aspx
Byte[] bitmapData = Convert.FromBase64String(FixBase64ForImage(ImageText));
System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));
public string FixBase64ForImage(string Image) {
System.Text.StringBuilder sbText = new System.Text.StringBuilder(Image,Image.Length);
sbText.Replace("\r\n", String.Empty); sbText.Replace(" ", String.Empty);
return sbText.ToString();
}
Use Convert.FromBase64String
to get a byte[]
representing the image binary.
You can then save the resulting byte[]
into a file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With