How do I convert a Bitmap to a byte[]

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?
 
A

Arne Vajhøj

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top