Do the following:
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(50, 100,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
What you will most likely want to do is create a Generic Handler (*.ashx) to
do the drawing. If you use the ASHX approach then when you are done drawing
then just output the bitmap to the OutputStream.
bmp.Save(context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
On your ASPX page the source URL for the image will be the path to the ASHX
file.
Sample code:
Image.ashx
using System;
using System.Web;
public class Image : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(50, 100,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.Clear(System.Drawing.Color.Blue);
bmp.Save(context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
}
public bool IsReusable
{
get
{
return false;
}
}
}
Default.aspx
<img src="Image.ashx" />
"jediknight" <wa*****@gmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro ups.com...
Hi,
I am designing a web form which as an imagemap. I need to obtain a
graphics object so I can draw on this imagemap.
Can anyone tell me how to do this?
I have tried creating a bitmap object and doing Graphics.FromImage call
but the image on the imagemap disappears leaving a black background.
Many thanks in advance!!