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

Home Posts Topics Members FAQ

how to create a gif or png dynamicaly in .aspx and return in response?

how to create a gif or png dynamicaly in .aspx and return in response?
Nov 17 '05 #1
2 2174
> how to create a gif or png dynamicaly in .aspx and return in response?


Hi Daniel,

You can create a graphics from bmp on the fly and after modifying the
graphics obtained you can render it to Response.Output Stream.

This stream will be directly served to requesting browser. You can also
display this image on any HTML using standard <img> tag. Provide the web
accessible path of this image rendering page in src elemnet of the <img> tag
and your image will be shown with the HTML output by browser.

Sample code snippet:
<CODE>
Bitmap bmp = new Bitmap(200, 100);
Graphics gr = Graphics.FromIm age(bmp);
gr.Clear(Color. WhiteSmoke);
gr.DrawString(" Test String", new Font("Arial", 12), Brushes.Blue, 10, 10);
bmp.Save(Respon se.OutputStream , ImageFormat.Jpe g);
gr.Dispose();
bmp.Dispose();
Response.End();
</CODE>
Nov 17 '05 #2
"Rahul Anand" wrote:
how to create a gif or png dynamicaly in .aspx and return in response?


Hi Daniel,

You can create a graphics from bmp on the fly and after modifying the
graphics obtained you can render it to Response.Output Stream.

This stream will be directly served to requesting browser. You can also
display this image on any HTML using standard <img> tag. Provide the web
accessible path of this image rendering page in src elemnet of the <img> tag
and your image will be shown with the HTML output by browser.

Sample code snippet:
<CODE>
Bitmap bmp = new Bitmap(200, 100);
Graphics gr = Graphics.FromIm age(bmp);
gr.Clear(Color. WhiteSmoke);
gr.DrawString(" Test String", new Font("Arial", 12), Brushes.Blue, 10, 10);
bmp.Save(Respon se.OutputStream , ImageFormat.Jpe g);
gr.Dispose();
bmp.Dispose();
Response.End();
</CODE>


Just to add, you can find a little more explanation here:

http://www.codeproject.com/aspnet/as...b_graphics.asp

--
Cheers,
Rahul Anand

Nov 17 '05 #3

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

Similar topics

3
1715
by: peter | last post by:
How to create a class dynamicaly at run-time? Some documentations in MSDN say that it is feasible using the class "TypeBuilder",but I don't know how to do. Is there anyone who can help me? Sample code is appreciated.
1
380
by: Daniel | last post by:
how to create a gif or png dynamicaly in .aspx and return in response?
2
2347
by: Christopher Ambler | last post by:
I'm wondering if there's a solution here - I have an ASPX page with a sole purpose of scaling an image. The ASPX page contains a single line with the codebehind tag, and the .cs file contains the code to read an image, use GDI+ to scale it to a reasonable size, and emit the image directly (setting content-type on the response and spitting...
7
7760
by: moondaddy | last post by:
I want to dynamically create a JavaScript file and cache it on the client for re-use. I know how to write javascript to a web page from the code behind, but I don't know how to actually create a file such as MyNewScript.js and then cache that on the client so all the pages of that session can use it. Can this be done? Thanks --...
3
1125
by: leon | last post by:
hello friends, i am writing a page aspx and creating controls dinamicaly and then i must to create for each control the events as well. Anybody to know how????? happy day lion
2
1997
by: WJ | last post by:
I have three ASPX pages: 1. "WebForm1.aspx" is interactive, responsible for calling a web site (https://www.payMe.com) with $$$. It is working fine. 2. "WebForm2.aspx" is non-interactive, a listener in my site to capture a "STATUS_CD" returned by www.payMe.com. It is working fine. 3. "WebForm3.aspx" is interactive page, responsibe to...
2
1414
by: SalamElias | last post by:
When creating checkboxes dynamically, I assign the ID property as follows : chkBox.ID ="myID", when runing the ASPX page I see a name attribute in the input ************************************* <input id="30R" type="checkbox" name="30R5149"........ ************************************** The object checkbox does not have "name" property. The...
4
6887
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in...
6
2801
by: Michael Tissington | last post by:
Using Visual Studio 2008 can someone point me to an example to create a cgi web service in C# ? Thanks.
0
7701
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
7615
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
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
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...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.