Load Picture into PictureBox from base64 String
 
String ImageText = "blahblahblahblahblah==";
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));
pictureBox1.Image = bitImage;
 
private String FixBase64ForImage(String Image)
{
    try
    {
        System.Text.StringBuilder st = new System.Text.StringBuilder(Image, Image.Length); 
	st.Replace("rn", String.Empty); 
	st.Replace(" ", String.Empty); 
	return st.ToString();
    }
    catch (Exception ex)
    {
 	return "";
    }
}
Categories: C# Tags: , , , ,
%d bloggers like this: