473,569 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can you render and image in ASP.NET?

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
Nov 19 '05 #1
9 1479
What do you mean? The browser renders the images, the server just provides
the path in the form of HTML.

"Lars Netzel" <tr*****@apa.se > wrote in message
news:#p******** *****@TK2MSFTNG P12.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

Nov 19 '05 #2
No I mean dynamically creating images.. for example images that needs
language support and stuff like that. I heared a long time ago abot usoem
GIF creator that was part of .NET but I've never seen it...

/lars
"Peter Rilling" <pe***@nospam.r illing.net> skrev i meddelandet
news:er******** ******@TK2MSFTN GP12.phx.gbl...
What do you mean? The browser renders the images, the server just
provides
the path in the form of HTML.

"Lars Netzel" <tr*****@apa.se > wrote in message
news:#p******** *****@TK2MSFTNG P12.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


Nov 19 '05 #3
> Is there any possibility to render images for the web in asp.net?

Yup.
Is it hard?
Not for me. Probably for some people. I can't speak for them.
Is there something built in or do I need external commercial components?
Everything you need is in the CLR. The System.Drawing and
System.Drawing. Imaging namespaces contain all the functionality you need,
combined with, of course, ASP.Net classes.

The first thing you need to do is define what you want to render. If you
want to open an image from a file, or if you want to draw one dynamically.

You would need to create an ASPX page that serves as the "image." You would
link to it as you would any other image, with an HTML image tag. The ASPX
page then creates the image (however), sets the Response.Conten tType to
"image/jpg" (or whatever image type you're returning), and then saves the
image to the Response.Output Stream.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"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

Nov 19 '05 #4
Hi Lars,

There's lots you can do with System.Graphics to create images in memory in
ASP.NET:

http://aspalliance.com/articleViewer.aspx?aId=400&pId=1

http://authors.aspalliance.com/chris...agecounter.asp

Ken

"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


Nov 19 '05 #5
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

Nov 19 '05 #6
Nice, thanx!

/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


Nov 19 '05 #7
Thank you, that example got me started quite fast... great!

/Lars
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Hi Lars,

There's lots you can do with System.Graphics to create images in memory in
ASP.NET:

http://aspalliance.com/articleViewer.aspx?aId=400&pId=1

http://authors.aspalliance.com/chris...agecounter.asp

Ken

"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

Nov 19 '05 #8
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

Nov 19 '05 #9
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

Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2529
by: Leif K-Brooks | last post by:
I'm considering writing a fairly basic vector drawing program using PyGTK. What's the best way to render it? What I'm thinking of is having everything render on a PIL image, then display that in the GTK window or save it depending on what's being done. Is that the best strategy? Will it be fast enough?
4
3166
by: lkrubner | last post by:
I'd like to write a PHP script to be used from the command line on a Unix machine. I'd like for the script to put together a string, turn it into a web page, print it, then return control the command line. Obviously it is quite easy to make a string that is valid HTML and send it to the printer. The tough part is making look like a web page....
2
1429
by: Jeronimo Bertran | last post by:
I have an aspx page that shows a complex image with several objects that are sensitive to mouseover events. The information about the objects in the image is obtained from a database and complex calculations are performed for each object to determine the position within the image. To render the image I created an aspx page that uses the...
5
2647
by: localhost | last post by:
I have a custom TrueType .ttf font in the filesystem (not installed) on the web server. I want to take the letter "A" from this font, render it as an image, and return that as a byte stream in a web page. How can I do that? Thanks.
4
1773
by: André | last post by:
Hi, I try to create and render a graphic among other objects like e.g. tables, labels, buttons. The tables are not a problem, neither the graphic. My problem is that i can't render both together. With the code below, i only see the graphic, nothing else (no table, label, button). How can i see the table and below the table, the graphic?
1
2230
by: | last post by:
I've built an application that scrapes JPG images of webpages and PDF instances of those webpages automatically from an RSS feed. References to the scraped resources are persisted to our database. I've also built an administrative interface that allows someone to scroll through a datalist of the JPG images of the page and to delete the...
8
4046
by: Edward Diener | last post by:
Is there a way in Javascript, or perhaps in HTML, to force a browser to re-render an image on an HTML page after a round-trip between the client and the server ? In my particular case, the image is changing on the server although the URL for it remains the same, but the browser is still displaying the old image from its cache rather than...
2
1920
by: =?Utf-8?B?UmljaA==?= | last post by:
On my development machine where I have Visual Studio 2005 loaded, I have an app that uses the Report control. I can view data in report format with the Report control -- the data renders OK in the Report control. My problem is in rendering the report from the rdlc file for printing to a line printer. Following the example from MSDN Help at...
4
2450
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I suspect some permissions problem. I'm running VS.NET 2008 in Vista. Symptoms and observations: * ASP.NET's native ImageMap and Image controls work...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.