AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2010

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2010.11.30 19:15 "Win32 ReadFile() / WriteFile() heads-up", by John Emmas
2010.11.30 19:26 "Re: Win32 ReadFile() / WriteFile() heads-up", by Toby Thain
2010.11.30 19:58 "Re: Win32 ReadFile() / WriteFile() heads-up", by John Emmas
2010.11.30 20:08 "Re: Win32 ReadFile() / WriteFile() heads-up", by Toby Thain
2010.11.30 20:12 "Re: Win32 ReadFile() / WriteFile() heads-up", by Frank Warmerdam
2010.12.01 17:40 "Re: Win32 ReadFile() / WriteFile() heads-up", by John Emmas
2010.12.05 18:36 "Re: Win32 ReadFile() / WriteFile() heads-up", by Edward Lam
2010.11.30 19:43 "Re: Win32 ReadFile() / WriteFile() heads-up", by Kevin Myers
2010.12.01 05:15 "Re: Win32 ReadFile() / WriteFile() heads-up", by Bob Friesenhahn
2010.12.01 08:45 "Re: Win32 ReadFile() / WriteFile() heads-up", by John Emmas
2010.12.01 06:35 "Re: Tiff Digest, Vol 79, Issue 1 - Win32 ReadFile() / WriteFile() heads-up (John Emmas)", by David J Taylor
2010.12.01 12:37 "Re: Win32 ReadFile() / WriteFile() heads-up", by Phil Harvey
2010.12.05 18:05 "Re: Win32 ReadFile() / WriteFile() heads-up", by Edward Lam

2010.11.30 19:15 "Win32 ReadFile() / WriteFile() heads-up", by John Emmas

You guys are probably already aware of this but I thought I'd flag it up
anyway....

As you know, libTIFF is widely used by 3rd party products and libraries. 
Among them is the cross-platform library libgtk.  On the Windows platform,
this is called libgtk-win32.  LibTIFF is actually used by libgdk_pixbuf
which is a graphical image library, supporting many different image types
(BMP. PNG, JPEG etc).

Because it interfaces with so many different types it generically uses the
CRT function _wfopen() to open the image files.  The FILE* returned by
_wfopen() is then passed to _fileno() to obtain a file handle.  That file
handle then gets used to manipulate the file (reading / writing etc) using
the interface provided by each specific library.  This all works very well
as long as you don't use the win32 versions of libgdk_pixbuf and libTIFF.

The problem is that in libTIFF (_tiffReadProc() for example, in tif_win32.c)
reading gets handled by the Windows function, ReadFile() and similarly for
WriteFile().  Unfortunately, those functions seem to only work with handles
returned by CreateFile().  They don't work for handles obtained from fopen()
or  _wfopen().  Of course, if one sticks entirely with libTIFF and uses the
recommended open function TIFFOpen(), all will be fine (because that does
call CreateFile() and thereby obtains a suitable handle).  However, any
library that's cross-platform probably wouldn't even consider CreateFile() /
ReadFile() / WriteFile() etc.  It would tend to prefer generic CRT
functions, such as read() and write().

I'm not saying there's anything wrong with libTIFF.  LibTIFF works fine as
long as you use its own interface function to open TIFF files - but
libgdk_pixbuf is an important library and it'd be nice if libTIFF could work
seamlessly with it.  At the moment it only works (under Windows) if you use
a *nix style build system, such as Cygwin or minGW.  Things fall down badly
if you want to use Visual C++.  libgdk_pixbuf needs to use generic handles
that can be applied to all file types across all platforms - it shouldn't be
getting brought down by special file handles that only apply to libTIFF and
Visual C++ but nothing else.

FWIW I've done some experiments today to replace the Windows-centric file
functions with their standard CRT equivalents and the initial signs were
pretty encouraging.  How do others feel about using read() and write() etc,
instead of ReadFile() and WriteFile()?  I'm not familiar enough with libTIFF
to understand what the ramifications might be.

John
P.S - incidentally, the link shown on your home page for subscribing to this
mailing list seems to be broken:-

http://remotesensing.org/mailman/listinfo/tiff