PlaceHolder Image  
Author Message
iGNiTe





PostPosted: Visual C# General, PlaceHolder Image Top

I've created a byte array:
byte[] bytePic = (byte[]) chartSpaceName.GetPicture("gif", 600, 300);

I'm wondering how to put this on my webpage without having to save it as a .gif file.
The byte array is created dynamically so it will always be different so I made a placeholder.

I'm not really sure what to do from there on...

I know I could do:
PlaceHolder.Controls.Add(new LiteralControl(strPath));

but that involves saving the gif file.

Any ideas



Visual C#5  
 
 
PJ. van de Sande





PostPosted: Visual C# General, PlaceHolder Image Top

Welcome to the MSDN Forums, this forum is not reserved for ASP.NET related question. We've got forums.asp.net for those question. Unfortunatly I'll give it a try to help you.

You should create on page that can give dynamicly generated images. The code below gets an Image and pushes it through the output stream:

Please let me know whenever you need more information!


false" Explicit="true" aspcompat="true" Debug="true" %>







 
<script runat="server">
 private void Page_Load(object sender, System.EventArgs e)
 {
     ChartSpaceName chartSpaceName = new ChartSpaceName();
     byte[] bytePic = (byte[]) chartSpaceName.GetPicture("gif", 600, 300);
     using( MemoryStream memStream = new MemoryStream(bytePic) )
     {
         MemoryStream memStream = new MemoryStream();
         Response.Clear();
         Response.ContentType="image/gif";
         memStream.WriteTo(Response.OutputStream);
    }
 }
</script>

 



 
 
iGNiTe





PostPosted: Visual C# General, PlaceHolder Image Top

Perfect, thank you!