Response.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jenny

    #1

    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
  • James J. Foster

    #2
    Re: Response.

    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



    "Jenny" <j.malloyNO@SPA Mx-mail.net> wrote in message
    news:0a2901c357 53$5275a690$a50 1280a@phx.gbl.. .[color=blue]
    > 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[/color]


    Comment

    • Jenny

      #3
      Re: Response.

      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

      [color=blue]
      >-----Original Message-----
      >Haven't dealt with GDI+ in a bit..but instead of saving[/color]
      the file to the[color=blue]
      >filesystem 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[/color]
      save both to a file[color=blue]
      >and to a stream...which is exactly why there's a a[/color]
      Response.Output Stream :)[color=blue]
      >
      >However, you'll have to change your logic a bit. If you[/color]
      save the bitmap to[color=blue]
      >the outputstream, you won't be able to render any text or[/color]
      anything...that 's[color=blue]
      >because you can't have a mix of binary and text contenxt[/color]
      outputted to the[color=blue]
      >screen (just the way HTTP works...not an asp.net[/color]
      limitation). SO what you'd[color=blue]
      >need to do is something like this:
      >
      ><img src="mytempimag e.aspx" width="130" height="30"> and[/color]
      place that in your[color=blue]
      >aspx page. This'll work because each image is fetched by[/color]
      the browser in[color=blue]
      >its own stream/request. Then in mytmepimage.asp x you can[/color]
      simply save the[color=blue]
      >image to the response.output stream...you'll also want to[/color]
      set your[color=blue]
      >response.conte nttype accordingly..so mething like "umage/jpeg"
      >
      >Karl
      >
      >
      >
      >"Jenny" <j.malloyNO@SPA Mx-mail.net> wrote in message
      >news:0a2901c35 753$5275a690$a5 01280a@phx.gbl. ..[color=green]
      >> 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[/color][/color]
      like?[color=blue][color=green]
      >>
      >> Thanks for all help
      >>
      >> Jenny[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...