471,350 Members | 1,835 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Image to byte[]??

Hi all
I want to convert an Image to byte[].
I used TypeDescriptor to get a convertor..
it sometimes works and sometimes gives me "GDI+ error"..

how can I convert image to bye[] ??

thanks
Dec 5 '05 #1
2 4098
perspolis wrote:
I want to convert an Image to byte[].
I used TypeDescriptor to get a convertor..
it sometimes works and sometimes gives me "GDI+ error"..

how can I convert image to bye[] ??


Use Image.Save, providing a MemoryStream and the desired ImageFormat.

Jon

Dec 5 '05 #2

MemoryStream memoryStream = new MemoryStream();

Byte[] imageBytes;

Bitmap bitmap = new Bitmap(this.pictureBox1.Image);

bitmap.Save(memoryStream,ImageFormat.Jpeg);

imageBytes = memoryStream.ToArray();

Regards
Johan
"perspolis" <re*****@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Hi all
I want to convert an Image to byte[].
I used TypeDescriptor to get a convertor..
it sometimes works and sometimes gives me "GDI+ error"..

how can I convert image to bye[] ??

thanks

Dec 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by John Smith | last post: by
10 posts views Thread by David W. Simmonds | last post: by
7 posts views Thread by lgbjr | last post: by
3 posts views Thread by den 2005 | last post: by

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.