Response.

J

Jenny

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
 
J

James J. Foster

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.
 
J

Jenny

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top