1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Public Function ByteArray2Image(ByVal BArray As Byte()) As Image
Try
Dim mstImage As System.IO.MemoryStream = New System.IO.MemoryStream(BArray)
Dim img As Image = Image.FromStream(mstImage)
Return img
Catch ex As Exception
Return Nothing
End Try
End Function
Function Image2ByteArray(ByVal img As Image) As Byte()
Try
Dim mstImage As System.IO.MemoryStream = New System.IO.MemoryStream
img.Save(mstImage, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim bytImage As Byte() = mstImage.GetBuffer
Return bytImage
Catch ex As Exception
Return Nothing
End Try
End Function |
Partager