roentgen b75cab
/* $Id: tiffinfo.c,v 1.21 2012-06-06 06:05:29 fwarmerdam Exp $ */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Copyright (c) 1988-1997 Sam Leffler
roentgen b75cab
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
roentgen b75cab
 *
roentgen b75cab
 * Permission to use, copy, modify, distribute, and sell this software and 
roentgen b75cab
 * its documentation for any purpose is hereby granted without fee, provided
roentgen b75cab
 * that (i) the above copyright notices and this permission notice appear in
roentgen b75cab
 * all copies of the software and related documentation, and (ii) the names of
roentgen b75cab
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
roentgen b75cab
 * publicity relating to the software without the specific, prior written
roentgen b75cab
 * permission of Sam Leffler and Silicon Graphics.
roentgen b75cab
 * 
roentgen b75cab
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
roentgen b75cab
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
roentgen b75cab
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
roentgen b75cab
 * 
roentgen b75cab
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
roentgen b75cab
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
roentgen b75cab
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
roentgen b75cab
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
roentgen b75cab
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
roentgen b75cab
 * OF THIS SOFTWARE.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
#include "tif_config.h"
roentgen b75cab
roentgen b75cab
#include <stdio.h></stdio.h>
roentgen b75cab
#include <stdlib.h></stdlib.h>
roentgen b75cab
#include <string.h></string.h>
roentgen b75cab
roentgen b75cab
#ifdef HAVE_STRINGS_H
roentgen b75cab
# include <strings.h></strings.h>
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#ifdef HAVE_UNISTD_H
roentgen b75cab
# include <unistd.h></unistd.h>
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#ifdef NEED_LIBPORT
roentgen b75cab
# include "libport.h"
roentgen b75cab
#endif
roentgen b75cab
roentgen b75cab
#include "tiffiop.h"
roentgen b75cab
roentgen b75cab
static TIFFErrorHandler old_error_handler = 0;
roentgen b75cab
static int status = 0;                  /* exit status */
roentgen b75cab
static int showdata = 0;		/* show data */
roentgen b75cab
static int rawdata = 0;			/* show raw/decoded data */
roentgen b75cab
static int showwords = 0;		/* show data as bytes/words */
roentgen b75cab
static int readdata = 0;		/* read data in file */
roentgen b75cab
static int stoponerr = 1;		/* stop on first read error */
roentgen b75cab
roentgen b75cab
static	void usage(void);
roentgen b75cab
static	void tiffinfo(TIFF*, uint16, long, int);
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
PrivateErrorHandler(const char* module, const char* fmt, va_list ap)
roentgen b75cab
{
roentgen b75cab
        if (old_error_handler)
roentgen b75cab
                (*old_error_handler)(module,fmt,ap);
roentgen b75cab
	status = 1;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
main(int argc, char* argv[])
roentgen b75cab
{
roentgen b75cab
	int dirnum = -1, multiplefiles, c;
roentgen b75cab
	uint16 order = 0;
roentgen b75cab
	TIFF* tif;
roentgen b75cab
	extern int optind;
roentgen b75cab
	extern char* optarg;
roentgen b75cab
	long flags = 0;
roentgen b75cab
	uint64 diroff = 0;
roentgen b75cab
	int chopstrips = 0;		/* disable strip chopping */
roentgen b75cab
roentgen b75cab
	while ((c = getopt(argc, argv, "f:o:cdDSjilmrsvwz0123456789")) != -1)
roentgen b75cab
		switch (c) {
roentgen b75cab
		case '0': case '1': case '2': case '3':
roentgen b75cab
		case '4': case '5': case '6': case '7':
roentgen b75cab
		case '8': case '9':
roentgen b75cab
			dirnum = atoi(&argv[optind-1][1]);
roentgen b75cab
			break;
roentgen b75cab
		case 'd':
roentgen b75cab
			showdata++;
roentgen b75cab
			/* fall thru... */
roentgen b75cab
		case 'D':
roentgen b75cab
			readdata++;
roentgen b75cab
			break;
roentgen b75cab
		case 'c':
roentgen b75cab
			flags |= TIFFPRINT_COLORMAP | TIFFPRINT_CURVES;
roentgen b75cab
			break;
roentgen b75cab
		case 'f':		/* fill order */
roentgen b75cab
			if (streq(optarg, "lsb2msb"))
roentgen b75cab
				order = FILLORDER_LSB2MSB;
roentgen b75cab
			else if (streq(optarg, "msb2lsb"))
roentgen b75cab
				order = FILLORDER_MSB2LSB;
roentgen b75cab
			else
roentgen b75cab
				usage();
roentgen b75cab
			break;
roentgen b75cab
		case 'i':
roentgen b75cab
			stoponerr = 0;
roentgen b75cab
			break;
roentgen b75cab
		case 'o':
roentgen b75cab
			diroff = strtoul(optarg, NULL, 0);
roentgen b75cab
			break;
roentgen b75cab
		case 'j':
roentgen b75cab
			flags |= TIFFPRINT_JPEGQTABLES |
roentgen b75cab
				 TIFFPRINT_JPEGACTABLES |
roentgen b75cab
				 TIFFPRINT_JPEGDCTABLES;
roentgen b75cab
			break;
roentgen b75cab
		case 'r':
roentgen b75cab
			rawdata = 1;
roentgen b75cab
			break;
roentgen b75cab
		case 's':
roentgen b75cab
			flags |= TIFFPRINT_STRIPS;
roentgen b75cab
			break;
roentgen b75cab
		case 'w':
roentgen b75cab
			showwords = 1;
roentgen b75cab
			break;
roentgen b75cab
		case 'z':
roentgen b75cab
			chopstrips = 1;
roentgen b75cab
			break;
roentgen b75cab
		case '?':
roentgen b75cab
			usage();
roentgen b75cab
			/*NOTREACHED*/
roentgen b75cab
		}
roentgen b75cab
	if (optind >= argc)
roentgen b75cab
		usage();
roentgen b75cab
roentgen b75cab
	old_error_handler = TIFFSetErrorHandler(PrivateErrorHandler);
roentgen b75cab
roentgen b75cab
	multiplefiles = (argc - optind > 1);
roentgen b75cab
	for (; optind < argc; optind++) {
roentgen b75cab
		if (multiplefiles)
roentgen b75cab
			printf("%s:\n", argv[optind]);
roentgen b75cab
		tif = TIFFOpen(argv[optind], chopstrips ? "rC" : "rc");
roentgen b75cab
		if (tif != NULL) {
roentgen b75cab
			if (dirnum != -1) {
roentgen b75cab
				if (TIFFSetDirectory(tif, (tdir_t) dirnum))
roentgen b75cab
					tiffinfo(tif, order, flags, 1);
roentgen b75cab
			} else if (diroff != 0) {
roentgen b75cab
				if (TIFFSetSubDirectory(tif, diroff))
roentgen b75cab
					tiffinfo(tif, order, flags, 1);
roentgen b75cab
			} else {
roentgen b75cab
				do {
roentgen b75cab
					toff_t offset;
roentgen b75cab
roentgen b75cab
					tiffinfo(tif, order, flags, 1);
roentgen b75cab
					if (TIFFGetField(tif, TIFFTAG_EXIFIFD,
roentgen b75cab
							 &offset)) {
roentgen b75cab
						if (TIFFReadEXIFDirectory(tif, offset)) {
roentgen b75cab
							tiffinfo(tif, order, flags, 0);
roentgen b75cab
						}
roentgen b75cab
					}
roentgen b75cab
				} while (TIFFReadDirectory(tif));
roentgen b75cab
			}
roentgen b75cab
			TIFFClose(tif);
roentgen b75cab
		}
roentgen b75cab
	}
roentgen b75cab
	return (status);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
char* stuff[] = {
roentgen b75cab
"usage: tiffinfo [options] input...",
roentgen b75cab
"where options are:",
roentgen b75cab
" -D		read data",
roentgen b75cab
" -i		ignore read errors",
roentgen b75cab
" -c		display data for grey/color response curve or colormap",
roentgen b75cab
" -d		display raw/decoded image data",
roentgen b75cab
" -f lsb2msb	force lsb-to-msb FillOrder for input",
roentgen b75cab
" -f msb2lsb	force msb-to-lsb FillOrder for input",
roentgen b75cab
" -j		show JPEG tables",
roentgen b75cab
" -o offset	set initial directory offset",
roentgen b75cab
" -r		read/display raw image data instead of decoded data",
roentgen b75cab
" -s		display strip offsets and byte counts",
roentgen b75cab
" -w		display raw data in words rather than bytes",
roentgen b75cab
" -z		enable strip chopping",
roentgen b75cab
" -#		set initial directory (first directory is # 0)",
roentgen b75cab
NULL
roentgen b75cab
};
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
usage(void)
roentgen b75cab
{
roentgen b75cab
	char buf[BUFSIZ];
roentgen b75cab
	int i;
roentgen b75cab
roentgen b75cab
	setbuf(stderr, buf);
roentgen b75cab
        fprintf(stderr, "%s\n\n", TIFFGetVersion());
roentgen b75cab
	for (i = 0; stuff[i] != NULL; i++)
roentgen b75cab
		fprintf(stderr, "%s\n", stuff[i]);
roentgen b75cab
	exit(-1);
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
ShowStrip(tstrip_t strip, unsigned char* pp, uint32 nrow, tsize_t scanline)
roentgen b75cab
{
roentgen b75cab
	register tsize_t cc;
roentgen b75cab
roentgen b75cab
	printf("Strip %lu:\n", (unsigned long) strip);
roentgen b75cab
	while (nrow-- > 0) {
roentgen b75cab
		for (cc = 0; cc < scanline; cc++) {
roentgen b75cab
			printf(" %02x", *pp++);
roentgen b75cab
			if (((cc+1) % 24) == 0)
roentgen b75cab
				putchar('\n');
roentgen b75cab
		}
roentgen b75cab
		putchar('\n');
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadContigStripData(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	unsigned char *buf;
roentgen b75cab
	tsize_t scanline = TIFFScanlineSize(tif);
roentgen b75cab
roentgen b75cab
	buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif));
roentgen b75cab
	if (buf) {
roentgen b75cab
		uint32 row, h=0;
roentgen b75cab
		uint32 rowsperstrip = (uint32)-1;
roentgen b75cab
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
roentgen b75cab
		for (row = 0; row < h; row += rowsperstrip) {
roentgen b75cab
			uint32 nrow = (row+rowsperstrip > h ?
roentgen b75cab
			    h-row : rowsperstrip);
roentgen b75cab
			tstrip_t strip = TIFFComputeStrip(tif, row, 0);
roentgen b75cab
			if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) {
roentgen b75cab
				if (stoponerr)
roentgen b75cab
					break;
roentgen b75cab
			} else if (showdata)
roentgen b75cab
				ShowStrip(strip, buf, nrow, scanline);
roentgen b75cab
		}
roentgen b75cab
		_TIFFfree(buf);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadSeparateStripData(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	unsigned char *buf;
roentgen b75cab
	tsize_t scanline = TIFFScanlineSize(tif);
roentgen b75cab
roentgen b75cab
	buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif));
roentgen b75cab
	if (buf) {
roentgen b75cab
		uint32 row, h;
roentgen b75cab
		uint32 rowsperstrip = (uint32)-1;
roentgen b75cab
		tsample_t s, samplesperpixel;
roentgen b75cab
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
roentgen b75cab
		for (row = 0; row < h; row += rowsperstrip) {
roentgen b75cab
			for (s = 0; s < samplesperpixel; s++) {
roentgen b75cab
				uint32 nrow = (row+rowsperstrip > h ?
roentgen b75cab
				    h-row : rowsperstrip);
roentgen b75cab
				tstrip_t strip = TIFFComputeStrip(tif, row, s);
roentgen b75cab
				if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) {
roentgen b75cab
					if (stoponerr)
roentgen b75cab
						break;
roentgen b75cab
				} else if (showdata)
roentgen b75cab
					ShowStrip(strip, buf, nrow, scanline);
roentgen b75cab
			}
roentgen b75cab
		}
roentgen b75cab
		_TIFFfree(buf);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
ShowTile(uint32 row, uint32 col, tsample_t sample,
roentgen b75cab
    unsigned char* pp, uint32 nrow, tsize_t rowsize)
roentgen b75cab
{
roentgen b75cab
	uint32 cc;
roentgen b75cab
roentgen b75cab
	printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col);
roentgen b75cab
	if (sample != (tsample_t) -1)
roentgen b75cab
		printf(",%u", sample);
roentgen b75cab
	printf("):\n");
roentgen b75cab
	while (nrow-- > 0) {
roentgen b75cab
	  for (cc = 0; cc < (uint32) rowsize; cc++) {
roentgen b75cab
			printf(" %02x", *pp++);
roentgen b75cab
			if (((cc+1) % 24) == 0)
roentgen b75cab
				putchar('\n');
roentgen b75cab
		}
roentgen b75cab
		putchar('\n');
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadContigTileData(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	unsigned char *buf;
roentgen b75cab
	tsize_t rowsize = TIFFTileRowSize(tif);
roentgen b75cab
roentgen b75cab
	buf = (unsigned char *)_TIFFmalloc(TIFFTileSize(tif));
roentgen b75cab
	if (buf) {
roentgen b75cab
		uint32 tw, th, w, h;
roentgen b75cab
		uint32 row, col;
roentgen b75cab
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
roentgen b75cab
		for (row = 0; row < h; row += th) {
roentgen b75cab
			for (col = 0; col < w; col += tw) {
roentgen b75cab
				if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0) {
roentgen b75cab
					if (stoponerr)
roentgen b75cab
						break;
roentgen b75cab
				} else if (showdata)
roentgen b75cab
					ShowTile(row, col, (tsample_t) -1, buf, th, rowsize);
roentgen b75cab
			}
roentgen b75cab
		}
roentgen b75cab
		_TIFFfree(buf);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadSeparateTileData(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	unsigned char *buf;
roentgen b75cab
	tsize_t rowsize = TIFFTileRowSize(tif);
roentgen b75cab
roentgen b75cab
	buf = (unsigned char *)_TIFFmalloc(TIFFTileSize(tif));
roentgen b75cab
	if (buf) {
roentgen b75cab
		uint32 tw, th, w, h;
roentgen b75cab
		uint32 row, col;
roentgen b75cab
		tsample_t s, samplesperpixel;
roentgen b75cab
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
roentgen b75cab
		TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel);
roentgen b75cab
		for (row = 0; row < h; row += th) {
roentgen b75cab
			for (col = 0; col < w; col += tw) {
roentgen b75cab
				for (s = 0; s < samplesperpixel; s++) {
roentgen b75cab
					if (TIFFReadTile(tif, buf, col, row, 0, s) < 0) {
roentgen b75cab
						if (stoponerr)
roentgen b75cab
							break;
roentgen b75cab
					} else if (showdata)
roentgen b75cab
						ShowTile(row, col, s, buf, th, rowsize);
roentgen b75cab
				}
roentgen b75cab
			}
roentgen b75cab
		}
roentgen b75cab
		_TIFFfree(buf);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadData(TIFF* tif)
roentgen b75cab
{
roentgen b75cab
	uint16 config = PLANARCONFIG_CONTIG;
roentgen b75cab
roentgen b75cab
	TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config);
roentgen b75cab
	if (TIFFIsTiled(tif)) {
roentgen b75cab
		if (config == PLANARCONFIG_CONTIG)
roentgen b75cab
			TIFFReadContigTileData(tif);
roentgen b75cab
		else
roentgen b75cab
			TIFFReadSeparateTileData(tif);
roentgen b75cab
	} else {
roentgen b75cab
		if (config == PLANARCONFIG_CONTIG)
roentgen b75cab
			TIFFReadContigStripData(tif);
roentgen b75cab
		else
roentgen b75cab
			TIFFReadSeparateStripData(tif);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
ShowRawBytes(unsigned char* pp, uint32 n)
roentgen b75cab
{
roentgen b75cab
	uint32 i;
roentgen b75cab
roentgen b75cab
	for (i = 0; i < n; i++) {
roentgen b75cab
		printf(" %02x", *pp++);
roentgen b75cab
		if (((i+1) % 24) == 0)
roentgen b75cab
			printf("\n ");
roentgen b75cab
	}
roentgen b75cab
	putchar('\n');
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
ShowRawWords(uint16* pp, uint32 n)
roentgen b75cab
{
roentgen b75cab
	uint32 i;
roentgen b75cab
roentgen b75cab
	for (i = 0; i < n; i++) {
roentgen b75cab
		printf(" %04x", *pp++);
roentgen b75cab
		if (((i+1) % 15) == 0)
roentgen b75cab
			printf("\n ");
roentgen b75cab
	}
roentgen b75cab
	putchar('\n');
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
void
roentgen b75cab
TIFFReadRawData(TIFF* tif, int bitrev)
roentgen b75cab
{
roentgen b75cab
	tstrip_t nstrips = TIFFNumberOfStrips(tif);
roentgen b75cab
	const char* what = TIFFIsTiled(tif) ? "Tile" : "Strip";
roentgen b75cab
	uint64* stripbc;
roentgen b75cab
roentgen b75cab
	TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc);
roentgen b75cab
	if (nstrips > 0) {
roentgen b75cab
		uint32 bufsize = (uint32) stripbc[0];
roentgen b75cab
		tdata_t buf = _TIFFmalloc(bufsize);
roentgen b75cab
		tstrip_t s;
roentgen b75cab
roentgen b75cab
		for (s = 0; s < nstrips; s++) {
roentgen b75cab
			if (stripbc[s] > bufsize) {
roentgen b75cab
				buf = _TIFFrealloc(buf, (tmsize_t)stripbc[s]);
roentgen b75cab
				bufsize = (uint32) stripbc[s];
roentgen b75cab
			}
roentgen b75cab
			if (buf == NULL) {
roentgen b75cab
				fprintf(stderr,
roentgen b75cab
				   "Cannot allocate buffer to read strip %lu\n",
roentgen b75cab
				    (unsigned long) s);
roentgen b75cab
				break;
roentgen b75cab
			}
roentgen b75cab
			if (TIFFReadRawStrip(tif, s, buf, (tmsize_t) stripbc[s]) < 0) {
roentgen b75cab
				fprintf(stderr, "Error reading strip %lu\n",
roentgen b75cab
				    (unsigned long) s);
roentgen b75cab
				if (stoponerr)
roentgen b75cab
					break;
roentgen b75cab
			} else if (showdata) {
roentgen b75cab
				if (bitrev) {
roentgen b75cab
					TIFFReverseBits(buf, (tmsize_t)stripbc[s]);
roentgen b75cab
					printf("%s %lu: (bit reversed)\n ",
roentgen b75cab
					    what, (unsigned long) s);
roentgen b75cab
				} else
roentgen b75cab
					printf("%s %lu:\n ", what,
roentgen b75cab
					    (unsigned long) s);
roentgen b75cab
				if (showwords)
roentgen b75cab
					ShowRawWords((uint16*) buf, (uint32) stripbc[s]>>1);
roentgen b75cab
				else
roentgen b75cab
					ShowRawBytes((unsigned char*) buf, (uint32) stripbc[s]);
roentgen b75cab
			}
roentgen b75cab
		}
roentgen b75cab
		if (buf != NULL)
roentgen b75cab
			_TIFFfree(buf);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
static void
roentgen b75cab
tiffinfo(TIFF* tif, uint16 order, long flags, int is_image)
roentgen b75cab
{
roentgen b75cab
	TIFFPrintDirectory(tif, stdout, flags);
roentgen b75cab
	if (!readdata || !is_image)
roentgen b75cab
		return;
roentgen b75cab
	if (rawdata) {
roentgen b75cab
		if (order) {
roentgen b75cab
			uint16 o;
roentgen b75cab
			TIFFGetFieldDefaulted(tif,
roentgen b75cab
			    TIFFTAG_FILLORDER, &o);
roentgen b75cab
			TIFFReadRawData(tif, o != order);
roentgen b75cab
		} else
roentgen b75cab
			TIFFReadRawData(tif, 0);
roentgen b75cab
	} else {
roentgen b75cab
		if (order)
roentgen b75cab
			TIFFSetField(tif, TIFFTAG_FILLORDER, order);
roentgen b75cab
		TIFFReadData(tif);
roentgen b75cab
	}
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
/* vim: set ts=8 sts=8 sw=8 noet: */
roentgen b75cab
/*
roentgen b75cab
 * Local Variables:
roentgen b75cab
 * mode: c
roentgen b75cab
 * c-basic-offset: 8
roentgen b75cab
 * fill-column: 78
roentgen b75cab
 * End:
roentgen b75cab
 */