I'm working on a document managment application which uses TIF as it's main format. There are several files that load fine in any other program except mine. Here is the code I had originally:
When it gets to the second line, it would give me an Out of Memory exception. Then after Googling the problem, I came up with the solution:
Which gave me the exception "Parameter is not valid." Again, I Googled the problem. This time though, the results of the search came back with people having problems loading images from a byte array. So again, I rewrote my code:
This also failed with the same error. I have tried many times interchanging between:
None have worked. After searching Google and this site again, I kept coming up with the answer, "you need to reset your memory stream to position=0 before loading the image". Which I already tried. I thought maybe the TIF files were too big for .NET to handle, but other applications don't seem to have a problem with them. The average filesize is about 1MB. Dimensions are around 1800 x 2200. Most are single page TIF files.
I am developing this application in Visual Studio 2005, in VB.NET. I have compiled and run this on other machines which are also showing this error.
Thanks in advance.
VB.NET:
Dim img as Image
img = Image.FromFile(filename)
When it gets to the second line, it would give me an Out of Memory exception. Then after Googling the problem, I came up with the solution:
VB.NET:
Dim fStream as new FileStream(filename, FileMode.Open)
img = Image.FromStream(filename)
Which gave me the exception "Parameter is not valid." Again, I Googled the problem. This time though, the results of the search came back with people having problems loading images from a byte array. So again, I rewrote my code:
VB.NET:
Dim fStream as new FileStream(filename, FileMode.Open)
Dim memStream as new MemoryStream
Dim bytes(fStream.Length) as Byte
fStream.Read(bytes, 0, fStream.Length)
memStream.Write(bytes, 0, bytes.Length)
memStream.Position = 0
img = New Bitmap(memStream)
This also failed with the same error. I have tried many times interchanging between:
VB.NET:
img = Image.FromFile(filename)
img = Image.FromStream(fStream)
img = New Bitmap(filename)
img = New Bitmap(fStream)
None have worked. After searching Google and this site again, I kept coming up with the answer, "you need to reset your memory stream to position=0 before loading the image". Which I already tried. I thought maybe the TIF files were too big for .NET to handle, but other applications don't seem to have a problem with them. The average filesize is about 1MB. Dimensions are around 1800 x 2200. Most are single page TIF files.
I am developing this application in Visual Studio 2005, in VB.NET. I have compiled and run this on other machines which are also showing this error.
Thanks in advance.