To use a System.Drawing.Bitmap object on a Page, you basically need to
create a separate Page that returns ContentType="image/gif" (or whatever
type of image you are creating). You then use that *.aspx file the same way
you would use a regular *.gif file. I wish there was a way to build this
into the Control itself also, but to the best of my knowledge there isn't,
since HTML needs a value to assign to the img tag's src attribute (or
wherever the image is going to be used). What you can do, however, is have
this separate Page accept a querystring so that you can use the same file to
create all your images so that you don't need to create a million extra
Pages. Something else you can do, if there are a couple static *.gif files
you will be using that you don't want the user to need to copy, is create a
resource file (*.resx) with the images in it and then have a Page that
simply loads one of them and writes it out the same way you would if you
were generating the image. Yeah, it's not what we want for writing custom
controls when we want to include images, but to the best of my knowledge,
it's the best we have write now.
--
Nathan Sokalski
http://www.nathansokalski.com/
"ThatsIT.net.au" <me@work> wrote in message
news:6A66FA67-C646-4EC1-A6C8-...
>I have this code that writes a pie chart in a asp.net page, but I want to
>use it in a server control.
>
> When I try I get a error on the last line "Response.OutputStream"
> Obviously there is no response object but how do I write it to screen?
>
> Dim objBitmap As New System.Drawing.Bitmap(400, 440)
> Dim objGraphics As System.Drawing.Graphics
> objGraphics = System.Drawing.Graphics.FromImage(objBitmap)
> objGraphics.Clear(Drawing.Color.White)
>
> Dim p As New Drawing.Pen(Drawing.Color.Yellow, 0)
> Dim rect As New Drawing.Rectangle(10, 10, 280, 280)
> 'objGraphics.DrawEllipse(p, rect)
>
> Dim b1 As New Drawing.SolidBrush(Drawing.Color.Red)
> Dim b2 As New Drawing.SolidBrush(Drawing.Color.Green)
> Dim b3 As New Drawing.SolidBrush(Drawing.Color.Blue)
> objGraphics.FillPie(b1, rect, 0.0, 90.0)
> objGraphics.FillPie(b2, rect, 90.0, 60.0)
> objGraphics.FillPie(b3, rect, 150.0, 210.0)
>
> Dim fontfml As New
> Drawing.FontFamily(Drawing.Text.GenericFontFamilie s.Serif)
> Dim font As New Drawing.Font(fontfml, 14)
> Dim brush As New Drawing.SolidBrush(Drawing.Color.Black)
> objGraphics.DrawString("Missy Mosley", font, brush, 100, 300)
> Dim i As Image = New Image
>
> Dim mStream As MemoryStream = New MemoryStream
> Dim httpApp As HttpApplication = New HttpApplication
> objBitmap.Save(Response.OutputStream,
> Drawing.Imaging.ImageFormat.Gif)