How To Write Text On Images Using C#
You have an image and want to create a signature of your name on it. You can easily Write Text On Images for such purpose by using any Image Editor program. But if you want to create an Application which will do this work for you, then its very easy to create such Application in C#.
Instructions:
1.Create a new instance of Image class which will hold the the Image from your Computer on which we will Write Text.
Image img = Image.FromFile(@"D:/image.jpg");
2.Now create new instance of Graphics class which will be used to manipulate this Image and Write Text on it.
Graphics graphic = Graphics.FromImage(img);
3.Now use this Graphics class instance to Write Text on our Image by using DrawString method of Graphics class.
graphic.DrawString("How To Ideas", new Font("Arial", 14), new SolidBrush(Color.AntiqueWhite), new PointF(450.0f, 400.0f));
4.In above line first parameter is the String which we want to Write on Image, 2nd parameter is the Font which will be used to Write Text, 3rd parameter is the SolidBrush which is used to actually paint the text on Image, 4th parameter is the location on Image where we want to Write Text.
5.Now you can either save this Image or just can show in PictureBox. If you don’t know how to save an Image then see my article on How To Save An Image Using C#. If you want to show this Image in PictureBox, then here is simple code for that.
pictureBox1.Image = img;
Here is the output I get in PictureBox after running this code.
Download Source Code