I've figured out how to create an image on the fly on my Website. Once
created, I write the image to the page using code like this:
Bitmap bm = [...]
[...]
Response.ContentType = "image/jpeg";
bm.Save(Response.OutputStream, ImageFormat.Jpeg);
The code I have does indeed display the graphic, but the page shows nothing
else. I need to write the image to a location within my Web page.
My preference would be to create a Web control, that I can embed in the
page, and then write the image from the control. However, the control's
Render handler provides an HtmlTextWriter argument, which does not have an
OutputStream property.
How can I output the graphic as the control's output?
Thanks.
Jonathan
nick chan - 26 May 2008 07:09 GMT
your control needs to output an Image location as a string
then, another page will actually load the image
u can either create another aspx page, or read up about ashx/axd
> I've figured out how to create an image on the fly on my Website. Once
> created, I write the image to the page using code like this:
[quoted text clipped - 17 lines]
>
> Jonathan
marss - 26 May 2008 08:04 GMT
> How can I output the graphic as the control's output?
1. Add new Generic Handler to the project. Name it, for example,
"Handler1".
2. Put the code for image creation inside of ProcessRequest method.
void ProcessRequest(HttpContext context)
{
//create image
Bitmap bm = [...]
[...]
context.Response.ContentType = "image/jpeg";
bm.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
3.Use it as an ordinary image url
<asp:Image ImageUrl="~/Handler1.ashx" ...
Regards,
Mykola
http://marss.co.ua - Casual ideas for web development
Jonathan Wood - 27 May 2008 05:09 GMT
Wow. New stuff for me. Will take me a while to figure it all out but looks
interesting. Thanks!
Jonathan
>> How can I output the graphic as the control's output?
>
[quoted text clipped - 17 lines]
> Mykola
> http://marss.co.ua - Casual ideas for web development
Munna - 27 May 2008 06:29 GMT
> Wow. New stuff for me. Will take me a while to figure it all out but looks
> interesting. Thanks!
[quoted text clipped - 22 lines]
> > Mykola
> >http://marss.co.ua- Casual ideas for web development
Hi
here is few links about dynamic image display that will help you kick
start
http://www.sitepoint.com/article/generating-asp-net-images-fly
http://aspalliance.com/articleViewer.aspx?aId=141&pId=
Best of luck
Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com