Results 1 to 3 of 3

Thread: Adding Text in picture box using webcam

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Posts
    323

    Adding Text in picture box using webcam

    Hi everyone,

    Please refer to a thread http://www.vbforums.com/showthread.p...-image-capture
    I implemented this example in my project and camera is working fine.

    I just want to know how can I add date and time inside picture box.

    Thanks in advance.

    Ladak

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Adding Text in picture box using webcam

    If you're asking how to draw text onto an Image object then you call Graphics.FromImage to get a Graphics object and then call DrawString on that, e.g.
    Code:
    Using g = Graphics.FromImage(myImage)
        g.DrawString(Date.Now.ToString("MMMM d, yyyy h:mm tt"), Font, Brushes.Black, 10.0F, 10.0F)
    End Using

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Adding Text in picture box using webcam

    If you actually want to draw the text onto the PictureBox instead of the Image, which would look basically the same to the user but would mean not modifying the actual Image object, then you can handle the Paint event of the PictureBox and call DrawString on the Graphics object it provides. Just note that the Paint event is raised regularly so if you use Date.Now in the DrawString call then the time will continually be updated. If you want the time displayed to be what it was when you first made the call then you'd need to assign the date/time String to a variable and then use that in the Paint event handler.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width