Create Dynamic Images RRS feed

  • Question

  • User-1690965310 posted
    I know this can be done but i just havnet had any luck. I basically want to have a textbox then the person enters there name and the name they enter gets rendered onto an image i specify. I dont need help with the textbox part, but im stuggling to get the dynamic image created. Can i get some help please. hava
    Wednesday, January 19, 2005 1:42 PM

All replies

  • User-1372641848 posted
    Try this sample code <%@ Page Language="c#" %> <%@ Import Namespace="System.Drawing" %> <script runat="server"> void Upload_Click(object sender, EventArgs e){ if (inputfile.PostedFile.ContentLength != 0){ Bitmap uploadedimage = new Bitmap(inputfile.PostedFile.InputStream); Graphics g = Graphics.FromImage(uploadedimage); g.DrawString(textbox.Text,new Font("verdana",12,GraphicsUnit.Pixel),Brushes.Black,10,10); // display image. Response.Clear(); Response.ContentType = "image/jpeg"; uploadedimage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); Response.End(); } } </script> <html > <head runat="server"> <title>Untitled Page</title> <form id="form1" runat="server" enctype="multipart/form-data">

    <input type="file" runat="server" id="inputfile" />

    <asp:textbox Runat="server" ID="textbox">your name</asp:textbox>

    <asp:Button Runat="server" text="Upload" OnClick="Upload_Click"/>

    Sunday, January 30, 2005 7:03 PM