Bitmap conversion

I

iyuen

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);}


--
 
V

Vadim Chekan

iyuen said:
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.
 
I

iyuen

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.....

--
 

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