summaryrefslogtreecommitdiff
path: root/graphics/xv
diff options
context:
space:
mode:
authorhe <he@pkgsrc.org>2002-10-06 16:26:56 +0000
committerhe <he@pkgsrc.org>2002-10-06 16:26:56 +0000
commit3a629c102a4b9f7e43fa00e9ae6819b07fec8c9f (patch)
treec265c1960707ae4af56e59ea40f4aa5e5ebb4b9c /graphics/xv
parentf73fe83f8d542de1cf5dad9a1a0016bab3289e93 (diff)
downloadpkgsrc-3a629c102a4b9f7e43fa00e9ae6819b07fec8c9f.tar.gz
Merge in the multi-page TIFF file support patch from
ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch as found on http://www.trilon.com/xv/downloads.html#patches Bump package revision to 4.
Diffstat (limited to 'graphics/xv')
-rw-r--r--graphics/xv/Makefile4
-rw-r--r--graphics/xv/distinfo9
-rw-r--r--graphics/xv/patches/patch-ak15
-rw-r--r--graphics/xv/patches/patch-al27
-rw-r--r--graphics/xv/patches/patch-as42
-rw-r--r--graphics/xv/patches/patch-ax395
6 files changed, 468 insertions, 24 deletions
diff --git a/graphics/xv/Makefile b/graphics/xv/Makefile
index ebe5f9bd6fa..1b11875bace 100644
--- a/graphics/xv/Makefile
+++ b/graphics/xv/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.42 2002/07/29 13:02:24 tron Exp $
+# $NetBSD: Makefile,v 1.43 2002/10/06 16:26:56 he Exp $
DISTNAME= xv-3.10a
-PKGREVISION= 3
+PKGREVISION= 4
CATEGORIES= graphics x11
MASTER_SITES= ftp://ftp.cis.upenn.edu/pub/xv/ \
ftp://ftp.kuis.kyoto-u.ac.jp/X11/contrib/clients/xv/ \
diff --git a/graphics/xv/distinfo b/graphics/xv/distinfo
index 1c537bbe82a..89ab0ab46eb 100644
--- a/graphics/xv/distinfo
+++ b/graphics/xv/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.4 2002/08/09 18:06:35 drochner Exp $
+$NetBSD: distinfo,v 1.5 2002/10/06 16:26:56 he Exp $
SHA1 (xv-3.10a.tar.gz) = 9e6372f154be9e9e355972cbeb91d98d9c342474
Size (xv-3.10a.tar.gz) = 2259124 bytes
@@ -18,16 +18,17 @@ SHA1 (patch-ag) = 6802096dc1493a92379cd2750448407cf4e08dc4
SHA1 (patch-ah) = 5d9fbc3459c44e8c61f50d9f0624ec2069795af9
SHA1 (patch-ai) = 1beb3d45b08be536f297661f5dbdca050591548a
SHA1 (patch-aj) = 0df06a5187f43dd4a97f795d9ef29fe773b21806
-SHA1 (patch-ak) = 8b0c769a0bf7b7dd77c30a6981305b4812c8e140
-SHA1 (patch-al) = 3e710e219cbcc20435ad3b7079bf7ad61fa3170f
+SHA1 (patch-ak) = cfefb6ed9d0747f620f9ea4dcfc948fd8355f137
+SHA1 (patch-al) = 7a1118af7b5581ab0fd28b95d4a973aefb544b09
SHA1 (patch-am) = 2995c284e62fe5bb669eb0562d120a671b0b30ce
SHA1 (patch-an) = 8eb0076fc932ad3859e72b5de228806457e812f8
SHA1 (patch-ao) = 36681bfa24df5715b7203e27c0cfd477890c8c58
SHA1 (patch-ap) = d80d3f42ef65f8941a9a2b318ec3895cf35a6fa4
SHA1 (patch-aq) = 5ab291d650c65437000951c6cbb42c0b7799db8f
SHA1 (patch-ar) = 61747379c2f080d13bc76b2175e8e7ae61647374
-SHA1 (patch-as) = f960648c9ce6e86c13dbd1cca091c4cc71ea7d08
+SHA1 (patch-as) = 03e8fafaf267fda7e17aee58ba48096796161e74
SHA1 (patch-at) = a2c2c57ad852006b66addc5c88f73fce7d4716eb
SHA1 (patch-au) = 3cb2fde94db4b71a449c81e4b912132b204b0062
SHA1 (patch-av) = cb815b12de135927cad826623c5071e938a59509
SHA1 (patch-aw) = 2085110d88d34a78d14b68dd6a3cbff56251352f
+SHA1 (patch-ax) = 81adbda29a9e3633085bd41b409f5795d0f353b1
diff --git a/graphics/xv/patches/patch-ak b/graphics/xv/patches/patch-ak
index b678e3d64a3..cbdb7dc0e21 100644
--- a/graphics/xv/patches/patch-ak
+++ b/graphics/xv/patches/patch-ak
@@ -1,14 +1,17 @@
-$NetBSD: patch-ak,v 1.1 2001/04/05 13:57:16 wiz Exp $
+$NetBSD: patch-ak,v 1.2 2002/10/06 16:26:57 he Exp $
This patch is based on
http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
It was edited to fit into the NetBSD Packages Collection! - HF
+It is also modified by
+ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
+
---------------------------------------------------------------------------
---- xv.c.patched Sun Jun 13 02:45:51 1999
-+++ xv.c Sun Jun 13 02:49:26 1999
+--- xv.c.orig Fri Aug 9 17:09:06 2002
++++ xv.c
@@ -279,6 +279,10 @@
pcdW = (Window) NULL; pcdUp = 0;
@@ -44,10 +47,12 @@ It was edited to fit into the NetBSD Packages Collection! - HF
#ifdef HAVE_PDS
else if (strncmp((char *) magicno, "NJPL1I00", (size_t) 8)==0 ||
strncmp((char *) magicno+2,"NJPL1I", (size_t) 6)==0 ||
-@@ -2740,6 +2754,10 @@
+@@ -2739,7 +2753,11 @@
+ #endif
#ifdef HAVE_TIFF
- case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
+- case RFT_TIFF: rv = LoadTIFF (fname, pinfo); break;
++ case RFT_TIFF: rv = LoadTIFF (fname, pinfo, quick); break;
+#endif
+
+#ifdef HAVE_PNG
diff --git a/graphics/xv/patches/patch-al b/graphics/xv/patches/patch-al
index fc2194f680e..28d8190fa70 100644
--- a/graphics/xv/patches/patch-al
+++ b/graphics/xv/patches/patch-al
@@ -1,14 +1,17 @@
-$NetBSD: patch-al,v 1.1 2001/04/05 13:57:16 wiz Exp $
+$NetBSD: patch-al,v 1.2 2002/10/06 16:26:57 he Exp $
This patch is based on
http://www.mit.edu/afs/athena/contrib/graphics/src/xv/patches/png/xvpng.diff
It was edited to fit into the NetBSD Packages Collection! - HF
+It is also modified by
+ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
+
---------------------------------------------------------------------------
---- xv.h.orig Sun Jun 13 03:41:34 1999
-+++ xv.h Sun Jun 13 03:53:34 1999
+--- xv.h.orig Fri Aug 9 17:09:14 2002
++++ xv.h
@@ -8,8 +8,8 @@
#include "config.h"
@@ -128,7 +131,15 @@ It was edited to fit into the NetBSD Packages Collection! - HF
#undef WHERE
-@@ -1506,12 +1526,12 @@
+@@ -1289,6 +1309,7 @@
+ void xv_getwd PARM((char *, size_t));
+ char *xv_strstr PARM((char *, char *));
+ FILE *xv_fopen PARM((char *, char *));
++void xv_mktemp PARM((char *, char *));
+ void Timer PARM((int));
+
+ /*************************** XVCOLOR.C ***************************/
+@@ -1506,12 +1527,12 @@
/*************************** XVDIAL.C ***************************/
@@ -146,7 +157,13 @@ It was edited to fit into the NetBSD Packages Collection! - HF
void DSetActive PARM((DIAL *, int));
void DRedraw PARM((DIAL *));
int DTrack PARM((DIAL *, int, int));
-@@ -1653,6 +1673,13 @@
+@@ -1648,11 +1669,18 @@
+ void JPEGSaveParams PARM((char *, int));
+
+ /**************************** XVTIFF.C ***************************/
+-int LoadTIFF PARM((char *, PICINFO *));
++int LoadTIFF PARM((char *, PICINFO *, int));
+ void CreateTIFFW PARM((void));
void TIFFDialog PARM((int));
int TIFFCheckEvent PARM((XEvent *));
void TIFFSaveParams PARM((char *, int));
diff --git a/graphics/xv/patches/patch-as b/graphics/xv/patches/patch-as
index 91f62b41163..bb57067a215 100644
--- a/graphics/xv/patches/patch-as
+++ b/graphics/xv/patches/patch-as
@@ -1,8 +1,17 @@
-$NetBSD: patch-as,v 1.1 2001/04/05 13:57:17 wiz Exp $
+$NetBSD: patch-as,v 1.2 2002/10/06 16:26:57 he Exp $
---- xvmisc.c.orig Sun Nov 14 14:05:45 1999
-+++ xvmisc.c Sun Nov 14 14:05:49 1999
-@@ -522,6 +522,10 @@
+--- xvmisc.c.orig Fri Aug 9 17:09:23 2002
++++ xvmisc.c
+@@ -28,6 +28,8 @@
+ * int xvbcmp (s1, s2, length)
+ * void xvbzero(s, length)
+ * char *xv_strstr(s1, s2)
++ * FILE *xv_fopen(str, str)
++ * void xv_mktemp(str)
+ * void Timer(milliseconds)
+ */
+
+@@ -522,6 +524,10 @@
if (pcdW) XDestroyWindow(theDisp, pcdW);
@@ -13,14 +22,31 @@ $NetBSD: patch-as,v 1.1 2001/04/05 13:57:17 wiz Exp $
/* if NOT using stdcmap for images, free stdcmap */
if (colorMapMode != CM_STDCMAP) {
int j;
-@@ -717,6 +721,10 @@
-
+@@ -718,6 +724,10 @@
#ifdef HAVE_TIFF
if (tiffW) XDefineCursor(theDisp, tiffW, otherc);
-+#endif
+ #endif
+
+#ifdef HAVE_PNG
+ if (pngW) XDefineCursor(theDisp, pngW, otherc);
- #endif
++#endif
if (pcdW) XDefineCursor(theDisp, pcdW, otherc);
+ }
+@@ -1070,6 +1080,16 @@
+ }
+
+
++/***************************************************/
++void xv_mktemp(buf, fname)
++ char *buf, *fname;
++{
++#ifndef VMS
++ sprintf(buf, "%s/%s", tmpdir, fname);
++#else
++ sprintf(buf, "Sys$Disk:[]%s", fname);
++#endif
++}
+
+
+ /*******/
diff --git a/graphics/xv/patches/patch-ax b/graphics/xv/patches/patch-ax
new file mode 100644
index 00000000000..715d2e541b1
--- /dev/null
+++ b/graphics/xv/patches/patch-ax
@@ -0,0 +1,395 @@
+$NetBSD: patch-ax,v 1.1 2002/10/06 16:26:57 he Exp $
+
+This patch is partly based on
+ ftp://ftp.trilon.com/pub/xv/patches/mp-tiff-patch
+as found on
+ http://www.trilon.com/xv/downloads.html#patches
+It was edited to fit into the NetBSD Packages Collection! - HE
+
+------------------------------------------------------------
+
+
+--- xvtiff.c.orig Fri Aug 9 17:22:16 2002
++++ xvtiff.c
+@@ -1,7 +1,7 @@
+ /*
+ * xvtiff.c - load routine for 'TIFF' format pictures
+ *
+- * LoadTIFF(fname, numcols) - load a TIFF file
++ * LoadTIFF(fname, numcols, quick) - load a TIFF file
+ */
+
+ #ifndef va_start
+@@ -15,6 +15,35 @@
+ #include "tiffio.h" /* has to be after xv.h, as it needs varargs/stdarg */
+
+
++/* Portions fall under the following copyright:
++ *
++ * Copyright (c) 1992, 1993, 1994 Sam Leffler
++ * Copyright (c) 1992, 1993, 1994 Silicon Graphics, Inc.
++ *
++ * Permission to use, copy, modify, distribute, and sell this software and
++ * its documentation for any purpose is hereby granted without fee, provided
++ * that (i) the above copyright notices and this permission notice appear in
++ * all copies of the software and related documentation, and (ii) the names of
++ * Sam Leffler and Silicon Graphics may not be used in any advertising or
++ * publicity relating to the software without the specific, prior written
++ * permission of Sam Leffler and Silicon Graphics.
++ *
++ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
++ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
++ *
++ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
++ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
++ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
++ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
++ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
++ * OF THIS SOFTWARE.
++ */
++
++
++static int copyTiff PARM((TIFF *, char *));
++static int cpStrips PARM((TIFF *, TIFF *));
++static int cpTiles PARM((TIFF *, TIFF *));
+ static byte *loadPalette PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
+ static byte *loadColor PARM((TIFF *, uint32, uint32, int, int, PICINFO *));
+ static int loadImage PARM((TIFF *, uint32, uint32, byte *, int));
+@@ -28,19 +57,23 @@
+ static int error_occurred;
+
+ /*******************************************/
+-int LoadTIFF(fname, pinfo)
+- char *fname;
++int LoadTIFF(fname, pinfo, quick)
++ char *fname;
+ PICINFO *pinfo;
++ int quick;
+ /*******************************************/
+ {
+ /* returns '1' on success, '0' on failure */
+
+ TIFF *tif;
+ uint32 w, h;
++ float xres, yres;
+ short bps, spp, photo, orient;
+ FILE *fp;
+ byte *pic8;
+ char *desc, oldpath[MAXPATHLEN+1], tmppath[MAXPATHLEN+1], *sp;
++ char tmp[256], tmpname[256];
++ int i, nump;
+
+ error_occurred = 0;
+
+@@ -60,6 +93,8 @@
+ filesize = ftell(fp);
+ fclose(fp);
+
++
++
+ rmap = pinfo->r; gmap = pinfo->g; bmap = pinfo->b;
+
+ /* a kludge: temporarily cd to the directory that the file is in (if
+@@ -81,9 +116,57 @@
+ }
+ }
+
++
++ nump = 1;
++
++ if (!quick) {
++ /* see if there's more than 1 image in tiff file, to determine if we
++ should do multi-page thing... */
++
++ tif = TIFFOpen(filename,"r");
++ if (!tif) return 0;
++ while (TIFFReadDirectory(tif)) nump++;
++ TIFFClose(tif);
++ if (DEBUG)
++ fprintf(stderr,"LoadTIFF: %d page%s found\n", nump, nump==1 ? "" : "s");
++
++
++ /* if there are multiple images, copy them out to multiple tmp files,
++ and load the first one... */
++
++ xv_mktemp(tmpname, "xvpgXXXXXX");
++
++ if (tmpname[0] == '\0') { /* mktemp() blew up */
++ sprintf(str,"LoadTIFF: Unable to create temporary filename???");
++ ErrPopUp(str, "\nHow unlikely!");
++ return 0;
++ }
+
++ if (nump>1) {
++ TIFF *in, *out;
++
++ in = TIFFOpen(filename, "r");
++ if (!in) return 0;
++ for (i=1; i<=nump; i++) {
++ sprintf(tmp, "%s%d", tmpname, i);
++ if (!copyTiff(in, tmp)) {
++ SetISTR(ISTR_WARNING, "LoadTIFF: Error writing page files!");
++ break;
++ }
++
++ if (!TIFFReadDirectory(in)) break;
++ }
++ if (DEBUG)
++ fprintf(stderr,"LoadTIFF: %d page%s written\n",
++ i-1, (i-1)==1 ? "" : "s");
++
++ sprintf(tmp, "%s%d", tmpname, 1); /* open page #1 */
++ filename = tmp;
++ }
++ } /* if (!quick) ... */
+
+- tif=TIFFOpen(filename,"r");
++
++ tif = TIFFOpen(filename,"r");
+ if (!tif) return 0;
+
+ /* flip orientation so that image comes in X order */
+@@ -107,6 +190,11 @@
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bps);
+ TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photo);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &spp);
++ if ((TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) == 1) &&
++ (TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) == 1)) {
++ normaspect = yres / xres;
++ if (DEBUG) fprintf(stderr,"TIFF aspect = %f\n", normaspect);
++ }
+
+ if (spp == 1) {
+ pic8 = loadPalette(tif, w, h, photo, bps, pinfo);
+@@ -139,6 +227,8 @@
+ if (pic8) free(pic8);
+ if (pinfo->comment) free(pinfo->comment);
+ pinfo->comment = (char *) NULL;
++ if (!quick && nump>1) KillPageFiles(tmpname, nump);
++ SetCursors(-1);
+ return 0;
+ }
+
+@@ -148,17 +238,167 @@
+ pinfo->normw = pinfo->w; pinfo->normh = pinfo->h;
+ pinfo->frmType = F_TIFF;
+
++ if (nump>1) strcpy(pinfo->pagebname, tmpname);
++ pinfo->numpages = nump;
+
+ if (pinfo->pic) return 1;
+
++
+ /* failed. if we malloc'd a comment, free it */
+ if (pinfo->comment) free(pinfo->comment);
+ pinfo->comment = (char *) NULL;
+
++ if (!quick && nump>1) KillPageFiles(tmpname, nump);
++ SetCursors(-1);
++
+ return 0;
+ }
+
+
++
++
++/*******************************************/
++
++#define CopyField(tag, v) \
++ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
++#define CopyField2(tag, v1, v2) \
++ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2)
++#define CopyField3(tag, v1, v2, v3) \
++ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3)
++
++
++/*******************************************/
++static int copyTiff(in, fname)
++ TIFF *in;
++ char *fname;
++{
++ /* copies tiff image to given filename. Returns 0 on error */
++
++ TIFF *out;
++ short bitspersample, samplesperpixel, shortv, *shortav;
++ uint32 w, l;
++ float floatv;
++ char *stringv;
++ uint32 longv;
++ uint16 *red, *green, *blue, shortv2;
++ int rv;
++
++ out = TIFFOpen(fname, "w");
++ if (!out) return 0;
++
++ CopyField (TIFFTAG_SUBFILETYPE, longv);
++ CopyField (TIFFTAG_TILEWIDTH, w);
++ CopyField (TIFFTAG_TILELENGTH, l);
++ CopyField (TIFFTAG_IMAGEWIDTH, w);
++ CopyField (TIFFTAG_IMAGELENGTH, l);
++ CopyField (TIFFTAG_BITSPERSAMPLE, bitspersample);
++ CopyField (TIFFTAG_COMPRESSION, shortv);
++ CopyField (TIFFTAG_PREDICTOR, shortv);
++ CopyField (TIFFTAG_PHOTOMETRIC, shortv);
++ CopyField (TIFFTAG_THRESHHOLDING, shortv);
++ CopyField (TIFFTAG_FILLORDER, shortv);
++ CopyField (TIFFTAG_ORIENTATION, shortv);
++ CopyField (TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
++ CopyField (TIFFTAG_MINSAMPLEVALUE, shortv);
++ CopyField (TIFFTAG_MAXSAMPLEVALUE, shortv);
++ CopyField (TIFFTAG_XRESOLUTION, floatv);
++ CopyField (TIFFTAG_YRESOLUTION, floatv);
++ CopyField (TIFFTAG_GROUP3OPTIONS, longv);
++ CopyField (TIFFTAG_GROUP4OPTIONS, longv);
++ CopyField (TIFFTAG_RESOLUTIONUNIT, shortv);
++ CopyField (TIFFTAG_PLANARCONFIG, shortv);
++ CopyField (TIFFTAG_ROWSPERSTRIP, longv);
++ CopyField (TIFFTAG_XPOSITION, floatv);
++ CopyField (TIFFTAG_YPOSITION, floatv);
++ CopyField (TIFFTAG_IMAGEDEPTH, longv);
++ CopyField (TIFFTAG_TILEDEPTH, longv);
++ CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav);
++ CopyField3(TIFFTAG_COLORMAP, red, green, blue);
++ CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2);
++ CopyField (TIFFTAG_ARTIST, stringv);
++ CopyField (TIFFTAG_IMAGEDESCRIPTION,stringv);
++ CopyField (TIFFTAG_MAKE, stringv);
++ CopyField (TIFFTAG_MODEL, stringv);
++ CopyField (TIFFTAG_SOFTWARE, stringv);
++ CopyField (TIFFTAG_DATETIME, stringv);
++ CopyField (TIFFTAG_HOSTCOMPUTER, stringv);
++ CopyField (TIFFTAG_PAGENAME, stringv);
++ CopyField (TIFFTAG_DOCUMENTNAME, stringv);
++
++ if (TIFFIsTiled(in)) rv = cpTiles (in, out);
++ else rv = cpStrips(in, out);
++
++ TIFFClose(out);
++ return rv;
++}
++
++
++/*******************************************/
++static int cpStrips(in, out)
++ TIFF *in, *out;
++{
++ tsize_t bufsize;
++ byte *buf;
++
++ bufsize = TIFFStripSize(in);
++ buf = (byte *) malloc((size_t) bufsize);
++ if (buf) {
++ tstrip_t s, ns = TIFFNumberOfStrips(in);
++ uint32 *bytecounts;
++
++ TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts);
++ for (s = 0; s < ns; s++) {
++ if (bytecounts[s] > bufsize) {
++ buf = (unsigned char *) realloc(buf, (size_t) bytecounts[s]);
++ if (!buf) return (0);
++ bufsize = bytecounts[s];
++ }
++ if (TIFFReadRawStrip (in, s, buf, (tsize_t) bytecounts[s]) < 0 ||
++ TIFFWriteRawStrip(out, s, buf, (tsize_t) bytecounts[s]) < 0) {
++ free(buf);
++ return 0;
++ }
++ }
++ free(buf);
++ return 1;
++ }
++ return 0;
++}
++
++
++/*******************************/
++static int cpTiles(in, out)
++ TIFF *in, *out;
++{
++ tsize_t bufsize;
++ byte *buf;
++
++ bufsize = TIFFTileSize(in);
++ buf = (unsigned char *) malloc((size_t) bufsize);
++ if (buf) {
++ ttile_t t, nt = TIFFNumberOfTiles(in);
++ uint32 *bytecounts;
++
++ TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts);
++ for (t = 0; t < nt; t++) {
++ if (bytecounts[t] > bufsize) {
++ buf = (unsigned char *)realloc(buf, (size_t) bytecounts[t]);
++ if (!buf) return (0);
++ bufsize = bytecounts[t];
++ }
++ if (TIFFReadRawTile (in, t, buf, (tsize_t) bytecounts[t]) < 0 ||
++ TIFFWriteRawTile(out, t, buf, (tsize_t) bytecounts[t]) < 0) {
++ free(buf);
++ return 0;
++ }
++ }
++ free(buf);
++ return 1;
++ }
++ return 0;
++}
++
++
+ /*******************************************/
+ static byte *loadPalette(tif, w, h, photo, bps, pinfo)
+ TIFF *tif;
+@@ -186,7 +426,7 @@
+ break;
+ }
+
+- sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
++ sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h);
+
+ pic8 = (byte *) malloc((size_t) w*h);
+ if (!pic8) FatalError("loadPalette() - couldn't malloc 'pic8'");
+@@ -214,7 +454,7 @@
+ "???"),
+ filesize);
+
+- sprintf(pinfo->shrtInfo, "%ux%u TIFF.",w,h);
++ sprintf(pinfo->shrtInfo, "%ux%u TIFF.",(u_int) w, (u_int) h);
+
+ /* allocate 24-bit image */
+ pic24 = (byte *) malloc((size_t) w*h*3);
+@@ -1018,7 +1258,7 @@
+ #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; }
+
+ #define UNROLL8(w, op1, op2) { \
+- uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 8; x -= 8) { \
+ op1; \
+ REPEAT8(op2); \
+@@ -1030,7 +1270,7 @@
+ }
+
+ #define UNROLL4(w, op1, op2) { \
+- register uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 4; x -= 4) { \
+ op1; \
+ REPEAT4(op2); \
+@@ -1042,7 +1282,7 @@
+ }
+
+ #define UNROLL2(w, op1, op2) { \
+- register uint32 x; \
++ uint32 x; \
+ for (x = w; x >= 2; x -= 2) { \
+ op1; \
+ REPEAT2(op2); \
+@@ -1384,7 +1624,7 @@
+ }
+ }
+
+-#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB))
++#define Code2V(c, RB, RW, CR) (((((int)c)-(int)RB)*(float)CR)/(float)(RW-RB))
+
+ #define CLAMP(f,min,max) \
+ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5)