472,951 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

How do I convert a Bitmap to a byte[]

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?
Jun 27 '08 #1
2 2662
Bill Fuller wrote:
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
Jun 27 '08 #2
On Fri, 06 Jun 2008 20:00:48 -0700, Arne Vajhøj <ar**@vajhoej.dkwrote:
Bill Fuller wrote:
>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.
And then after you've saved the Bitmap to that MemoryStream, use
MemoryStream.ToArray() to convert to a byte[].

Pete
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fritz Switzer | last post by:
With two controls a PictureBox and another "PictureBox like" , Pic2, a control from a dll, I'm stuck on cannot implicity convert System.Drawing.Image to System.Drawing.Bitmap error. How do I...
2
by: Eka Gautama | last post by:
Hi all, I need help for a sample code to convert a bitmap to byte as well from byte to bitmap.. Thanks for the help Eka
2
by: Clas Hortien | last post by:
Hi, i have a array of uint and want to display this array as a System.Web.UI.WebControls.Image. //========================================= uint ar = new uint; string fName;
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
3
by: Dennis | last post by:
I am trying to convert a bitmap to a JPEG MemoryStream and return a Byte array containing the resulting JPEG Image as follows: Public Function BmpToJPEG(ByVal BitMapIn As Bitmap, ByVal Quality As...
2
by: cosminb | last post by:
I have a native function which returns an image in the form of a BYTE* lpDIB array. How do I convert it to a Bitmap, so that I can work with it properly in C#? Thanks in advance, Cosmin
3
by: ShihChengYu | last post by:
Dear all: How to convert color image to bi-level image? I have confronted one problem when I build my OCR project. I used an software API function to enhance my project, but the API only...
4
by: eking | last post by:
//Thanks for any help,thank you!лл¡£ public override void FloodFill(Bitmap bmp, Point pt) { int ctr=timeGetTime(); //Debug.WriteLine("*******Flood Fill******"); //get the color's int...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.