Using Graphics class we can write something on image. Graphics class object invoke drawing objects, like String, Rectangle, oval etc. For DrawString( ) method, we need some parameter like string text, font, point where you want to display string on image. Now copy this code
Image img = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
var font = new Font("TimesNewRoman", 25, FontStyle.Bold, GraphicsUnit.Pixel);
var graphics = Graphics.FromImage(img);
graphics.DrawString("Hello World! " , font, Brushes.Red, new Point(0, 0));
this.pictureBox1.Image = img;
Here
Here
- First to add the picture box in the form.
- Now, using the Bitmap class we can pick the resolution parameter of picture box then assign these parameter to Image class instance.
- Take Font class for making highly visualize text in the image.
- Use graphics class to Draw the string on the image.
- Before Drawing must to assign the image to the Graphics class.
The following mentioned video contain full implementation guide: