1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
Public Sub connexionwebcam()
LoadDeviceList()
If lstDevices.Items.Count > 0 Then
lstDevices.SelectedIndex = 0
Else
lstDevices.Items.Add("Caméra non connectée")
End If
Me.AutoScrollMinSize = New Size(100, 100)
Dim r As Rectangle
iDevice = lstDevices.SelectedIndex
Dim bReturn As Boolean
Dim wSize As Integer
Dim s As CAPSTATUS
bReturn = SendMessage(hHwnd, WM_CAP_GET_STATUS, Marshal.SizeOf(s), s)
End Sub
Private Sub LoadDeviceList()
Dim strName As String = Space(100)
Dim strVer As String = Space(100)
Dim bReturn As Boolean
Dim x As Short = 0
Do
bReturn = capGetDriverDescriptionA(x, strName, 100, strVer, 100)
If bReturn Then lstDevices.Items.Add(strName.Trim)
x += CType(1, Short)
Loop Until bReturn = False
End Sub
Private Sub OpenPreviewWindow()
If modemanuel = False Then
Dim picCapture As New PictureBox
End If
Dim iHeight As Integer = picCapture.Height
Dim iWidth As Integer = picCapture.Width
hHwnd = capCreateCaptureWindowA(iDevice.ToString, WS_VISIBLE Or WS_CHILD, 0, 0, 370, _
250, picCapture.Handle.ToInt32, 0)
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, 370, 250, SWP_NOMOVE Or SWP_NOZORDER)
Else
DestroyWindow(hHwnd)
End If
End Sub
Delegate Sub MySubDelegate()
Protected Sub DelegateTest()
Dim c1 As New class1
' Create an instance of the delegate.
Dim msd As MySubDelegate = AddressOf c1.Sub1
' Call the method.
msd.Invoke()
End Sub
Public Sub prisephoto()
Dim data As IDataObject
Dim bmap As Bitmap
If modemanuel = False Then
OpenPreviewWindow()
End If
SendMessage(hHwnd, WM_CAP_EDIT_COPY, 640, 480)
data = Clipboard.GetDataObject()
If data.GetDataPresent(GetType(System.Drawing.Bitmap)) Then
bmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
picCapture.Image = bmap
If modemanuel = False Then
ClosePreviewWindow()
End If
Trace.Assert(Not (bmap Is Nothing))
bmap.Save("C:\photosjpg\" + nomdossier + "\" + valeurcb(cbvaltexte) + ".jpg", Imaging.ImageFormat.Jpeg)
End If
End Sub
Private Sub ClosePreviewWindow()
SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, iDevice, 0)
DestroyWindow(hHwnd)
End Sub |
Partager