473,480 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Convert Bitmap to Byte and Byte to Bitmap

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

Nov 15 '05 #1
2 60094
I need help for a sample code to convert a bitmap to byte as well from byte
to bitmap..


I doubt you'll be able to squeeze an entire bitmap into a single byte
- did you mean a byte array?

There are many ways to do that, depending on the format you want it
in. The easiest way is probably to save the bitmap to a stream and
then read it's content. Something like

MemoryStream ms = new MemoryStream();
yourBitmap.Save( ms, ImageFormat.Bmp );
byte[] bitmapData = ms.ToArray();

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
> I doubt you'll be able to squeeze an entire bitmap into a single byte
- did you mean a byte array?
Yep.. a byte of array...
There are many ways to do that, depending on the format you want it
in. The easiest way is probably to save the bitmap to a stream and
then read it's content. Something like

MemoryStream ms = new MemoryStream();
yourBitmap.Save( ms, ImageFormat.Bmp );
byte[] bitmapData = ms.ToArray();


Cool.. I'll try this... Thanks for your help...

Eka
Nov 15 '05 #3

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

Similar topics

1
50419
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
7872
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
3268
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
5390
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
9173
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
7753
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
5046
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
2197
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
2679
by: Bill Fuller | last post by:
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...
0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7088
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5342
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2997
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2986
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
183
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.