Assuming you have a byte array:
byte[] imageBackground = new byte[] { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,... };
you could create an Image
:
using (var stream = new MemoryStream(imageBackground))
using (var image = Image.FromStream(stream))
{
// do something with the image
}
or if you wanted to display it on an ASP.NET web form, inside an Image
control, you could write a generic handler that will stream this image to the response:
public class ImageHandler : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
var response = context.Response;
byte[] imageBackground = new byte[] { 137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,... };
response.OutputStream.Write(imageBackground, 0, imageBackground.Length);
response.ContentType = "image/jpeg";
}
}
and then point the Image control to this generic handler:
<asp:Image runat="server" ID="myimage" ImageUrl="~/imagehandler.ashx" />