How do I convert a Bitmap to a byte[]

  • Thread starter Thread starter Bill Fuller
  • Start date Start date
B

Bill Fuller

I have a Bitmap (bm) that I am able to save using, for example,
bm.Save("file.jpg", System.Drawing.Imaging.ImageFormat.Jpeg). However, I
would like to convert this to a byte array (byte[]). What is the best way to
do this?
 
Bill said:
I have a Bitmap (bm) that I am able to save using, for example,
bm.Save("file.jpg", System.Drawing.Imaging.ImageFormat.Jpeg). However, I
would like to convert this to a byte array (byte[]). What is the best way to
do this?

It has an overload that takes a Stream as first argument. Pass a
MemoryStream object.

Arne
 
Back
Top