Remember that on thg client, its all HTML. The main point is that you need
an image tag that points to the ASPX page that generates the image. It
doesn't matter if that image tag is in a Control or any other element in an
ASPX page. And, of course, you can request the ASPX page that generates the
image all by itself, just as you would request an image from a web server
all by itself.
In other words, you treat the ASPX page that generates the image as if it
WERE an image, in whatever context you use it. To the browser, it will BE an
image, due to the Response.Conten tType.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Lars Netzel" <tr*****@apa.se > wrote in message
news:es******** ********@TK2MSF TNGP09.phx.gbl. ..
Do I need to have this in an Aspx page? Is there other ways to call for the
picture? I want to do this all in one class.
I guess the ContentType is pretty important but I'm wanting to do an output
from a WebControl that also generates the picture. That means I won't have
any aspx page avaliable.
/Lars
"John Puopolo" <jo**********@f astsearch.com.n ospam> skrev i meddelandet
news:OB******** ******@tk2msftn gp13.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.a spx">
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(objec t sender, System.EventArg s e) {
Bitmap objBitmap = new Bitmap(200, 200);
Graphics g = Graphics.FromIm age(objBitmap);
g.FillEllipse(B rushes.Red, 0, 0, 200, 200);
objBitmap.Save( Response.OutStr ean, 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" <tr*****@apa.se > wrote in message
news:%2******** *******@TK2MSFT NGP12.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