Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stream dynamic image directly to web page? 2

Status
Not open for further replies.

joelwenzel

Programmer
Jun 28, 2002
448
Hi,

I am creating an image via code during runtime. I need to display this image on my webpage. One way to do this would be to save the image to a file, and then have an image object reference the file. However, the page gets updated constantly and tons of images would be generated.

so, what I really need is a way to directly stream the image i create to an image object. How do I do this?
 
joelwenzel - I use a third party package for creating chart images (ChartDirector - They have two mechanisms for handling the chart image which is referenced by the img tag (1) create the image and send to the rendered page (so 2 round trips to the server, the aspx page and then the page's reference to the bitstream which is credated within a dll, and (2) put the image in a Session and call the Session object. Just a couple of ideas - haven't worked directly in dot NET to create the image.
 
joe: If it turns out that streaming the image object is what you are after here are a few links which discuss in some detail the process:

.NET Streams Explained


ShowImage - Output an image as a binary stream to the Response object

Creating Images on the Fly with ASP.NET - Drawing the graphics

Binary streaming of large images from Database


Using the OutputStream method

..thought perhaps you may gain some further insight here.
 
Yeah, as those links that Isadore posted will no doubt show, the overloaded Bitmap.Save method can save the image to a stream and therefore you can save it directly to the Response.OutputStream.

Here's the example from the help file:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
those resources were very good. I can now stream directly to a browser window. However, I would really like to be able to stream to an Webcontrol.Image object so that I can have other stuff on the page as well, besides images.

Is such a thing possible? From what i can tell, it isn't. It looks like I would have to same a temp copy of the file.
 
I don't believe you can do that. The Response.OutputStream will expect a certain type of stream (i.e. text, jpg, gif etc) and you won't be able to mix those.

I guess you'll have to save it as a temp file and have a clean up routine for those files.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm: There is the other option of putting the object into Session - just a thought (ChartDirector takes advantage of this).
 
How do you then load the session object into an image control as the ImageUrl property only accepts a file path string (not an image object)?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
If I put it in a session, can I do something like

<img src=<%# Session("File") %> >

So that I can place the image and other controls?
 
No, you can't do that (which is why I also asked the question as, as far as I know, an Image control get's it's image from a physical file nto a stream).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ok..that's what I thought. Thanks for your help eveyone. Guess I better create a temp file afterall
 
Thanks ca8msm - I posted that option as it was a technique used by ChartDirector as an alternative to creating a temporary file and saving it to a temporary directory. I also use ASPMap, which too has the option of either saving an image to a temporary directory or placing it in Session and then streaming it directly to the client form there (of course this occurs within their dll files - haven't had experience directly with dot NET on this).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top