Response.

  • Thread starter Thread starter Jenny
  • Start date Start date
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
 
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.
 
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
 
Back
Top