Convert Byte() to System.Drawing.Image?

J

JackBlack

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!
 
A

Armin Zingler

JackBlack said:
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
 
M

Mattias Sjögren

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
 
H

Herfried K. Wagner [MVP]

JackBlack said:
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.
 

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