Sub extractImageTest()
Dim by As Byte, jpegFile&, TbL
Dim filetoopen As Variant
filetoopen = Application.GetOpenFilename("jpeg Files (*.jpg;*.mp3), *.jpg;*.mp3", 1, "ouvrir une image")
If filetoopen = False Then Exit Sub
TbL = GetBinaryArrayJpg_OnFile(filetoopen)
If Not IsArray(TbL) Then MsgBox "Un problème dans l'extraction c'est produit": Exit Sub
jpegFile = FreeFile
Open Environ("userprofile") & "\Desktop\imagetemp.jpg" For Binary Access Write Lock Write As jpegFile
For i = 0 To UBound(TbL)
If IsNumeric(TbL(i)) Then by = TbL(i): Put jpegFile, , by
Next i
Close jpegFile
End Sub
'cette fonction récupère juste l'array de bits concernant le jpg
Function GetBinaryArrayJpg_OnFile(Fichier)
Dim OBJstream, BB() As Byte, b As Long, tablo
Set OBJstream = CreateObject("ADODB.Stream")
OBJstream.Open: OBJstream.Type = 1
OBJstream.LoadFromFile (Fichier)
BB = OBJstream.Read()
ReDim tablo(UBound(BB))
For i = 0 To UBound(BB): tablo(i) = BB(i): Next
code = "255,216" & Split(Split(Join(tablo, ","), "255,216")(1), "255,217")(0) & ",255,217"
GetBinaryArrayJpg_OnFile = Split(code, ",")
End Function