I use to store image in bytes and able to convert it to system.drawing.image but not sure how to render it on page
Thanks
You can create ASPX page that will return image file as byte array with appropriate headers information, to get image you will be able to call this page like imagemanager.aspx?imgid=31337
Then in your main page in system.web.ui.webcontrols.image
control set ImageUrl
property to your script path:
ctrlImage.ImageUrl = "imagemanager.aspx?imgid=31337";
Here is example of method to output you image in imagemanager.aspx:
private void TransmitBytes(byte[] bytes, string outFileName)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + outFileName);
Response.AddHeader("Content-Length", bytes.Length.ToString());
Response.ContentType = "image/jpeg";
Response.BinaryWrite(bytes);
Response.End();
}
System.Drawing.Image
represents image or picture that you can render, print, save to file, resize, create thumbnail from etc. But System.Web.UI.WebControls.Image
is a web control that you can use to show images on web pages.
To show dynamically created image on webpage you need some handler
or other mechanism that sends image to calling page.
Here is an article on 4guysfromrolla that explains this concept.
Here is another one on developerfusion.com in C#
I found this very detailed article on MSDN by Scott Mitchel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With