Loading an image from a binary file without FromFile?
Ive 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 Im 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 Im 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 Im 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? Ive tried everything I could think of but either its too late at night, or Im still to new at this Any Ideas?
Thanks,
Dan
Ive 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 Im 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 Im 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 Im 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? Ive tried everything I could think of but either its too late at night, or Im 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 by a moderator: