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