473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Bitmap conversion

I'm trying to convert byte array (valid bitmap format) into some bitmaps and
back to byte array again. But when I inspect the content of the array
before and after the conversion they are different. I'm used the following
code to do the conversion. May any of you tell me what's happening?

Thanks,

Here are my code....
internal static Bitmap convertImage(string imageText)

{ imageText = imageText.Replace("\r\n", String.Empty);

Byte[] bitmapData;

bitmapData = Convert.FromBase64String(imageText);

MemoryStream streamBitmap = new MemoryStream(bitmapData);

return new Bitmap(streamBitmap);}

}

internal static string convertBase64Array(Bitmap bmp)

{ MemoryStream bmpStream = new MemoryStream();

bmp.Save(bmpStream, System.Drawing.Imaging.ImageFormat.Bmp);

byte[] bmpArray = new byte[bmpStream.Length];

bmpStream.Read(bmpArray, 0, Convert.ToInt32(bmpStream.Length));

return Convert.ToBase64String(bmpArray);}
--
-----------------------------------------------------------------
Isaac Yuen
CEM
University of Alberta
iy***@ualberta.construction.ca
-----------------------------------------------------------------

| University of Alberta
| Phone: (780) 492-2276
| Fax: (780) 492-0249

Nov 16 '05 #1
2 4623
iyuen wrote:
I'm trying to convert byte array (valid bitmap format) into some bitmaps and
back to byte array again. But when I inspect the content of the array
before and after the conversion they are different. I'm used the following
code to do the conversion. May any of you tell me what's happening?

Thanks,

Here are my code....


Did you check if the result of conversion is still a valid bmp? If yes,
may be it just has changed some characteristic like number of colors?

Vadim Chekan.
Nov 16 '05 #2
How would I be able to do that to check if it's valid beside showing it on a
form?
Well...i've used ImageFormat.MemoryBmp instead and it throws me an
exception.....

--
-----------------------------------------------------------------
Isaac Yuen
CEM
University of Alberta
iy***@ualberta.construction.ca
-----------------------------------------------------------------

| University of Alberta
| Phone: (780) 492-2276
| Fax: (780) 492-0249
"Vadim Chekan" <re*****************@rogers.com> wrote in message
news:3l********************@twister01.bloor.is.net .cable.rogers.com...
iyuen wrote:
I'm trying to convert byte array (valid bitmap format) into some bitmaps and back to byte array again. But when I inspect the content of the array
before and after the conversion they are different. I'm used the following code to do the conversion. May any of you tell me what's happening?

Thanks,

Here are my code....


Did you check if the result of conversion is still a valid bmp? If yes,
may be it just has changed some characteristic like number of colors?

Vadim Chekan.

Nov 16 '05 #3

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

Similar topics

2
by: chulhee | last post by:
I have a table named 'touchpoint' which contains about 20 millions of rows. I created a bitmap index on a column named 'reason_cd' which has 7 distinct values: 'IN', 'FR', 'OP', 'CM', 'SV',...
3
by: Flix | last post by:
Is there some way to convert a Bitmap from one PixelFormat (16bit or with indexed colors) to another(24bit), without doing per pixel operations?
1
by: The Confessor | last post by:
The following code: MapGraphics(ListBox_Graphics.SelectedIndex - 1).MapBitmap = System.Drawing.Bitmap.FromFile(OpenFileDialog_SelectFile.FileName) incurs the following error: Option Strict...
3
by: Sharon | last post by:
I have a buffer of byte that contains a raw data of a 1 byte-per-pixel image data. I need to convert this buffer to a Bitmap of Format32bppArgb and to a Bitmap of Format24bppRgb. Can anybody...
4
by: Andrew | last post by:
Hi, I'm trying to blit small bitmaps onto a larger bitmap, and I've got a few issues wrt positioning and output size. I think my problems are due to DPI differences... My small images are...
0
by: Craig | last post by:
Hi there, This could be a curly question. When I created the x11 bitmap image using the im.tobitmap() function I found out later that the display information in the array is big endian (I...
10
by: Pramod Kadur | last post by:
Hello All, I need to convert the bitmap image to hexadecimal, so is there any free tool for doing this conversion? Any other suggestion is always welcome. Thank you in advance. Regards,...
1
by: TG01 | last post by:
I cannot clone a bitmap.. the error on the offending line says: Cannot implicitly convert type 'object' to 'System.Drawing.Bitmap'. An explicit conversion exists (are you missing a cast?) ...
0
by: Duracel | last post by:
Hi, I've got a routine that fetches a bitmap from a COM server and converts it into a .NET format bitmap. The original DIB surface is 24 bit. When blitting this bitmap to a window, the speed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.