Decode Base64 Byte Array for Image in C #

I am making a small app in android that views an image from a gallery or takes pictures from a camera. Then the selected image is compressed and uploaded to the server. I have compressed an image using Base64 String in android and for loading the image I am making a web service in ASP.NET. But I'm not sure how to decode the string (converted with Base64 in android) into an image (the web service should be able to convert it). Please help me.

Thank you in advance

+3


source to share


1 answer


You can convert base64string to Image.FromStream . First you need to convert the base64string to a stream.



byte[] imageBytes = Convert.FromBase64String(imgBase64String);
Image img = null;

using (MemoryStream ms1 = new MemoryStream(imageBytes))
{
     img = Image.FromStream(ms1);
}

if (img != null)
{
  // ...
}

      

+4


source







All Articles