AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2005.11.15 09:38 "[Tiff] libtiff support for Microsoft Office Document Imaging", by Brad Hards
2005.11.15 14:40 "Re: [Tiff] libtiff support for Microsoft Office Document Imaging", by Frank Warmerdam
2005.11.20 04:31 "Re: [Tiff] libtiff support for Microsoft Office Document Imaging", by Brad Hards
2005.11.21 03:29 "Re: [Tiff] libtiff support for Microsoft Office Document Imaging", by Frank Warmerdam

2005.11.20 04:31 "Re: [Tiff] libtiff support for Microsoft Office Document Imaging", by Brad Hards

On Wednesday 16 November 2005 01:40 am, Frank Warmerdam wrote:

I would suggest adding a potential #define in tiffconf.h that is MDI_SUPPORT. it would not be defined.  Normally If defined, then .mdi files magic number is supported and byte swapping is done accordingly.

Depending on your level of success, the messiness and your willingness we might later want to incorporate MDI support into the core library (controlled by the MDI_SUPPORT flag).

I've had a go at doing this. See attached for what it might look like.

I decided to add a configure option instead of doing the #define directly. The #define has no effect for tiffdump, since tiffdump is already a diagnostics tool and can support most of the MDI tags.

I've done a little bit of work on what will happen if the host is bigendian, however it is almost certainly incomplete. I will do some more work on this before submitting the patch again.

I'd also like to add something to the public API (eg another define or a function) that says whether libtiff was compiled with MDI support.

I'm still not sure this is the right approach - doing a more general solution (perhaps with some flags) and always having it on would avoid packaging / building problems.

Brad

Index: configure.ac
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/configure.ac,v
retrieving revision 1.52
diff -u -4 -p -r1.52 configure.ac

--- configure.ac        7 Oct 2005 17:27:09 -0000       1.52
+++ configure.ac        20 Nov 2005 04:09:39 -0000

@@ -251,8 +251,21 @@ if test "$HAVE_LOGLUV" = "yes" ; then
   AC_DEFINE(LOGLUV_SUPPORT,1,[Support LogLuv high dynamic range encoding])
 fi

 dnl ---------------------------------------------------------------------------
+dnl Switch on/off support for Microsoft Document Imaging
+dnl ---------------------------------------------------------------------------
+
+AC_ARG_ENABLE(mdi,
+ AS_HELP_STRING([--disable-mdi],
+ [disable support for Microsoft Document Imaging]),
+ [HAVE_MDI=$enableval], [HAVE_MDI=yes])
+
+if test "$HAVE_MDI" = "yes" ; then
+ AC_DEFINE(MDI_SUPPORT,1,[Support Microsoft Document Imaging format])
+fi
+
+dnl ---------------------------------------------------------------------------
 dnl Check for ZLIB.
 dnl ---------------------------------------------------------------------------

 HAVE_ZLIB=no
@@ -528,8 +541,9 @@ LOC_MSG([ Installation directory:

 LOC_MSG([  Documentation directory:            ${LIBTIFF_DOCDIR}])
 LOC_MSG([  C compiler:                         ${CC} ${CFLAGS}])
 LOC_MSG([  C++ compiler:                       ${CXX} ${CXXFLAGS}])
 LOC_MSG([  Enable runtime linker paths:        ${HAVE_RPATH}])

+LOC_MSG([ Support Microsoft Document Imaging: ${HAVE_MDI}])
 LOC_MSG()
 LOC_MSG([ Support for internal codecs:])

 LOC_MSG([  CCITT Group 3 & 4 algorithms:       ${HAVE_CCITT}])
 LOC_MSG([  Macintosh PackBits algorithm:       ${HAVE_PACKBITS}])

Index: libtiff/tif_open.c

=================================================================== RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_open.c,v retrieving revision 1.27

diff -u -4 -p -r1.27 tif_open.c

--- libtiff/tif_open.c  12 Sep 2005 16:31:04 -0000      1.27
+++ libtiff/tif_open.c  20 Nov 2005 04:09:39 -0000

@@ -356,10 +356,22 @@ TIFFClientOpen(
        /*
         * Setup the byte order handling.
         */

        if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN &&

-           tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN) {
+           tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN
+#if MDI_SUPPORT
+           &&
+#if HOST_BIGENDIAN
+           tif->tif_header.tiff_magic != MDI_BIGENDIAN
+#else
+           tif->tif_header.tiff_magic != MDI_LITTLEENDIAN
+#endif
+           ) {
+               TIFFError(name,  "Not a TIFF or MDI file, bad magic number %d (0x%x)",
+#else
+           ) {

                TIFFError(name, "Not a TIFF file, bad magic number %d (0x%x)",
+#endif
                    tif->tif_header.tiff_magic,
                    tif->tif_header.tiff_magic);
                goto bad;
        }
Index: libtiff/tiff.h
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tiff.h,v
retrieving revision 1.38
diff -u -4 -p -r1.38 tiff.h

--- libtiff/tiff.h      26 Jul 2005 10:33:57 -0000      1.38
+++ libtiff/tiff.h      20 Nov 2005 04:09:40 -0000

@@ -49,9 +49,10 @@
 #define TIFF_BIGTIFF_VERSION 43

 #define        TIFF_BIGENDIAN          0x4d4d
 #define        TIFF_LITTLEENDIAN       0x4949
-
+#define        MDI_LITTLEENDIAN        0x5045
+#define        MDI_BIGENDIAN           0x4550

 /*