Click here to Skip to main content
12,508,630 members (56,330 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
hi
in the following code:
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 30-Dec-11 21:47pm
Updated 30-Dec-11 23:24pm
Mehdi Gholam323.5K
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 31 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100