Getting Bitmap from Base64String in C#

Use the following code for getting Bitmap from Base64String.

public Bitmap getBitmapFromBase64String(string base64Value)

{

Bitmap img = null;

byte[] imgData = Convert.FromBase64String(base64Value);

using (MemoryStream ms = new MemoryStream())

{

ms.Write(imgData, 0, imgData.Length);

img = (Bitmap)Image.FromStream(ms, true);

ms.Close();

ms.Dispose();

}

return img;

}


....S.VinothkumaR.

No comments: