i




 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
write text on image in asp.net
11-30-2012, 09:00 PM
Post: #1
write text on image in asp.net
We can easily write any text on image using Bitmap object passing to Graphics. And by DrawString method of Graphic class, we can write the text, set font size and family and color as well on image as shown in below code

Code:
private void Write_Text_On_Image(string Text, string FileName)
    {
        //This is the image where we are going to write the text on it.
        string PrimaryImg, OutputImg;
        PrimaryImg = Server.MapPath(".") + "\\Image\\Image.jpg";
        Bitmap bitmapPrimaryImage = new System.Drawing.Bitmap(PrimaryImg);
        Graphics graphicsPrimaryImage = Graphics.FromImage(bitmapPrimaryImage);

        //Set the font properties (#000000 for black)
        Color colorString = System.Drawing.ColorTranslator.FromHtml("#000000");
        graphicsPrimaryImage.DrawString(Text, new Font("Arial", 32,
        FontStyle.Bold), new SolidBrush(colorString), new Point(5, 5));

        //Save the new image on same folder
        OutputImg = Server.MapPath(".") + "\\Image\\" + FileName;
        bitmapPrimaryImage.Save(OutputImg);
    }

[Image: 6gjz9s.png]

Download the attachment for complete code




Attached File(s)
.zip  WriteTxtImage.zip (Size: 21.04 KB / Downloads: 10)

[Image: 2604595733.png]
Quote


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  Read, write and processing each row of a gridview ? dongtrien 0 1,355 11-24-2015 03:16 AM
Last Post: dongtrien
  pdf to image conversion in asp.net c# nisar87 10 32,360 11-10-2015 02:01 AM
Last Post: dasccca
  PDF to Image Conversion in ASP.NET magnum_2007 7 10,895 07-25-2014 09:13 AM
Last Post: alxe_2014
  pdf to text conversion in asp.net c# nisar87 0 7,763 12-12-2012 09:02 PM
Last Post: nisar87
  Weburl to Image conversion in asp.net nisar87 0 2,412 12-04-2012 08:47 AM
Last Post: nisar87



User(s) browsing this thread: 1 Guest(s)