Connecting Tech Pros Worldwide Forums | Help | Site Map

Response.

Jenny
Guest
 
Posts: n/a
#1: Nov 17 '05
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

James J. Foster
Guest
 
Posts: n/a
#2: Nov 17 '05

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.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.malloyNO@SPAMx-mail.net> wrote in message
news:0a2901c35753$5275a690$a501280a@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.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[/color]


Jenny
Guest
 
Posts: n/a
#3: Nov 17 '05

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(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[/color]
save both to a file[color=blue]
>and to a stream...which is exactly why there's a a[/color]
Response.OutputStream :)[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="mytempimage.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.aspx you can[/color]
simply save the[color=blue]
>image to the response.outputstream...you'll also want to[/color]
set your[color=blue]
>response.contenttype accordingly..something like "umage/jpeg"
>
>Karl
>
>
>
>"Jenny" <j.malloyNO@SPAMx-mail.net> wrote in message
>news:0a2901c35753$5275a690$a501280a@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.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[/color][/color]
like?[color=blue][color=green]
>>
>> Thanks for all help
>>
>> Jenny[/color]
>
>
>.
>[/color]
Closed Thread