18-08-21, 12:31 AM
السلام عليكم ورحمة الله وبركاتة
انا دائما استخدم هذه الاكواد
كود :
Public Function ImageToByte(ByVal image As Image, ByVal format As System.Drawing.Imaging.ImageFormat) As Byte()
Using ms As MemoryStream = New MemoryStream()
image.Save(ms, format)
Dim imageBytes As Byte() = ms.ToArray()
Return imageBytes
End Using
End Function
Public Function ByteToImage(ByVal imageBytes As Byte()) As Image
Dim ms As MemoryStream = New MemoryStream(imageBytes, 0, imageBytes.Length)
ms.Write(imageBytes, 0, imageBytes.Length)
Dim image As Image = New Bitmap(ms)
Return image
End Function
