Parameter is not valid (with bitmap)
-
Hi. Why do i get this error when opening a file as bitmap : "Parameter is not valid" I'm trying to open a .tif file, with calling a funtcion. The code:
Bitmap tif = new Bitmap(fileName, false);
I googled a bit and tried with casting the bitmap like this: "bitmap tif = (bitmap)bitmap.fromfile(filename);" but i got another error saying - "out of memory". i also read something with using stream, but didnt quite get it on how to work... Can someone please help? PS: the tif file has 4 EMPTY pages. And everything stopped only with this file. Many tifs before went through well. Thanks in advance.
Regards, Matjaž
-
Hi. Why do i get this error when opening a file as bitmap : "Parameter is not valid" I'm trying to open a .tif file, with calling a funtcion. The code:
Bitmap tif = new Bitmap(fileName, false);
I googled a bit and tried with casting the bitmap like this: "bitmap tif = (bitmap)bitmap.fromfile(filename);" but i got another error saying - "out of memory". i also read something with using stream, but didnt quite get it on how to work... Can someone please help? PS: the tif file has 4 EMPTY pages. And everything stopped only with this file. Many tifs before went through well. Thanks in advance.
Regards, Matjaž
Since you are setting the second param (useIcm, i think) to false, omit it altogether.
Bitmap tif = new Bitmap(filename);
If you still get the error, then it is likely that the tif file has been created in an unorthodox (to MS, at least) way. As far as using streams is concerned try something like:
Bitmap tif = null;
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
tif = new Bitmap(fs);
}Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”