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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s