I use picture box to view web cam, it works. But i wan to add another transparent picture box on top with upload a picture transparent background circle . So when i open web cam there is a circle on the web cam. Is that possible? How to make picture box transparent?

Dani AI

Generated

this is doable in WinForms, but the trick is that a control with BackColor = Transparent only shows its PARENT, not the sibling underneath. So stacking PictureBox2 over PictureBox1 will still show the form background unless you re-parent the overlay. your sample was about hiding; here we want to draw on top. clearing BackgroundImage makes it empty, not see-through over another control.

Quick overlay approach (uses a 32-bit PNG ring with a transparent center):

' picVideo shows the webcam. picOverlay holds the ring.
Private Sub Form1_Load(...) Handles MyBase.Load
    picOverlay.Parent = picVideo
    picOverlay.BackColor = Color.Transparent
    picOverlay.Image = My.Resources.CircleMask   ' PNG with transparent center
    picOverlay.SizeMode = PictureBoxSizeMode.Zoom
    picOverlay.Dock = DockStyle.Fill
    picOverlay.BringToFront()
    picOverlay.Enabled = False   ' so it does not steal mouse input
End Sub

If you do not have a PNG, draw the guide directly over the video so it always stays in sync with resize:

Private Sub picVideo_Paint(sender As Object, e As PaintEventArgs) Handles picVideo.Paint
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
    Dim r = Rectangle.Inflate(picVideo.ClientRectangle, -40, -40)
    Using p As New Pen(Color.Lime, 3) : e.Graphics.DrawEllipse(p, r) : End Using
    ' Optional: dim outside the circle by filling a Region that excludes r.
End Sub

Notes:

  • If your capture library uses a hardware overlay surface, child controls may not appear above it. Render frames to a bitmap (then assign to picVideo.Image) or use the Paint approach.
  • If this is actually ASP.NET (tags suggest it), there is no PictureBox on a web page. You would position a PNG ring over the video with CSS.

Recommended Answers

All 3 Replies

I only started learning VB today but when going through an example of how to display a picture i was curious how to also hide it.

the following is what I put together with one button to display the image and another to hide.

To show the image;

PictureBox1.Visible = True

To hide the image;

PictureBox1.Visible = True

Extracted from this;

Public Class Picture_example

    Private Sub Picture_example_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.Image = Image.FromFile("C:\Documents and Settings\JJ\Desktop\pcount2.jpg")
        PictureBox1.Visible = True
    End Sub
    Private Sub Picture_example_2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        PictureBox1.Visible = False
    End Sub
End Class

hope it helps

Im not goin to hide it, cause i use picturebox to viewing webcam and i want add a circle when viewing the web cam. so i wan add another picturebox2 on top the web cam picture box. what i can think is the picturebox2 background make it transparent and upload a circle with background transparent .png . but when i viewing the web cam the picturebox2 still there.

I don't Understand You All But i think you could use none picture like this

PictureBox2.BackgroundImage = Nothing

It Still there And Transparent
You Could Upload You png to Image Resource
And When You Want it to Show Again Just

PictureBox2.BackgroundImage = My.Resource.***.png
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.