Click here to Skip to main content
15,897,151 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi Dear All....


I have a byte array containing some data representing an image.(Profile Photo).
I would like to display the original image from this byte array. Could any one please tell me which control should I use here and how to convert this byte array to image and how to display this image on the aspx page..



Thank You All.....
Posted

1 solution

Converting is simple:
C#
using (MemoryStream stream = new MemoryStream(bytes))
{
    myImage = new Bitmap(stream);
}

Then just set the Image property of your control to myImage.
 
Share this answer
 
Comments
SubhashRokzzz 3-Mar-15 5:36am    
Hi OriginalGriff..

thank you for your help. Could you please explain. Which control should be used and how can i display this image on that control.?
OriginalGriff 3-Mar-15 6:05am    
Oh, right - I see...
Don't convert it to an Image at all.
Drop an Image control on your form, and then set the byte data as the URL:

myImage.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(bytes);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900