recognize both big-endian and little-endian TIFF files.

Thu, 20 Mar 2003 15:22:23 +0000

author
eric
date
Thu, 20 Mar 2003 15:22:23 +0000
changeset 152
e69798068425
parent 151
83a99cc69861
child 153
4a4a5b5fd6e5

recognize both big-endian and little-endian TIFF files.

tumble_tiff.c file | annotate | diff | revisions
     1.1 --- a/tumble_tiff.c	Thu Mar 20 14:55:28 2003 +0000
     1.2 +++ b/tumble_tiff.c	Thu Mar 20 15:22:23 2003 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  /*
     1.5   * tumble: build a PDF file from image files
     1.6   *
     1.7 - * $Id: tumble_tiff.c,v 1.4 2003/03/20 06:55:28 eric Exp $
     1.8 + * $Id: tumble_tiff.c,v 1.5 2003/03/20 07:22:23 eric Exp $
     1.9   * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
    1.10   *
    1.11   * This program is free software; you can redistribute it and/or modify
    1.12 @@ -28,6 +28,12 @@
    1.13  #include <strings.h>  /* strcasecmp() is a BSDism */
    1.14  
    1.15  #include <tiffio.h>
    1.16 +/*
    1.17 + * On the x86, libtiff defaults to bit-endian bit order for no good reason.
    1.18 + * In theory, the '-L' (and maybe '-H') should give us little-endian bit
    1.19 + * order, but it doesn't seem to work.  Thus we reverse the bits ourselves
    1.20 + * after we read in the file.
    1.21 + */
    1.22  #define TIFF_REVERSE_BITS
    1.23  
    1.24  
    1.25 @@ -69,7 +75,8 @@
    1.26  
    1.27    rewind (f);
    1.28  
    1.29 -  if ((buf [0] != 0x49) || (buf [1] != 0x49))
    1.30 +  if (! (((buf [0] == 0x49) && (buf [1] == 0x49)) ||
    1.31 +	 ((buf [0] == 0x4d) && (buf [1] == 0x4d))))
    1.32      return (0);
    1.33  
    1.34    tiff_in = TIFFFdOpen (fileno (f), name, "r");