How to Write Text on an Image in VB.NET

Written by lora covrett
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Write Text on an Image in VB.NET
Documents are scanned to create computerised images. (Hemera Technologies/AbleStock.com/Getty Images)

Electronic documents are used in nearly every business environment. The electronic image is often routed directly from one person to another based on a set of workflow rules. Before sending the document to the next user, the current user might have placed a post-it note on the paper document with a handwritten note. Text can be placed on electronic images in VB.Net using the GDI+ Graphics class. GDI+ contains classes for drawing, imaging and printing.

Skill level:
Moderately Challenging

Other People Are Reading

Instructions

  1. 1

    Import the GDI+ classes "System.Drawing.Imaging" and "System.Drawing" at the beginning of your VB.Net program. Define a function or subroutine that will perform the action of adding text to the image. Name it something meaningful, such as "AddText."

  2. 2

    Define variables inside the "AddText" function to reference the image object, the brush object and the size of the image. The size variable needs to reference "System.Drawing.Size." Set the image equal to a picture file using "System.Drawing.Image.FromFile(FileName)," where "FileName" is the path to the image to be displayed in the program.

  3. 3

    Create a new image that is essentially a copy of the original image. "System.Drawing.Bitmap" requires the image and the size as parameters to create a new bitmap image.

  4. 4

    Create a new graphics object from the newly created bitmap image, passing the bitmap image variable to "System.Drawing.Graphics.FromImage(NewBitMap)." With the graphics object, many different objects can be drawn on the image.

  5. 5

    Use the "DrawString" method to add text to the image. Pass the text string, font, brush and position to the "DrawString" method. Referencing the new bitmap object created earlier, call the "Save" method passing the new image object and the format. Release the new bitmap object by calling the "Dispose" method.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.