473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.

My application generates images dynamic. These images are
then used for an image button like in the beneath.

Dim ob As Bitmap = New Bitmap(130, 30)
Dim banner As Graphics = Graphics.FromIm age(ob)

Dim tempfilepath As String = System.IO.Path. GetTempPath
ob.Save(tempfil epath & "temp.jpg",
Imaging.ImageFo rmat.Jpeg)

image_button.Im ageUrl = tempfilepath & CType(i, String) &
"temp.jpg"

Is it also possible to add this graphic with the help of
Response.Binary Write etc.? If yes how must the code luck like?

Thanks for all help

Jenny
Nov 17 '05 #1
2 2512
I'm thinking that you want to stream the image down as opposed to saving it
to disk. What you can do is create a separate page that just streams down
the bytes for an image. Create a new .aspx page and remove all the HTML
content. Add this code to the page_load event:

Bitmap ob = new Bitmap(130, 30);
Graphics banner = Graphics.FromIm age(ob);
ob.Save(Respons e.OutputStream, System.Drawing. Imaging.ImageFo rmat.Jpeg);

Next, in the page with your ImageButton control, set the source of the
ImageButton to the page you created above. For example, if your page was
called webform2.aspx, you'd have:

ImageButton1.Im ageUrl = "webform2.aspx" ;

You can customize with parameters or whatever you need in order to generate
an appropriate image for that particular user.

--
James J. Foster, DotNetCoders
http://www.dotnetcoders.com
"Jenny" <j.********@SPA Mx-mail.net> wrote in message
news:0a******** *************** *****@phx.gbl.. .
My application generates images dynamic. These images are
then used for an image button like in the beneath.

Dim ob As Bitmap = New Bitmap(130, 30)
Dim banner As Graphics = Graphics.FromIm age(ob)

Dim tempfilepath As String = System.IO.Path. GetTempPath
ob.Save(tempfil epath & "temp.jpg",
Imaging.ImageFo rmat.Jpeg)

image_button.Im ageUrl = tempfilepath & CType(i, String) &
"temp.jpg"

Is it also possible to add this graphic with the help of
Response.Binary Write etc.? If yes how must the code luck like?

Thanks for all help

Jenny

Nov 17 '05 #2
Hi Karl,

thanks for the suggestion. But there is an image before the
sentence 'and place that in your' which I can't see. Can
you send it a second time?

Thanks
Jenny

-----Original Message-----
Haven't dealt with GDI+ in a bit..but instead of saving the file to thefilesystem which you are doing via:
ob.Save(tempfi lepath & "temp.jpg", Imaging.ImageFo rmat.Jpeg)

why not save it to the response's outputstream ala:

ob.save(Respon se.OutputStream , Imaging.ImageFo rmat.Jpeg)

if you look at the save method, you'll see that you can save both to a fileand to a stream...which is exactly why there's a a Response.Output Stream :)
However, you'll have to change your logic a bit. If you save the bitmap tothe outputstream, you won't be able to render any text or anything...that 'sbecause you can't have a mix of binary and text contenxt outputted to thescreen (just the way HTTP works...not an asp.net limitation). SO what you'dneed to do is something like this:

<img src="mytempimag e.aspx" width="130" height="30"> and place that in youraspx page. This'll work because each image is fetched by the browser inits own stream/request. Then in mytmepimage.asp x you can simply save theimage to the response.output stream...you'll also want to set yourresponse.conte nttype accordingly..so mething like "umage/jpeg"

Karl

"Jenny" <j.********@SPA Mx-mail.net> wrote in message
news:0a******* *************** ******@phx.gbl. ..
My application generates images dynamic. These images are
then used for an image button like in the beneath.

Dim ob As Bitmap = New Bitmap(130, 30)
Dim banner As Graphics = Graphics.FromIm age(ob)

Dim tempfilepath As String = System.IO.Path. GetTempPath
ob.Save(tempfil epath & "temp.jpg",
Imaging.ImageFo rmat.Jpeg)

image_button.Im ageUrl = tempfilepath & CType(i, String) &
"temp.jpg"

Is it also possible to add this graphic with the help of
Response.Binary Write etc.? If yes how must the code luck like?
Thanks for all help

Jenny

.

Nov 17 '05 #3

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

Similar topics

13
4734
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of Response.Writes. Are there any tools that will let you design the form then convert that form to Response.Writes that you can further customize with ASP logic? For instance: use Dreamweaver to design the form, then another program to convert to...
6
3038
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a cookie (say Response.Cookies ("TEST")) and you have a query string variable &test=x or &Test=x and you get Request.QueryString to parse the query string, the cookie that gets dropped matches the case of the query string, not what your code says. ...
5
2498
by: Luiz Vianna | last post by:
Guys, I need to send some info to my client while I'm processing some stuff. The flow will be something like : -process -response -process -response .... I imagine to use response.flush (as I did on ASP) but it does not work. See my test code, after sending 2 lines on response, I'm simulating a processing time before sending other 2 lines.
2
4168
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle of an http request, i set a filename (with path) and do a Response.WriteFile(filenamewithpath) then Response.End(). I have tried Response.Clear() and .Flush() ahead of time.
0
2981
by: PD | last post by:
I am trying to stream out a PDF file via the response object and when I execute the code it always brings up the first document that I pulled up.Even when I step through the code, I can see the new values in theData string array (see code below), but it serves up the first document that I had run this code with. I streamed theData into a text file to look at the values and it contained the appropriate ones for the new document. Even when I...
6
7359
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the browser displays or offers to save the binary file instead. I would like to have the browser accept and display the revised HTML code as well as offering to open or save the attached file. This SHOULD be possible using a multipart MIME format -...
5
4561
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks a session variable, and if it is not present, does a Response.Redirect to a webpage for the CAS passing a url parameter for the url to post back to. The CAS provides a page for the user to log into, validates the username and password, and then...
4
4322
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and response.writes out comma delimited strings so that the results are opened in Excel or saved to a flat file. Basically, it looks something like this like this:
2
3180
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. I have actually saved the file returned by IE 7 as a text file and opened it in notepad, so I have confirmed that it is indeed the page master being returned. The code is in the code behind file for the aspx page and is called directly from a...
0
8325
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
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.