C# .NET - Convert Base64 string to image

Asked By John Hey on 11-Oct-05 10:46 AM
Hi, 
I have a base64 string -----It was a jpeg image originally and that image was encoded with a PHP function to a base64 string and was saved in a text type field in SQL database--------
What I want to do is to take that string and decode/convert it to image again and show it in the webpage (images are company's logos)in C#
I just moved from PHP to C# and I couldn't find any way to do it.(almost newbie in C#)
I will appreciate if anyone help me with detail explanation to do it.
Thanks

Convert FromBase64String

Asked By Peter Bromberg on 11-Oct-05 10:50 AM
will return a byte array.
You can wrap this in a MemoryStream, and use one of the Image class overloaded methods such as .FromStream  to bring it into an Image object.

How to show image in web page

Asked By John Hey on 11-Oct-05 12:14 PM
I just found this code but i don't know what to do to show image.
public class Base64ToImage
{
public void ConvertThis(string ImageText)
{
if (ImageText.Length > 0)
{
Byte[] bitmapData = new Byte[ImageText.Length];
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();
	}
}//class
 help me please.

See this article

Asked By Peter Bromberg on 12-Oct-05 12:10 PM
http://www.eggheadcafe.com/articles/20050911.asp