[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

GDI+ Images: any way to get only header info without reading in entire file?

Ted Miller

11/11/2003 7:09:00 PM

Hi folks,

I'm looking at TIFF support in GDI+. What I need is a way to get the header
info such as dimensions and bit depth, without causing the entire file to
get read in (ie, without reading in the pixel data, or accessing the header
info or pixel data for any additional frames that might be in the file).

Unfortunately, my testing shows that the call to create an Image from a TIFF
file will in fact cause the whole thing to get read in. (I am able to verify
this with a derived Stream type I wrote, so I can see the Read requests).

//
// Open a tiff file and put into a Stream whose implementation
// is available to me. This is just set-up for the test.
//
FileStream fs = new FileStream("c:\\mytiff.tif",FileMode.Open);
TedStream s = new TedStream(checked((uint)fs.Length));
s.PopulateFromStream(fs,0,0,checked((int)fs.Length));
s.Position = 0;

//
// Setting breakpoint in TedStream's Read method,
// I can see that this call causes the entire TIFF to get read in.
//
Image i = Image.FromStream(s);


Is there any way to get what I need, or am I out of luck with GDI+? Shame to
have to continue to use libtiff when GDI+/.Net have such lovely support for
TIFF built in, but we need those dimensions without reading in the entire
file, for performance reasons.