Problème pour enregistrer une image !

robapt Messages postés 114 Date d'inscription mardi 6 juillet 2004 Statut Membre Dernière intervention 4 décembre 2009 - 10 mai 2006 à 22:13
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 10 mai 2006 à 23:28
Salut tout le monde,j'ai un problème avec l'enregistrement d'une image
envoyé par winsock (par le serveur) ,le client reçoit l'image dans
image1.picture et l'enregistre sous le nom "Capture.jpeg" mais esce que
ce serai possible de changer le nom à chaque enregistrement
("Capture(1).jpeg" , "Capture(2).jpeg" , "Capture(3).jpeg" , ETC ...)

Je vous envoie le code :

Client :

Dim cLenTotal As Long, cAvance As Long, fReceive As Boolean

Private Sub Command2_Click()
Winsock.SendData "capture"
fReceive = False
Form2.Image1.Picture = Nothing
End Sub

Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim data As String
Winsock.GetData data
If fReceive = True Then
cAvance = cAvance + Len(data)
Open "G:\troyen\Captures d'écran\Capture.jpeg" For Append As #1
Print #1, data;
Close #1
Form2.Visible = True
Form2.Label5.Caption = Int((cAvance / cLenTotal) * 100) & "%" If cAvance cLenTotal Then Form2.Image1.Picture LoadPicture("G:\troyen\Captures d'écran\Capture.jpeg"): WinServe.Close
End If
If data Like "FILE:*" And fReceive = False Then
cLenTotal = Mid(data, 6, Len(data))
Form2.Label3.Caption = cLenTotal & " octets"
fReceive = True
cAvance = 0
Winsock.SendData "READY"
End If
End Sub

Serveur :


Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim data As String

Dim cLenFile As Long, cAvance As Long

Winsock.GetData data
If left(data, 7) = "capture" Then
Picture1.AutoRedraw = True
Picture1.width = Screen.width
Picture1.Height = Screen.Height
BitBlt Picture1.hDC, 0&, 0&, Screen.width, Screen.Height, GetDC(GetDesktopWindow()), 0&, 0&, SRCCOPY
SavePicture Picture1.Image, App.Path & "\temp.jpeg"
cLenFile = FileLen(App.Path & "\temp.jpeg")
LoadPictures (Picture1.Image)
Call SaveJPG(m_cDib, App.Path & "\temp.jpeg", 60)
Winsock.SendData "FILE:" & FileLen(App.Path & "\temp.jpeg")
End If
If data Like "*READY*" Then
Dim Texte As String
cAvance = 0
Open App.Path & "\temp.jpeg" For Binary Access Read As #1
Texte = Space(LOF(1))
Get 1, , Texte
Close #1
Winsock.SendData Texte
Kill App.Path & "\temp.jpeg"
End If



--------------------------------------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------------------------------------



Voila
,j'espère que vous arrivez à vous y retrouver,en faite quand je clique
sur le bouton Command2 dans le client ,winsock envoie "capture" pour
que le serveur envoie la capture,sa c'est fait mais dans dataarrival du
client, comment faire pour enregistrer sous plusieurs noms .

Merci ^^

1 réponse

Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
10 mai 2006 à 23:28
tu veux enregistrer des fichiers sous la forme Capture01.jpeg, Capture02.jpeg, Capture02.jpeg

c'est ça ??

il faut chercher à quel numéro tu est arrivé et l'incrémenter de 1 à chaque nouvelle capture




z$ =
Dir$("G:\troyen\Captures d'écran\Capture*.jpeg")



m = 0

While z$ <> ""

Lg = Len(z$) - 6

v = Val(Mid$(z$, Lg, 2))

If v > m Then m = v

z$ = Dir()

Wend


m = m + 1

Open "G:\troyen\Captures d'écran\Capture" & Format$(m,"00") & ".jpeg" For Append As #1


Daniel
0
Rejoignez-nous