locked
Text on Image RRS feed

  • Question

  • User511232196 posted

    HI,

         I want to display text on the image dynamically and save it as .Jpeg file.Please if any one knows the code post me.


    Thanks.

    Wednesday, September 30, 2009 5:18 AM

Answers

All replies

  • User1186257875 posted

    Here:

    http://lmgtfy.com/?q=drawstring+image+.NET

    second item 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 30, 2009 7:47 AM
  • User207054734 posted

     Hi,

    You can do something like this:-

    int

    height = 500;

    int width = 960;

    System.Drawing.

    Pen myPen;

    myPen =

    new System.Drawing.Pen(System.Drawing.Color.Red);

    Bitmap

    bmp = new Bitmap(width, height);

    Graphics g = Graphics.FromImage(bmp);//from image can be your image on which you want to write..

    g.Clear(

    Color.White);

    //Then USe g.DrawString(string,font,Brush,x,y);

    loke this:-

     

    Font f = new Font(FontFamily.GenericSansSerif,12);

    g.DrawString("Hello-World", f, Brushes.Aqua, 12, 30);

    bmp.Save(Server.MapPath("Image.jpg"), ImageFormat.Jpeg);

    myPen.Dispose();

    bmp.Dispose();

    g.Dispose();

     

    Enjoy.......

     

     

    Wednesday, September 30, 2009 8:00 AM