toocool
Registered Member
here's what i'm doing:
i'm updating my 'camcap' application. it uses a webcam and displays a live feed in the picturebox.
the update will enable the user to create frames and use a particular colour as a 'transparency key'. in other words, in the picture attached, the red regions will be replaced with whatever is being by the webcam, while the black regions remain unchanged
the problem: it treats the ENTIRE image (including the red section) as not red. and since red is in this case the transparency key, the red is not replaced by the webcam image.
here's the code:
please help
i'm updating my 'camcap' application. it uses a webcam and displays a live feed in the picturebox.
the update will enable the user to create frames and use a particular colour as a 'transparency key'. in other words, in the picture attached, the red regions will be replaced with whatever is being by the webcam, while the black regions remain unchanged
the problem: it treats the ENTIRE image (including the red section) as not red. and since red is in this case the transparency key, the red is not replaced by the webcam image.
here's the code:
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim pic2 = cameracap.CurrentCamera.GetCurrentImage
Dim pic As Bitmap = New Bitmap(My.Computer.FileSystem.SpecialDirectories.MyPictures & "\test.png")
If pic2 IsNot Nothing Then
Dim x As Integer = 1
Dim y As Integer = 1
For x = 1 To pic2.Width - 1
For y = 1 To pic2.Height - 1
Dim col As Color = pic.GetPixel(x, y)
If col = Color.Red Then
Dim chg As Color = pic2.GetPixel(x, y)
pic.SetPixel(x, y, chg)
End If
Next
Next
PictureBox1.Image = pic
End If
End Sub
please help
Attachments
-
5.1 KB Views: 0