Hi, Try the following code snippet. It assumes that you have the image and text with you already... <%@ Page language="C#" ContentType="image/jpeg"%> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Imaging" %> <%@ Import Namespace="System.IO" %> <script runat="server"> void Page_Load(Object o, EventArgs e) { String FileName = "image1.jpg"; String Message = "Season's Greetings"; Color FillColor = Color.FromArgb(127,255,255,255); SolidBrush FillBrush = new SolidBrush(FillColor); Rectangle FillRectangle = new Rectangle(5,5,310,50); Font TextFont = new Font("Comic Sans MS",20); SolidBrush TextBrush = new SolidBrush(Color.Navy); StringFormat TextFormat = new StringFormat(); TextFormat.Alignment = StringAlignment.Center; TextFormat.LineAlignment = StringAlignment.Center; System.Drawing.Image GreetingImage = System.Drawing.Image.FromFile(Server.MapPath("images") + "\\" + FileName); Graphics DrawingSurface = Graphics.FromImage(GreetingImage); DrawingSurface.FillRectangle(FillBrush, FillRectangle); DrawingSurface.DrawString(Message, TextFont, TextBrush, FillRectangle, TextFormat); Stream Output = Response.OutputStream; GreetingImage.Save(Output,ImageFormat.Jpeg); } </script>
|