Convert Byte() to System.Drawing.Image?

  • Thread starter Thread starter JackBlack
  • Start date Start date
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!
 
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
 
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
 
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.
 
Back
Top