By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

Convert Byte() to System.Drawing.Image?

P: n/a
Using VB.Net (VS.Net 2k3)...

I'm at a bit of an impasse I think... Is there any way to convert an array
of Byte() into a System.Drawing.Image object without writing the array to a
file, then reading back into the s.d.i object? Couldn't find anything in
MSDN or by Googling...

Thanks!
Jan 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>I'm at a bit of an impasse I think... Is there any way to convert an array
of Byte() into a System.Drawing.Image object without writing the array to a
file, then reading back into the s.d.i object?


Create a MemoryStream around the byte array and call Image.FromStream.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jan 20 '06 #2

P: n/a
"JackBlack" <ja********@hotmail.com> schrieb
Using VB.Net (VS.Net 2k3)...

I'm at a bit of an impasse I think... Is there any way to convert
an array of Byte() into a System.Drawing.Image object without
writing the array to a file, then reading back into the s.d.i
object? Couldn't find anything in MSDN or by Googling...

dim stream as System.IO.MemoryStream
dim img as image

stream = new System.IO.MemoryStream(bytearray)
img = image.fromstream(stream)
Armin

Jan 20 '06 #3

P: n/a
"JackBlack" <ja********@hotmail.com> schrieb:
I'm at a bit of an impasse I think... Is there any way to convert an
array of Byte() into a System.Drawing.Image object


Create a 'MemoryStream' object, write the byte array to the stream and use
'Image.FromStream' to construct the image. Note that the stream must be
kept open as long as the 'Image' object exists.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.