locked
writing text on image at runtime in C#.net RRS feed

  • Question

  • User803787494 posted

     writing text on image at runtime in C#.net

    Friday, February 13, 2009 7:39 AM

Answers

  • User541108374 posted

    Hi,

    0k, i'm writing in windows form,c#

    In that case I suggest that you post your questions on the forums of www.windowsclient.net. It's dedicated to that technology.

    You should be able to instantiate a label with text and place that on certain coordinates on the form.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 13, 2009 8:26 AM

All replies

  • User541108374 posted

    Hi,

    the standard way to do this is to use an HttpHandler. Searching with live.com or google can provide you with a wealth of sample code for this: http://search.live.com/results.aspx?q=httphandler+watermark+image&form=QBLH.

    Grz, Kris.

    Friday, February 13, 2009 7:42 AM
  • User-609339402 posted

     Hi,

    for that you can used this function in that you have to pass your text and set image on which you want to string

    public void AddWatermark(string watermarkText) // pass string
        {
            System.Drawing.Image bitmap = (System.Drawing.Image)Bitmap.FromFile(Server.MapPath("image\\img_tripod.jpg")); // set image

            Font font = new Font("Arial", 20, FontStyle.Italic, GraphicsUnit.Pixel);

            Color color = Color.FromArgb(255, 255, 0, 0);
            Point atpoint = new Point(bitmap.Width / 2, bitmap.Height / 2);
            SolidBrush brush = new SolidBrush(color);
            Graphics graphics = Graphics.FromImage(bitmap);

            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;


            graphics.DrawString(watermarkText, font, brush, atpoint, sf);
            graphics.Dispose();
            MemoryStream m = new MemoryStream();
            bitmap.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);
            m.WriteTo(Response.OutputStream);
            m.Dispose();
            base.Dispose();
        }

     

    Friday, February 13, 2009 7:44 AM
  • User803787494 posted

     not asp

     

    Friday, February 13, 2009 7:55 AM
  • User541108374 posted

    Hi,

     not asp

    Specify that in your original question the next time. These forums are dedicated to ASP.NET hence it's normal that you get answers for that technology.

    Use the Graphics.DrawString method from the System.Drawing namespace.

    Grz, Kris.

    Friday, February 13, 2009 8:02 AM
  • User803787494 posted

    0k, i'm writing in windows form,c#

    what i require is to write text on form at runtime without using anytext boxes ortools. please help.

    Friday, February 13, 2009 8:12 AM
  • User541108374 posted

    Hi,

    0k, i'm writing in windows form,c#

    In that case I suggest that you post your questions on the forums of www.windowsclient.net. It's dedicated to that technology.

    You should be able to instantiate a label with text and place that on certain coordinates on the form.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 13, 2009 8:26 AM