How to convert system.drawing.image to system.web.ui.webcontrols.image

I use to store the image in bytes and can convert it to system.drawing.image, but not sure how to make it on the page

thank

+5
source share
2 answers

You can create an ASPX page that will return an image file as an array of bytes with the corresponding header information, to get the image, you can call this page, for example imagemanager.aspx?imgid=31337

Then, on the main page in, system.web.ui.webcontrols.imageset the ImageUrlproperty set to your script path:

ctrlImage.ImageUrl = "imagemanager.aspx?imgid=31337";

Here is an example method for displaying an 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();
    }
+5
source

Kamaal, System.Drawing.Image , , , , , .. System.Web.UI.WebControls.Image -, -.

-, handler , .

4guysfromrolla.com, .

developerfusion.com #

MSDN .

+3

All Articles