Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi in the following code:
C#
Image img = Image.FromFile(@"c:\tmp.tif");
g.DrawImage(img, 0, 0);

i get the following exception:
An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll

Additional information: A generic error occurred in GDI+.
in FromFile function.

what's the problem and what can i do to resolve it?
thx
Posted
Updated 30-Dec-11 23:24pm
v2
Comments
Amir Mahfoozi 31-Dec-11 4:27am    
Try other tiff files to ensure that the problem is not the file structure.
Amir Mahfoozi 31-Dec-11 5:59am    
[moved from answers to comments]
ilostmyid2 :
thank u 4 ur answers.
no, it's not in use by another process. it seems that GDI+ doesn't support the format. when i give it another file path which is a path to a jpg file, it works well. when i give it path of a bmp file, it works weird. DrawImage draws a whole white surface, while DrawImageUnscaledAndClipped draws it properly! it seems that Image is still a newbie in decoding images.
maybe i've to install a GDI+ update. i'm using Windows Server 2003 as a client!
any idea?
thx
ilostmyid2 31-Dec-11 6:30am    
the tiff file is not recognized by "Windows Picture and Fax Viewer", but it's opened and shown successfully by "Microsoft Office Document Imaging".

1 solution

The code itself works fine for me, check your TIF file is not corrupt or in use by something else.
Try a different file, or location, in case it is a permissions issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900