Convert a Bitmap to a Byte Array

  Dim stream As MemoryStream = New MemoryStream
  Dim bitmapBytes As Byte()
  'Create bitmap
  Dim bitmap As Bitmap = New Bitmap(50, 50)
  bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
  bitmapBytes = stream.ToArray
  stream.Close()
  bitmap.Dispose()

 

Tip Submitted By: David McCarter


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.