PC Review


Reply
Thread Tools Rate Thread

Convert Bitmap to Byte and Byte to Bitmap

 
 
Eka Gautama
Guest
Posts: n/a
 
      10th Nov 2003
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



 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      10th Nov 2003

>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.
 
Reply With Quote
 
Eka Gautama
Guest
Posts: n/a
 
      11th Nov 2003
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Convert an image to bitmap byte() with the size? James Hahn Microsoft VB .NET 0 9th Oct 2009 07:52 AM
How do I convert a Bitmap to a byte[] Bill Fuller Microsoft C# .NET 1 7th Jun 2008 04:00 AM
Convert Bitmap to Byte Array =?Utf-8?B?S0M=?= Microsoft Dot NET Compact Framework 1 28th Oct 2005 03:28 PM
Convert a Bitmap to a Byte Array? =?Utf-8?B?Q29udmVydCBhIEJpdG1hcCB0byBhIEJ5dGUgQXJy Microsoft Dot NET Compact Framework 4 20th Oct 2005 04:04 PM
Convert Bitmap to Byte[] Sergio Florez M. Microsoft C# .NET 4 2nd Jul 2004 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 AM.