Bonjour,
J'utilise MemoryStream pour sauver une image mais je ne parviens pas à la récupérer... Je ne parviens pas à trouver mon erreur.
J'ai une erreur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private imagess As Image 'Function Private Function BmpToBytes_MemStream(ByVal bmp As Bitmap) As Byte() Dim ms = New MemoryStream() bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Gif) Dim bmpBytes As Byte() = ms.GetBuffer() bmp.Dispose() ms.Close() Return bmpBytes End Function Function GetStringFromByteArray(ByRef SrcArray() As Byte) As String Dim enc As New System.Text.ASCIIEncoding() Return enc.GetString(SrcArray) End Function Public Function ByteArrayToImage(ByVal ByteArray As Byte()) As Image Dim stream As New MemoryStream(ByteArray, 0, ByteArray.Length) Return Image.FromStream(stream, True) End Function Public Shared Function StrToByteArray(ByVal str As String) As Byte() Dim encoding As New System.Text.ASCIIEncoding() Return encoding.GetBytes(str) End Function 'StrToByteArray 'Code d'appel des fonction Dim stream As MemoryStream = New MemoryStream() imagess.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg) Dim array As Byte() = stream.ToArray() Dim img_string As String = GetStringFromByteArray(array) Dim bitear As Byte() = StrToByteArray(img_string) PictureBox1.Image = ByteArrayToImage(bitear).ArgumentException, le paramètre n'est pas valide
Merci de votre aide
Partager