Create Graphics in Custom Control

S

Stanley

Is is possible to create a graphic using GDI+ and send it back from a
control doing something like:
Code:
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
' Set the content type
HttpContext.Current.Response.ContentType = "image/jpeg"
Dim b As Bitmap = BuildImage()
' send the image to the viewer
b.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Jpeg)
' tidy up
b.dispose()
End Sub

At the current moment when I try this I get back a bunch of garbage like:
[garbage return]
?JFIF``?    $.' ",#(7),01444'9=82<.342? 
2!!22222222222222222222222222222222222222222222222222?,X"?
 ?}!1AQa"q2???#B??R?$3br?
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz??????????????????????????
?????????ƒa???????????????
?w!1AQaq"2?B????#3R???$4?&'()*56789:CDEFGHIJS
TUVWXYZcdefghijstuvwxyz????????????????????????????????????ƒa??????????????
?????4???i??Z
%D???Q??.y????|?????3U?M?0;??a?T????lg5?e?30?="?~9????vnMt??]???+PH?o?
???@P???????????rk?kQ?It???Pq??6/y?Uc??????]f???0q;???VqY:t???W???QG?
_????0?4???152?
&??N??7?+?i???h??~?????QEQEQEQEQEQEQEQEQEQEQEQEQEQEQEQE
QEQE?%!?z?n)??5????Wš@U?m???-?????E?}q?#5?_>kz????w?.#mh[\la??j?????
W???c??C?5?c????? g?i????I2?
&)[??[???Q?S?T?)??M?<??q???S???qx%?e?????0??"??=i?"?b????f??/ZlN?2h-????
????R??TW??Fw%5?5?????B#z T?????????
???????????(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(????
ZL?Zi4?l??2b#V^??
R??v?[????[[?????????????????.?m??_??(??????,?7[?n??m{6??G5?\?????v?O??
??????gk????{???Q?2@?u???y?:?&}?y?km?U???i??
????5m/??????^??H?O?*???o????[???????t??Y?IM??d?(??4???—?~??????????
?(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(?)h??R?/jCKI@=P?
[?]????-?????Mix?_?\?7[;?;?7
?vz\????l??L??????\??a???~j?Stm???|???U??k??X‚?WW??q\6??M??o?W?s??Ng?
????Mtd?'??a???e??Wq{??\???O? ?]??}??&k?3Z?z??H?a}?? ????h&
?????'?w??1??????Th?? ?$Y???S3)h??? ?y??m
^??????_?O??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??(??)?
???4S
???w0L??^%?kGT?f??~b??Hk^>f?"?????][???$&?muO+5b?2pk???(???u??Wu?oZi
??i??s??f??6??T??M????Z??J???co4??X:?p+}
?????m?"?@b??+??vz?ø???*??=MQ??u?A?y9L?mK?????øI?????????]^?6??c???p8
????;?q??O??h0?
?VG???"?9Z)?A??????p??u????????QEQEQEQEQEQEQEQEQEQEQEQEQEQ
EQEQEQEQEQE?A?????SLc?U%?fC??r3T?×.???Q?o????"?cmD???????}??r??oM\
??9r??j?????b??jUy/??ø?>7Wm?h?|?sxl????X?q:h?u??;?F|:G????k ???jtSd?;?]
?}*???P????w?s?t?U?87v?_b?R????9y?5??????As{??????-Z??50????R?x?2????
???xQ@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@
Q@QE?RP 2?? d]???'??8?}??????x????8?]3?m=wS%??????z?WU?J/
?*+??sU????[X???}??S\?????[?4?????iQ?J???-uE6+?%'????zW3w??
?2????WUJ???^????nx??z??????MqC?????1?T??#?Pi£??^??????_??EPEPEP
EPEPEPEPEPEPEPEPEPEPEPEPEPEPEPEP???
?v?CM??z_??Z??j@????y?H54÷mo? ???Z?e???z0???~?Mj???
cST????g???????s???VYj????U?????????T??`???;u?????5?4oH?t??v????p??bL*????
?P????????j?5{1?R????5?$????'p???;?
[/garbage return]

TIA

-Stanley
 
A

Antonio Bakula

Is is possible to create a graphic using GDI+ and send it back from a
control doing something like:
Code:
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
' Set the content type
HttpContext.Current.Response.ContentType = "image/jpeg"
Dim b As Bitmap = BuildImage()
' send the image to the viewer
b.Save(HttpContext.Current.Response.OutputStream, ImageFormat.Jpeg)
' tidy up
b.dispose()
End Sub


you can check out my TStreamImage control at :

http://baksa.europe.webmatrixhosting.net/

see PStreamImage, it has source included, it's written in Delphi but there
are also VS.NET c# examples.
 

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,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top