Voila déja un point de depart :
Avec ca devrais avoir un peu près tout ce qu'il te faut pour gérer l'envoie et la reception de l'image + un bouton pour capturer l'image.
<code>
Option Explicit
'Déclaration des fonctions pour le traitement des fichiers graphiques
Private Declare Function BmpToJpeg Lib "Bmp2Jpeg.dll" (ByVal BmpFilename As String, ByVal JpegFilename As String, ByVal CompressQuality As Integer) As Integer
Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYdest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal dwRop As Long) As Long
'déclaration des fonctions pour la capture de l'image de la caméra
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal IpszWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, IParam As Any) As Long
Private Declare Function ReleaseCapture Lib "USER32" () As Long
'Déclaration des constantes
Private Const WM_CAP_DRIVER_CONNECT As Long = 1034
Private Const WM_CAP_DRIVER_DISCONNECT As Long = 1035
Private Const WM_CAP_GRAB_FRAME As Long = 1084
Private Const WM_CAP_EDIT_COPY As Long = 1054
Private Const WM_CAP_DLG_VIDEOFORMAT As Long = 1065
Private Const WM_CAP_DLG_VIDEOSOURCE As Long = 1066
Private Const WM_CLOSE = &H10
'Déclaration des variables nécessaires à l'utilisation des fonctions précédentes
Private mCapHwnd As Long
'Déclaration des variables pour le stockage mémoire des images
Dim ImageWebCam() As Byte
Private Sub Form_Load()
socklisten.LocalPort = 128
socklisten.Listen
'dimensionnement dynamique de l'objet MaWebCam en fonction de la taille de l'image
MaWebCam.Width = 640 * Screen.TwipsPerPixelX
MaWebCam.Height = 480 * Screen.TwipsPerPixelY
'fenêtre virtuelle
mCapHwnd = capCreateCaptureWindow("Ma fenêtre de capture", 0, 0, 0, 320, 240, Me.hwnd, 0)
SendMessage mCapHwnd, WM_CAP_DRIVER_CONNECT, 0, 0
End Sub
Private Sub Camera_Click()
Timer.Enabled = True
End Sub
Private Sub Capture_Click()
'Pour cette ligne il te faut avoir la dll bmp2jpeg
BmpToJpeg App.Path & "\tmpout.bmp", App.Path & "\tmpout.jpeg", 40
MsgBox "Cliquez sur OK pour enregistrer l'image", vbOKOnly
SavePicture MaWebCam, "tmpout.bmp"
End Sub
Private Sub socklisten_ConnectionRequest(ByVal requestID As Long)
sockclient.Accept requestID
End Sub
Private Sub Setting_Click()
SendMessage mCapHwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0
End Sub
Private Sub Timer_Timer()
SendMessage mCapHwnd, WM_CAP_GRAB_FRAME, 0, 0
SendMessage mCapHwnd, WM_CAP_EDIT_COPY, 0, 0
MaWebCam.Picture = Clipboard.GetData
MaWebCam.Refresh
Dim FREEout As Integer
FREEout = FreeFile
Open App.Path & "\tmpout.jpg" For Binary As #FREEout
ReDim ImageWebCam(1 To LOF(FREEout))
Get #FREEout, , ImageWebCam
Close #FREEout
End Sub
Private Sub sock_DataArrival(ByVal bytesTotal As Long)
Dim ImageWebcamDistante() As Byte
Dim FREEin As Integer
Winsock.GetData ImageWebcamDistante
If Dir$(App.Path & "\tmpin.jpg") <> "" Then Kill App.Path & "\tmpin.jpg"
FREEin = FreeFile
Open App.Path & "\tmpin.jpg" For Binary As #FREEin
Put #FREEin, , ImageWebcamDistante
Close #FREEin
webcamdistance.Picture = LoadPicture(App.Path & "\tmpin.jpg")
webcamdistance.distance.Refresh
DoEvents
End Sub
Private Sub Form_Unload(Cancel As Integer)
SendMessage mCapHwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0
End Sub
<\code>
Voila bonne prog. a toi !
Olivier