Search

Thursday, March 12, 2015
0 comments

How to write something on image in windows form c#

4:59 AMThursday, March 12, 2015
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

  1. First to add the picture box in the form.
  2. Now, using the Bitmap class we can pick the resolution parameter of picture box then assign these parameter to Image class instance.
  3. Take Font class for making highly visualize text in the image.
  4. Use graphics class to Draw the string on the image.
  5. Before Drawing must to assign the image to the Graphics class.
The following mentioned video contain full implementation guide:



Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top