Custom WebControl - Rendering Images
-
I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.
-
I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.
What I had done is: set the "img source" to myPic.aspx then in myPic.aspx.cs in the Page_Load event, write to the output stream: "MIME=image/jpeg" // or something like that and then just write your image you draw to the stream as well. Bitmap bm; // draw to it bm.Save( Response ); // the response stream this works, i have done it before, but this is not exactly correct, can't remeber the exact words/code not sure of the correct form for MIME type, but look on google for MIME types or something. You can even pass parameters to yout myPic.aspx?lines=1,2,8,9 which could draw a line from 1,2 to 8,9 Or save the bmp in the Session and retreive it from the sesion when the client requests myPic.aspx, but i have not tried this session idea before. Hope that might help.
-
I am building a custom WebControl and I would like to render an image in that custom control. I have a solution but it is not the solution I would like. Currently I am saving my image as a file and writing an html "img source" tag pointing to that file at the time I am asked to render my control into the HtmlTextWriter. The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Is this possible?? Thanks.
Bob Scoverski wrote: The solution I would like is to be able to stream the image into the page so that I am not required to create an image file. Yes, I wrote an article on it here: Web Graphics On The Fly in ASP.NET[^]. Hope this helps. :) - Nick Parker
My Blog