Convert Bitmap To Byte Array

If you need to convert a Bitmap to an Byte array, here is how you do it.

  Public Shared Function ConvertToByteArray(ByVal value As Bitmap) As Byte()

      Dim bitmapBytes As Byte()

 

      Using stream As New System.IO.MemoryStream

 

        value.Save(stream, value.RawFormat)

        bitmapBytes = stream.ToArray

 

      End Using

 

      Return bitmapBytes

 

  End Function

Tip By: David McCarter

This code can be found in the open source dotNetTips.Utility assembly

One thought on “Convert Bitmap To Byte Array

Comments are closed.