Loading an image from a binary file without FromFile?
I've narrowed the problem down to
picBox.Image = System.Drawing.Image.FromStream(New System.IO.MemoryStream(image, 0, image.Length))
Where an exception occurs in system.drawing, saying a bad param was given for FromStream(). Maybe I'm going about this the wrong way? How can I load an image from a binary file and convert it from byte() to system.drawing.image? Current code below.
Original Message:
This is what I'm doing, but it tells me I have an invalid parameter and points me to the last line with the memory stream object in it. It says the function accepts byte() and I'm giving it byte() (I checked in the debugger and it says image() is 7300 bytes long at this point) So why is it doing this? I've tried everything I could think of but either it's too late at night, or I'm still to new at this Any Ideas?
Thanks,
Dan
I've narrowed the problem down to
picBox.Image = System.Drawing.Image.FromStream(New System.IO.MemoryStream(image, 0, image.Length))
Where an exception occurs in system.drawing, saying a bad param was given for FromStream(). Maybe I'm going about this the wrong way? How can I load an image from a binary file and convert it from byte() to system.drawing.image? Current code below.
Original Message:
This is what I'm doing, but it tells me I have an invalid parameter and points me to the last line with the memory stream object in it. It says the function accepts byte() and I'm giving it byte() (I checked in the debugger and it says image() is 7300 bytes long at this point) So why is it doing this? I've tried everything I could think of but either it's too late at night, or I'm still to new at this Any Ideas?
Code:
If System.IO.File.Exists(path) Then
Dim br As New System.IO.BinaryReader(System.IO.File.OpenRead(path))
Dim image As Byte() = br.ReadBytes(br.BaseStream.Length)
br.Close()
image = ByteDecrypt(image, rij) 'home baked function
picBox.Image = System.Drawing.Image.FromStream(New System.IO.MemoryStream(image, 0, image.Length))
Thanks,
Dan
Last edited: