473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.FromImage(ob)

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

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

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

Thanks for all help

Jenny
Nov 17 '05 #1
2 2497
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.FromImage(ob);
ob.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.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.ImageUrl = "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.********@SPAMx-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.FromImage(ob)

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

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

Is it also possible to add this graphic with the help of
Response.BinaryWrite 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(tempfilepath & "temp.jpg", Imaging.ImageFormat.Jpeg)

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

ob.save(Response.OutputStream, Imaging.ImageFormat.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.OutputStream :)
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="mytempimage.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.aspx you can simply save theimage to the response.outputstream...you'll also want to set yourresponse.contenttype accordingly..something like "umage/jpeg"

Karl

"Jenny" <j.********@SPAMx-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.FromImage(ob)

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

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

Is it also possible to add this graphic with the help of
Response.BinaryWrite 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
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...
6
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...
5
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...
2
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...
0
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...
6
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...
5
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...
4
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...
2
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.