protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Bitmap oBitmap = new Bitmap(468, 60);
Graphics oGraphic = Graphics.FromImage(oBitmap);
String scolor = BackgroundColor.SelectedValue;
String sText = Text.Text;
String sFont = Font.Text;
Color oColor = Color.FromName(BackgroundColor.SelectedValue);
SolidBrush oBrush = new SolidBrush(oColor);
SolidBrush oBrushwrite = new SolidBrush(Color.White);
oGraphic.FillRectangle(oBrush, 0, 0, 468, 60);
Font oFont = new Font(sFont, 13);
PointF oPoint = new PointF(5f,5f);
oGraphic.DrawString(sText, oFont, oBrushwrite, oPoint);
Response.ContentType = "image/jpeg";
oBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
}
}
Credit goes to :
http://www.sitepoint.com/generating-asp-net-images-fly/