Re: Can you render and image in ASP.NET?
From: Lars Netzel (troligt_at_apa.se)
Date: 01/05/05
- Next message: Lars Netzel: "Re: datagrid design question"
- Previous message: Chad Devine: "Re: Font size in DropdownList"
- In reply to: John Puopolo: "Re: Can you render and image in ASP.NET?"
- Next in thread: Lars Netzel: "follow up question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 5 Jan 2005 23:07:55 +0100
Nice, thanx!
/Lars
"John Puopolo" <john.puopolo@fastsearch.com.nospam> skrev i meddelandet
news:OBfsDG38EHA.3700@tk2msftngp13.phx.gbl...
Hi...
Yes, you can create an image dynamically in ASP.NET. It's fairly straight
forward as well.
The idea is to create an image in memory on the server and stream it back to
the client (browser). Now, *if* you were to write that image to disk, you
could insert an <img> tag in the output stream and provide a link back to
the newly created image that you saved off; however, since you want to send
the image bytes back to the browser, you will need an <img> tag in the page
HTML whose source is the ASPX page that constructs the image. For example:
<html>
This is some text.
<img src="genImage.aspx">
Isn't that a pretty picture?
</html>
Now, the genImage.aspx code simply uses the System.Drawing, etc. to render
an image. Here is a simple example from a sample project I have:
>From genImage.aspx:
private void Page_Load(object sender, System.EventArgs e) {
Bitmap objBitmap = new Bitmap(200, 200);
Graphics g = Graphics.FromImage(objBitmap);
g.FillEllipse(Brushes.Red, 0, 0, 200, 200);
objBitmap.Save(Response.OutStrean, ImageFormat.Gif);
}
That's it. You have the full power of the .NET drawing and image libraries
at your disposal and can generate as complex an image as you can dream up.
Enjoy...
John Puopolo
"Lars Netzel" <troligt@apa.se> wrote in message
news:%23p1QcI28EHA.208@TK2MSFTNGP12.phx.gbl...
> Hey!
>
> Is there any possibility to render images for the web in asp.net? Is it
> hard? Is there something built in or do I need external commercial
> components?
>
> best regards
> /Lars
>
>
- Next message: Lars Netzel: "Re: datagrid design question"
- Previous message: Chad Devine: "Re: Font size in DropdownList"
- In reply to: John Puopolo: "Re: Can you render and image in ASP.NET?"
- Next in thread: Lars Netzel: "follow up question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|