I\'m developing an Android App that should send an image to my ASP.NET Web Service where the image will be saved as a file. I\'ve seen a couple of ways to do this and I went for
Seems like there is something iffy with your conversion from string to image. Also you are not disposing your stream which will leak memory.
Try this instead:
private Image Base64ToImage(string base64String)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
using (var ms = new MemoryStream(imageBytes, 0,
imageBytes.Length))
{
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
}
}