Is it possible that I can send image data from server side to client using JSON format and assign that data into image control.
if yes, then How??
Thanks...
Image Transfer Using JSON
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Dec 13, 2013, 6:55 AM EST
Yes, you can, but as a string. The below method converts the image bytes to string.
private string CreateBase64Image(byte[] fileBytes)
{
Image streamImage;
using (MemoryStream ms = new MemoryStream(fileBytes))
{
streamImage = ScaleImage(Image.FromStream(ms));
}
using (MemoryStream ms = new MemoryStream())
{
streamImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
return Convert.ToBase64String(ms.ToArray());
}
}
And in client side,
$('#image1').attr('src', 'data:image/png;base64,' + imageString);