Decoding Base64 Image
Use Convert.FromBase64String
to get a byte[]
representing the image binary.
You can then save the resulting byte[]
into a file.
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();
}
Scrape the embedded image into a string. Using WebClient
is probably your best bet. Convert the base64 string to a byte array using Convert.FromBase64String()
. Use a MemoryStream
and Image.FromStream()
to reconstitute an image object.