Module ModuleHelper Public Function ByteArrayToBitmap(bytearray() As Byte) As Bitmap Return New Bitmap(New System.IO.MemoryStream(bytearray)) End Function Public Function StringToByteArray(ByVal hex As String) As Byte() Dim NumberChars As Integer = hex.Length Dim bytes(NumberChars / 2) As Byte For i As Integer = 0 To NumberChars - 1 Step 2 bytes(i / 2) = Convert.ToByte(hex.Substring(i, 2), 16) Next Return bytes End Function Public Function BitmapToByteArray(bitmap As Bitmap) As Byte() Dim bytearray As Byte() Using stream As New System.IO.MemoryStream bitmap.Save(stream, bitmap.RawFormat) bytearray = stream.ToArray() End Using Return bytearray End Function End Module