summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Leffler <sam@engr.sgi.com>1997-09-01 03:22:05 +0100
committerRoger Leigh <rleigh@codelibre.net>2022-06-22 19:41:27 +0100
commit0db24a4dc6b63cb897d1179d5e0a639707ab6868 (patch)
tree58f3974d5cde95e12b6df96d8e35c83bd3fc0798
parent7b7dc6a9696b7d7fb1c2fcdd355ee0e3a9d22c2d (diff)
downloadlibtiff-git-tiff-3.4.tar.gz
v3.4beta037 releasev3.4beta037tiff-3.4
-rw-r--r--COPYRIGHT4
-rw-r--r--Makefile.in75
-rw-r--r--README6
-rw-r--r--TODO2
-rw-r--r--config.site6
-rwxr-xr-xconfigure10
-rw-r--r--contrib/dosdjgpp/Makefile.lib2
-rw-r--r--contrib/dosdjgpp/Makefile.tools2
-rw-r--r--contrib/dosdjgpp/Makefile.top2
-rw-r--r--contrib/mfs/README37
-rw-r--r--contrib/mfs/mfs_file.c579
-rw-r--r--contrib/pds/README90
-rw-r--r--contrib/pds/tif_imageiter.c518
-rw-r--r--contrib/pds/tif_imageiter.h57
-rw-r--r--contrib/pds/tif_pdsdirread.c1124
-rw-r--r--contrib/pds/tif_pdsdirwrite.c964
-rw-r--r--contrib/ras/README10
-rw-r--r--contrib/winnt/README.console182
-rwxr-xr-xdist/newalpha2
-rw-r--r--dist/newversion2
-rw-r--r--dist/tiff.alpha2
-rw-r--r--dist/tiff.spec6
-rw-r--r--html/Makefile.in6
-rw-r--r--html/build.html21
-rw-r--r--html/contrib.html36
-rw-r--r--html/document.html28
-rw-r--r--html/images.html16
-rw-r--r--html/index.html20
-rw-r--r--html/internals.html43
-rw-r--r--html/libtiff.html19
-rw-r--r--html/misc.html29
-rw-r--r--html/support.html36
-rw-r--r--html/tools.html12
-rw-r--r--libtiff/Makefile.in12
-rw-r--r--libtiff/Makefile.lcc6
-rw-r--r--libtiff/mkg3states.c6
-rw-r--r--libtiff/mkspans.c6
-rwxr-xr-xlibtiff/mkversion.c6
-rw-r--r--libtiff/t4.h6
-rwxr-xr-xlibtiff/tif_acorn.c6
-rw-r--r--libtiff/tif_apple.c6
-rw-r--r--libtiff/tif_atari.c6
-rw-r--r--libtiff/tif_aux.c6
-rw-r--r--libtiff/tif_close.c6
-rw-r--r--libtiff/tif_codec.c13
-rw-r--r--libtiff/tif_compress.c6
-rw-r--r--libtiff/tif_dir.c71
-rw-r--r--libtiff/tif_dir.h11
-rw-r--r--libtiff/tif_dirinfo.c20
-rw-r--r--libtiff/tif_dirread.c6
-rw-r--r--libtiff/tif_dirwrite.c28
-rw-r--r--libtiff/tif_dumpmode.c6
-rw-r--r--libtiff/tif_error.c6
-rw-r--r--libtiff/tif_fax3.c6
-rw-r--r--libtiff/tif_fax3.h6
-rw-r--r--libtiff/tif_flush.c6
-rw-r--r--libtiff/tif_getimage.c58
-rw-r--r--libtiff/tif_jpeg.c6
-rw-r--r--libtiff/tif_luv.c1428
-rw-r--r--libtiff/tif_lzw.c6
-rw-r--r--libtiff/tif_msdos.c6
-rw-r--r--libtiff/tif_next.c6
-rw-r--r--libtiff/tif_open.c6
-rw-r--r--libtiff/tif_packbits.c6
-rw-r--r--libtiff/tif_pixarlog.c37
-rw-r--r--libtiff/tif_predict.c15
-rw-r--r--libtiff/tif_predict.h6
-rw-r--r--libtiff/tif_print.c27
-rw-r--r--libtiff/tif_read.c8
-rw-r--r--libtiff/tif_strip.c6
-rw-r--r--libtiff/tif_swab.c6
-rw-r--r--libtiff/tif_thunder.c6
-rw-r--r--libtiff/tif_tile.c6
-rw-r--r--libtiff/tif_unix.c6
-rw-r--r--libtiff/tif_version.c6
-rw-r--r--libtiff/tif_vms.c6
-rw-r--r--libtiff/tif_warning.c6
-rw-r--r--libtiff/tif_win3.c8
-rw-r--r--libtiff/tif_win32.c61
-rw-r--r--libtiff/tif_write.c24
-rw-r--r--libtiff/tif_zip.c17
-rw-r--r--libtiff/tiff.h19
-rw-r--r--libtiff/tiffcomp.h6
-rw-r--r--libtiff/tiffconf.h8
-rw-r--r--libtiff/tiffio.h7
-rw-r--r--libtiff/tiffiop.h22
-rw-r--r--libtiff/uvcode.h173
-rw-r--r--man/Makefile.in6
-rw-r--r--man/TIFFClose.3t6
-rw-r--r--man/TIFFError.3t6
-rw-r--r--man/TIFFFlush.3t6
-rw-r--r--man/TIFFGetField.3t9
-rw-r--r--man/TIFFOpen.3t6
-rw-r--r--man/TIFFPrintDirectory.3t6
-rw-r--r--man/TIFFRGBAImage.3t6
-rw-r--r--man/TIFFReadDirectory.3t6
-rw-r--r--man/TIFFReadEncodedStrip.3t6
-rw-r--r--man/TIFFReadEncodedTile.3t6
-rw-r--r--man/TIFFReadRGBAImage.3t6
-rw-r--r--man/TIFFReadRawStrip.3t6
-rw-r--r--man/TIFFReadRawTile.3t6
-rw-r--r--man/TIFFReadScanline.3t6
-rw-r--r--man/TIFFReadTile.3t6
-rw-r--r--man/TIFFSetDirectory.3t6
-rw-r--r--man/TIFFSetField.3t20
-rw-r--r--man/TIFFWarning.3t6
-rw-r--r--man/TIFFWriteDirectory.3t6
-rw-r--r--man/TIFFWriteEncodedStrip.3t6
-rw-r--r--man/TIFFWriteEncodedTile.3t6
-rw-r--r--man/TIFFWriteRawStrip.3t6
-rw-r--r--man/TIFFWriteRawTile.3t6
-rw-r--r--man/TIFFWriteScanline.3t6
-rw-r--r--man/TIFFbuffer.3t2
-rw-r--r--man/TIFFcodec.3t2
-rw-r--r--man/TIFFmemory.3t2
-rw-r--r--man/TIFFquery.3t6
-rw-r--r--man/TIFFsize.3t6
-rw-r--r--man/TIFFstrip.3t6
-rw-r--r--man/TIFFswab.3t6
-rw-r--r--man/TIFFtile.3t6
-rw-r--r--man/fax2ps.16
-rw-r--r--man/fax2tiff.16
-rw-r--r--man/gif2tiff.16
-rw-r--r--man/libtiff.3t75
-rw-r--r--man/pal2rgb.16
-rw-r--r--man/ppm2tiff.16
-rw-r--r--man/ras2tiff.16
-rw-r--r--man/rgb2ycbcr.16
-rw-r--r--man/sgi2tiff.16
-rw-r--r--man/thumbnail.16
-rw-r--r--man/tiff2bw.16
-rw-r--r--man/tiff2ps.16
-rw-r--r--man/tiffcmp.16
-rw-r--r--man/tiffcp.16
-rw-r--r--man/tiffdither.16
-rw-r--r--man/tiffdump.16
-rw-r--r--man/tiffgt.16
-rw-r--r--man/tiffinfo.16
-rw-r--r--man/tiffmedian.16
-rw-r--r--man/tiffsplit.16
-rw-r--r--man/tiffsv.16
-rw-r--r--port/Makefile.in6
-rw-r--r--port/install.sh.in6
-rw-r--r--tools/Makefile.in6
-rw-r--r--tools/Makefile.lcc6
-rw-r--r--tools/fax2ps.c6
-rw-r--r--tools/fax2tiff.c6
-rw-r--r--tools/gif2tiff.c13
-rw-r--r--tools/pal2rgb.c6
-rw-r--r--tools/ppm2tiff.c6
-rw-r--r--tools/ras2tiff.c6
-rw-r--r--tools/rasterfile.h2
-rw-r--r--tools/rgb2ycbcr.c6
-rw-r--r--tools/sgi2tiff.c6
-rw-r--r--tools/sgigt.c18
-rw-r--r--tools/sgisv.c6
-rw-r--r--tools/thumbnail.c6
-rw-r--r--tools/tiff2bw.c6
-rw-r--r--tools/tiff2ps.c55
-rw-r--r--tools/tiffcmp.c6
-rw-r--r--tools/tiffcp.c71
-rw-r--r--tools/tiffdither.c6
-rw-r--r--tools/tiffdump.c8
-rw-r--r--tools/tiffinfo.c6
-rw-r--r--tools/tiffmedian.c9
-rw-r--r--tools/tiffsplit.c6
166 files changed, 6170 insertions, 725 deletions
diff --git a/COPYRIGHT b/COPYRIGHT
index b9fc9fe2..82821861 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
-Copyright (c) 1988-1996 Sam Leffler
-Copyright (c) 1991-1996 Silicon Graphics, Inc.
+Copyright (c) 1988-1997 Sam Leffler
+Copyright (c) 1991-1997 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
diff --git a/Makefile.in b/Makefile.in
index 6389aef0..10c5b56a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,12 +1,12 @@
#! smake
-# $Header: /usr/people/sam/tiff/RCS/Makefile.in,v 1.58 1997/02/21 01:20:19 sam Exp $
+# $Header: /d1/sam/tiff/RCS/Makefile.in,v 1.62 1997/08/29 23:24:06 sam Exp $
#
# @WARNING@
#
# Tag Image File Format Library
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
@@ -131,6 +131,7 @@ TIFFFILES=\
libtiff/tiffconf.h \
libtiff/tiffio.h \
libtiff/tiffiop.h \
+ libtiff/uvcode.h \
libtiff/mkg3states.c \
libtiff/mkspans.c \
libtiff/mkversion.c \
@@ -153,6 +154,7 @@ TIFFFILES=\
libtiff/tif_flush.c \
libtiff/tif_getimage.c \
libtiff/tif_jpeg.c \
+ libtiff/tif_luv.c \
libtiff/tif_lzw.c \
libtiff/tif_msdos.c \
libtiff/tif_next.c \
@@ -315,22 +317,69 @@ CONTRIBFILES=\
contrib/dbs/xtiff/patchlevel.h \
contrib/dbs/xtiff/xtiff.c \
contrib/dbs/xtiff/xtifficon.h \
- contrib/ras/ras2tif.c \
- contrib/ras/tif2ras.c \
+ contrib/ras/README \
+ contrib/ras/ras2tif.c \
+ contrib/ras/tif2ras.c \
contrib/vms/libtiff/makevms.com \
contrib/vms/libtiff/tiff.opt \
contrib/vms/libtiff/tiffshraxp.opt \
contrib/vms/libtiff/tiffshrvax.opt \
contrib/vms/libtiff/tiffvec.mar \
contrib/vms/tools/makevms.com \
- contrib/tags \
- contrib/mac-mpw \
- contrib/acorn \
- contrib/win32 \
- contrib/win95 \
- contrib/winnt \
- contrib/mac-cw \
- contrib/dosdjgpp \
+ contrib/tags/README \
+ contrib/tags/Makefile.gcc \
+ contrib/tags/Makefile.mpw \
+ contrib/tags/listtif.c \
+ contrib/tags/maketif.c \
+ contrib/tags/xtif_dir.c \
+ contrib/tags/xtiffio.h \
+ contrib/tags/xtiffiop.h \
+ contrib/mac-mpw/README \
+ contrib/mac-mpw/BUILD.mpw \
+ contrib/mac-mpw/libtiff.make \
+ contrib/mac-mpw/mactrans.c \
+ contrib/mac-mpw/port.make \
+ contrib/mac-mpw/tools.make \
+ contrib/mac-mpw/top.make \
+ contrib/acorn/ReadMe \
+ contrib/acorn/Makefile \
+ contrib/acorn/SetVars \
+ contrib/acorn/cleanlib \
+ contrib/acorn/convert \
+ contrib/acorn/install \
+ contrib/win32/README \
+ contrib/win32/dllshell.c \
+ contrib/win32/libtiff.def \
+ contrib/win95/README \
+ contrib/win95/Makefile.w95 \
+ contrib/win95/tiff2dib.c \
+ contrib/winnt/README \
+ contrib/winnt/README.console \
+ contrib/winnt/fax3sm.c \
+ contrib/winnt/libtiff.def \
+ contrib/winnt/libtiff.mak \
+ contrib/winnt/libtiff.vcp \
+ contrib/winnt/version.h \
+ contrib/mac-cw/README \
+ contrib/mac-cw/Makefile.script \
+ contrib/mac-cw/mac_main.c \
+ contrib/mac-cw/mac_main.h \
+ contrib/mac-cw/metrowerks.note \
+ contrib/mac-cw/mkg3_main.c \
+ contrib/mac-cw/version.h \
+ contrib/dosdjgpp/README \
+ contrib/dosdjgpp/Makefile.lib \
+ contrib/dosdjgpp/Makefile.tools \
+ contrib/dosdjgpp/Makefile.top \
+ contrib/dosdjgpp/conf.bat \
+ contrib/dosdjgpp/port.h \
+ contrib/mfs/README \
+ contrib/mfs/mfs_file.c \
+ contrib/pds/README \
+ contrib/pds/tif_imageiter.c \
+ contrib/pds/tif_imageiter.h \
+ contrib/pds/tif_pdsdirread.c \
+ contrib/pds/tif_pdsdirwrite.c \
${NULL}
DISTFILES=\
${TIFFFILES} \
diff --git a/README b/README
index edeff123..5a806052 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-$Header: /usr/people/sam/tiff/RCS/README,v 1.27 1996/01/10 19:31:42 sam Exp $
+$Header: /d1/sam/tiff/RCS/README,v 1.28 1997/08/29 21:45:14 sam Exp $
TIFF Software Distribution
--------------------------
@@ -37,8 +37,8 @@ also be interested in knowing about it and, hopefully, be acknowledged.
The legal way of saying that is:
-Copyright (c) 1988-1996 Sam Leffler
-Copyright (c) 1991-1996 Silicon Graphics, Inc.
+Copyright (c) 1988-1997 Sam Leffler
+Copyright (c) 1991-1997 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
diff --git a/TODO b/TODO
index 3fd94828..e434fb52 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-# $Header: /usr/people/sam/tiff/RCS/TODO,v 1.4 1996/02/09 22:09:00 sam Exp $
+# $Header: /d1/sam/tiff/RCS/TODO,v 1.4 1996/02/09 22:09:00 sam Exp $
o tiffcmp read data by strip/tile instead of scanline
o YCbCr sampling support
diff --git a/config.site b/config.site
index eafd1da1..3bf150ff 100644
--- a/config.site
+++ b/config.site
@@ -1,9 +1,9 @@
-# $Header: /usr/people/sam/tiff/RCS/config.site,v 1.13 1996/06/05 21:24:33 sam Exp $
+# $Header: /d1/sam/tiff/RCS/config.site,v 1.14 1997/08/29 21:45:16 sam Exp $
#
# TIFF Software
#
-# Copyright (c) 1990-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1990-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/configure b/configure
index 5149317f..629461c2 100755
--- a/configure
+++ b/configure
@@ -1,10 +1,10 @@
#!/bin/sh
-# $Header: /usr/people/sam/tiff/RCS/configure,v 1.56 1997/01/28 00:39:52 sam Exp $
+# $Header: /d1/sam/tiff/RCS/configure,v 1.58 1997/08/29 22:30:51 sam Exp $
#
# Tag Image File Format (TIFF) Software
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
@@ -147,7 +147,7 @@ do
-target|--target) ac_prev=TARGET;;
-target=*|--target=*) TARGET="$ac_optarg" ;;
-version|--version)
- echo "This is TIFF configure $Revision: 1.56 $"
+ echo "This is TIFF configure $Revision: 1.58 $"
exit 0
;;
-help|--help) usage; exit 0;;
@@ -1117,12 +1117,12 @@ if [ "$DSO" = auto ]; then
DSOOPTS='-fpic -shared'
LIBCOPTS=-fpic
DSO=HPUX
+ TIFFLIBREF="-Wl,+s,+b${DIR_LIB}"' -L${DEPTH}/libtiff -ltiff'
;;
*-hpux*)
DSOSUF=sl
DSOOPTS='-b'
LIBCOPTS="+Z"
-# LIBPORT="-Wl,+b${DIR_LIB}"
DSO=HPUX
TIFFLIBREF="-Wl,+s,+b${DIR_LIB}"' -L${DEPTH}/libtiff -ltiff'
;;
diff --git a/contrib/dosdjgpp/Makefile.lib b/contrib/dosdjgpp/Makefile.lib
index fd4fa764..f0ccff3f 100644
--- a/contrib/dosdjgpp/Makefile.lib
+++ b/contrib/dosdjgpp/Makefile.lib
@@ -1,4 +1,4 @@
-# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.28 1996/02/09 05:55:00 sam Exp $
+# $Header: /d1/sam/tiff/contrib/dosdjgpp/RCS/Makefile.lib,v 1.1 1997/08/27 22:39:50 sam Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#
diff --git a/contrib/dosdjgpp/Makefile.tools b/contrib/dosdjgpp/Makefile.tools
index 68869b77..d4928d62 100644
--- a/contrib/dosdjgpp/Makefile.tools
+++ b/contrib/dosdjgpp/Makefile.tools
@@ -1,4 +1,4 @@
-# $Header: /usr/people/sam/tiff/tools/RCS/Makefile.in,v 1.17 1996/02/09 05:55:00 sam Exp $
+# $Header: /d1/sam/tiff/contrib/dosdjgpp/RCS/Makefile.tools,v 1.1 1997/08/27 22:39:50 sam Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#
diff --git a/contrib/dosdjgpp/Makefile.top b/contrib/dosdjgpp/Makefile.top
index 1d60696e..d6bcee4c 100644
--- a/contrib/dosdjgpp/Makefile.top
+++ b/contrib/dosdjgpp/Makefile.top
@@ -1,5 +1,5 @@
#! smake
-# $Header: /usr/people/sam/tiff/RCS/Makefile.in,v 1.44 1996/02/09 21:29:19 sam Exp $
+# $Header: /d1/sam/tiff/contrib/dosdjgpp/RCS/Makefile.top,v 1.1 1997/08/27 22:39:50 sam Exp $
#
# manually derived from Makefile.in (though basically nothing remains)
# for DJGPP v2.x (GNU C for DOS/386).
diff --git a/contrib/mfs/README b/contrib/mfs/README
new file mode 100644
index 00000000..6f9befbc
--- /dev/null
+++ b/contrib/mfs/README
@@ -0,0 +1,37 @@
+Date: Mon, 23 Jun 1997 13:30:48 +0200
+To: <sam@cthulhu.engr.sgi.com>
+
+From: "Mike Johnson" <mikehunt@swipnet.se>
+Subject: libtiff - Thanks
+
+Return-Path: mikehunt@swipnet.se
+Delivery-Date: Mon, 23 Jun 1997 06:53:39 -0700
+
+Hi Sam,
+
+I noticed in the README from libtiff that you would like to know about
+what people have done with libtiff, so I thought I would drop you a
+line.
+
+We have used libtiff to create and convert TIFF images of financial
+documents which are sent from and to major document processing systems
+in Sweden and Denmark.
+
+I would like to express my deep gratitude to yourself and Sillicon
+Graphics for making this excellent library available for public use.
+There is obviously a lot of work that has gone in to libtiff and the
+quality of the code and documentation is an example to others.
+
+One thing that libtiff did not do was work on a memory area rather than
+files. In my applications I had already read a TIFF or other format
+file in to memory and did not want to waste I/O writing it out again
+for libtiff's benefit. I therefore constructed a set of functions to
+pass up to TIFFClientOpen to simulate a file in memory. I have attached
+my mfs (memory file system) source code for you to use or junk, as you
+see fit. :-)
+
+Once again, thanks very much for making my life simpler.
+
+Best Regards,
+
+Mike Johnson.
diff --git a/contrib/mfs/mfs_file.c b/contrib/mfs/mfs_file.c
new file mode 100644
index 00000000..fa408dab
--- /dev/null
+++ b/contrib/mfs/mfs_file.c
@@ -0,0 +1,579 @@
+/*
+--------------------------------------------------------------------------------
+- Module : mem_file.c
+- Description : A general purpose library for manipulating a memory area
+- as if it were a file.
+- mfs_ stands for memory file system.
+- Author : Mike Johnson - Banctec AB 03/07/96
+-
+--------------------------------------------------------------------------------
+*/
+
+/*
+
+Copyright (c) 1996 Mike Johnson
+Copyright (c) 1996 BancTec AB
+
+Permission to use, copy, modify, distribute, and sell this software
+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
+Mike Johnson and BancTec may not be used in any advertising or
+publicity relating to the software.
+
+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 MIKE JOHNSON OR BANCTEC 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.
+
+*/
+
+
+/*
+--------------------------------------------------------------------------------
+- Includes
+--------------------------------------------------------------------------------
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+--------------------------------------------------------------------------------
+- Definitions
+--------------------------------------------------------------------------------
+*/
+
+#define MAX_BUFFS 20
+#define FALSE 0
+#define TRUE 1
+
+/*
+--------------------------------------------------------------------------------
+- Globals
+--------------------------------------------------------------------------------
+*/
+
+static char *buf[MAX_BUFFS]; /* Memory for each open buf */
+static long buf_off[MAX_BUFFS]; /* File pointer for each buf */
+static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */
+static long fds[MAX_BUFFS]; /* File descriptor status */
+static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */
+
+static int library_init_done = FALSE;
+
+
+/*
+--------------------------------------------------------------------------------
+- Function prototypes
+--------------------------------------------------------------------------------
+*/
+
+int mfs_open (void *ptr, int size, char *mode);
+int mfs_lseek (int fd, int offset, int whence);
+int mfs_read (int fd, void *buf, int size);
+int mfs_write (int fd, void *buf, int size);
+int mfs_size (int fd);
+int mfs_map (int fd, char **addr, size_t *len);
+int mfs_unmap (int fd);
+int mfs_close (int fd);
+static int extend_mem_file (int fd, int size);
+static void mem_init ();
+
+/*
+--------------------------------------------------------------------------------
+- Function code
+--------------------------------------------------------------------------------
+*/
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_open ()
+-
+- Arguments : Pointer to allocated buffer, initial size of buffer,
+- mode spec (r, w, a)
+-
+- Returns : File descriptor or -1 if error.
+-
+- Description : Register this area of memory (which has been allocated
+- and has a file read into it) under the mem_file library.
+- A file descriptor is returned which can the be passed
+- back to TIFFClientOpen and used as if it was a disk
+- based fd.
+- If the call is for mode 'w' then pass (void *)NULL as
+- the buffer and zero size and the library will
+- allocate memory for you.
+- If the mode is append then pass (void *)NULL and size
+- zero or with a valid address.
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_open (void *buffer, int size, char *mode)
+{
+ int ret, i;
+ void *tmp;
+
+ if (library_init_done == FALSE)
+ {
+ mem_init ();
+ library_init_done = TRUE;
+ }
+
+ ret = -1;
+
+ /* Find a free fd */
+
+ for (i = 0; i < MAX_BUFFS; i++)
+ {
+ if (fds[i] == -1)
+ {
+ ret = i;
+ break;
+ }
+ }
+
+ if (i == MAX_BUFFS) /* No more free descriptors */
+ {
+ ret = -1;
+ errno = EMFILE;
+ }
+
+ if (ret >= 0 && *mode == 'r')
+ {
+ if (buffer == (void *)NULL)
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+ else
+ {
+ buf[ret] = (char *)buffer;
+ buf_size[ret] = size;
+ buf_off[ret] = 0;
+ }
+ }
+ else if (ret >= 0 && *mode == 'w')
+ {
+
+ if (buffer != (void *)NULL)
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+
+ else
+ {
+ tmp = malloc (0); /* Get a pointer */
+ if (tmp == (void *)NULL)
+ {
+ ret = -1;
+ errno = EDQUOT;
+ }
+ else
+ {
+ buf[ret] = (char *)tmp;
+ buf_size[ret] = 0;
+ buf_off[ret] = 0;
+ }
+ }
+ }
+ else if (ret >= 0 && *mode == 'a')
+ {
+ if (buffer == (void *) NULL) /* Create space for client */
+ {
+ tmp = malloc (0); /* Get a pointer */
+ if (tmp == (void *)NULL)
+ {
+ ret = -1;
+ errno = EDQUOT;
+ }
+ else
+ {
+ buf[ret] = (char *)tmp;
+ buf_size[ret] = 0;
+ buf_off[ret] = 0;
+ }
+ }
+ else /* Client has file read in already */
+ {
+ buf[ret] = (char *)buffer;
+ buf_size[ret] = size;
+ buf_off[ret] = 0;
+ }
+ }
+ else /* Some other invalid combination of parameters */
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+
+ if (ret != -1)
+ {
+ fds[ret] = 0;
+ buf_mode[ret] = *mode;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_lseek ()
+-
+- Arguments : File descriptor, offset, whence
+-
+- Returns : as per man lseek (2)
+-
+- Description : Does the same as lseek (2) except on a memory based file.
+- Note: the memory area will be extended if the caller
+- attempts to seek past the current end of file (memory).
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_lseek (int fd, int offset, int whence)
+{
+ int ret;
+ long test_off;
+
+ if (fds[fd] == -1) /* Not open */
+ {
+ ret = -1;
+ errno = EBADF;
+ }
+ else if (offset < 0 && whence == SEEK_SET)
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+ else
+ {
+ switch (whence)
+ {
+ case SEEK_SET:
+ if (offset > buf_size[fd])
+ extend_mem_file (fd, offset);
+ buf_off[fd] = offset;
+ ret = offset;
+ break;
+
+ case SEEK_CUR:
+ test_off = buf_off[fd] + offset;
+
+ if (test_off < 0)
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+ else
+ {
+ if (test_off > buf_size[fd])
+ extend_mem_file (fd, test_off);
+ buf_off[fd] = test_off;
+ ret = test_off;
+ }
+ break;
+
+ case SEEK_END:
+ test_off = buf_size[fd] + offset;
+
+ if (test_off < 0)
+ {
+ ret = -1;
+ errno = EINVAL;
+ }
+ else
+ {
+ if (test_off > buf_size[fd])
+ extend_mem_file (fd, test_off);
+ buf_off[fd] = test_off;
+ ret = test_off;
+ }
+ break;
+
+ default:
+ errno = EINVAL;
+ ret = -1;
+ break;
+ }
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_read ()
+-
+- Arguments : File descriptor, buffer, size
+-
+- Returns : as per man read (2)
+-
+- Description : Does the same as read (2) except on a memory based file.
+- Note: An attempt to read past the end of memory currently
+- allocated to the file will return 0 (End Of File)
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_read (int fd, void *clnt_buf, int size)
+{
+ int ret;
+
+ if (fds[fd] == -1 || buf_mode[fd] != 'r')
+ {
+ /* File is either not open, or not opened for read */
+
+ ret = -1;
+ errno = EBADF;
+ }
+ else if (buf_off[fd] + size > buf_size[fd])
+ {
+ ret = 0; /* EOF */
+ }
+ else
+ {
+ memcpy (clnt_buf, (void *) (buf[fd] + buf_off[fd]), size);
+ buf_off[fd] = buf_off[fd] + size;
+ ret = size;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_write ()
+-
+- Arguments : File descriptor, buffer, size
+-
+- Returns : as per man write (2)
+-
+- Description : Does the same as write (2) except on a memory based file.
+- Note: the memory area will be extended if the caller
+- attempts to write past the current end of file (memory).
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_write (int fd, void *clnt_buf, int size)
+{
+ int ret;
+
+ if (fds[fd] == -1 || buf_mode[fd] == 'r')
+ {
+ /* Either the file is not open or it is opened for reading only */
+
+ ret = -1;
+ errno = EBADF;
+ }
+ else if (buf_mode[fd] == 'w')
+ {
+ /* Write */
+
+ if (buf_off[fd] + size > buf_size[fd])
+ {
+ extend_mem_file (fd, buf_off[fd] + size);
+ buf_size[fd] = (buf_off[fd] + size);
+ }
+
+ memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
+ buf_off[fd] = buf_off[fd] + size;
+
+ ret = size;
+ }
+ else
+ {
+ /* Append */
+
+ if (buf_off[fd] != buf_size[fd])
+ buf_off[fd] = buf_size[fd];
+
+ extend_mem_file (fd, buf_off[fd] + size);
+ buf_size[fd] += size;
+
+ memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size);
+ buf_off[fd] = buf_off[fd] + size;
+
+ ret = size;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_size ()
+-
+- Arguments : File descriptor
+-
+- Returns : integer file size
+-
+- Description : This function returns the current size of the file in bytes.
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_size (int fd)
+{
+ int ret;
+
+ if (fds[fd] == -1) /* Not open */
+ {
+ ret = -1;
+ errno = EBADF;
+ }
+ else
+ ret = buf_size[fd];
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_map ()
+-
+- Arguments : File descriptor, ptr to address, ptr to length
+-
+- Returns : Map status (succeeded or otherwise)
+-
+- Description : This function tells the client where the file is mapped
+- in memory and what size the mapped area is. It is provided
+- to satisfy the MapProc function in libtiff. It pretends
+- that the file has been mmap (2)ped.
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_map (int fd, char **addr, size_t *len)
+{
+ int ret;
+
+ if (fds[fd] == -1) /* Not open */
+ {
+ ret = -1;
+ errno = EBADF;
+ }
+ else
+ {
+ *addr = buf[fd];
+ *len = buf_size[fd];
+ ret = 0;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_unmap ()
+-
+- Arguments : File descriptor
+-
+- Returns : UnMap status (succeeded or otherwise)
+-
+- Description : This function does nothing as the file is always
+- in memory.
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_unmap (int fd)
+{
+ return (0);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mfs_close ()
+-
+- Arguments : File descriptor
+-
+- Returns : close status (succeeded or otherwise)
+-
+- Description : Close the open memory file. (Make fd available again.)
+-
+--------------------------------------------------------------------------------
+*/
+
+int mfs_close (int fd)
+{
+ int ret;
+
+ if (fds[fd] == -1) /* Not open */
+ {
+ ret = -1;
+ errno = EBADF;
+ }
+ else
+ {
+ fds[fd] = -1;
+ ret = 0;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : extend_mem_file ()
+-
+- Arguments : File descriptor, length to extend to.
+-
+- Returns : 0 - All OK, -1 - realloc () failed.
+-
+- Description : Increase the amount of memory allocated to a file.
+-
+--------------------------------------------------------------------------------
+*/
+
+static int extend_mem_file (int fd, int size)
+{
+ void *new_mem;
+ int ret;
+
+ if ((new_mem = realloc (buf[fd], size)) == (void *) NULL)
+ ret = -1;
+ else
+ {
+ buf[fd] = (char *) new_mem;
+ ret = 0;
+ }
+
+ return (ret);
+}
+
+/*
+--------------------------------------------------------------------------------
+- Function : mem_init ()
+-
+- Arguments : None
+-
+- Returns : void
+-
+- Description : Initialise the library.
+-
+--------------------------------------------------------------------------------
+*/
+
+static void mem_init ()
+{
+ int i;
+
+ for (i = 0; i < MAX_BUFFS; i++)
+ {
+ fds[i] = -1;
+ buf[i] = (char *)NULL;
+ buf_size[i] = 0;
+ buf_off[i] = 0;
+ }
+}
+
diff --git a/contrib/pds/README b/contrib/pds/README
new file mode 100644
index 00000000..b9abc6b3
--- /dev/null
+++ b/contrib/pds/README
@@ -0,0 +1,90 @@
+Date: Fri, 01 Aug 1997 20:14:52 MDT
+To: Sam Leffler <sam@cthulhu.engr.sgi.com>
+
+From: "Conrad J. Poelman (WSAT)" <poelmanc@plk.af.mil>
+Subject: Potential TIFF library additions
+
+Delivery-Date: Fri, 01 Aug 1997 19:21:06 -0700
+
+Sam,
+
+You probably don't remember me, but I sent in a couple of bug fixes
+regarding the TIFF library about a 16 months ago or so...
+
+I just wanted to send you two other additions that I have made to our
+local version of the TIFF library in hopes that you will want to
+incorporate them into your next major release of the TIFF library.
+(These additions are based on TIFF version 3.4beta31, but they sit on
+top of the library so they shouldn't be much trouble to incorporate them
+into any more recent version.) They are internally documented to a
+reasonable extent and we've been successfully using them in our code
+here for over a year. If you think they would make good additions to the
+TIFF library, I'd be happy to clean them up more, document them more,
+and/or integrate them with the latest version of the TIFF library, but I
+figured I'd see if you were interested in using them before I went to
+all that trouble.
+
+TIFF Image Iterator
+-------------------
+Your ReadRGBA() routine works well for reading many different formats
+(TILED, STIP, compressed or not, etc.) of the most basic types of data
+(RGB, 8-bit greyscale, 8-bit colormapped) into an SGI-style data array,
+and serves as a good template for users with other needs. I used it as
+an exmaple of how to make an iterator which, rather than fill a data
+array, calls an arbitrary user-supplied callback function for each
+"chunk" of data - that "chunk" might be a strip or a tile, and might
+have one sample-per-pixel or two, and might be 8-bit data or 16-bit or
+24-bit. The callback function can do whatever it wants with the data -
+store it in a big array, convert it to RGBA, or draw it directly to the
+screen. I was able to use this iterator to read 16-bit greyscale and 32-
+and 64-bit floating point data, which wasn't possible with ReadRGBA().
+
+I have tested this routine with 8- and 16-bit greyscale data as well as
+with 32- and 64-bit floating point data. I believe nearly all of our
+data is organized in strips, so actually I'd appreciate it if you had
+some tiled images that I could test it with.
+
+It should certainly be possible and would be cleanest to reimplement
+ReadRGBA() in terms of the image iterator, but I haven't done that.
+
+
+Private Sub-Directory Read/Write
+--------------------------------
+TIFF-PL is a Phillips Laboratory extension to the TIFF tags that allows
+us to store satellite imaging-specific information in a TIFF format,
+such as the satellite's trajectory, the imaging time, etc. In order to
+give us the flexibility to modify the tag definitions without getting
+approval from the TIFF committee every time, we were given only three
+TIFF tags - a PL signature, a PL version number, and PL directory
+offset, which lists the position in the file at which to find a private
+sub-directory of tags-value pairs. So I wrote two routines:
+TIFFWritePrivateDataSubDirectory(), which takes a list of tags and a
+"get" function and writes the tag values into the TIFF file, returning
+the offset within the file at which it wrote the directory; and
+TIFFReadPrivateDataSubDirectory(), which takes an offset, a list of
+tags, and a "set" function and reads all the data from the private
+directory. The functions themselves are pretty simple. (The files are
+huge because I had to basically copy all of the tif_dirread.c and
+tif_dirwrite.c files in order to access the various fetching routines
+which were all declared static and therefore inaccessible in the TIFF
+library.)
+
+
+I'm including the four source files (tif_imgiter.h, tif_imgiter.c,
+tif_pdsdirread.c, tif_pdsdirwrite.c) in case you want to take a look at
+them. I can also send you some sample code that uses them if you like.
+If you're interested in having them incorporated into the standard TIFF
+library, I'd be happy to do that integration and clean up and document
+the routines. (For example, I've already realized that instead of
+limiting the SEP callback function to three bands (R,G,B) it should take
+an array to enable the handling of n-banded multi-spectral data...) If
+not, I'll just leave them as they are, since they work fine for us now.
+
+Holler if you have any questions.
+
+-- Conrad
+__________________________________________________________________
+ Capt Conrad J. Poelman PL/WSAT (Phillips Laboratory)
+ 505-846-4347 3550 Aberdeen Ave SE
+ (FAX) 505-846-4374 Kirtland AFB, NM 87117-5776
+
diff --git a/contrib/pds/tif_imageiter.c b/contrib/pds/tif_imageiter.c
new file mode 100644
index 00000000..9c6c4370
--- /dev/null
+++ b/contrib/pds/tif_imageiter.c
@@ -0,0 +1,518 @@
+/* $Header: /d1/sam/tiff/contrib/pds/RCS/tif_imageiter.c,v 1.1 1997/08/29 23:12:56 sam Exp $ */
+
+/*
+ * Copyright (c) 1991-1996 Sam Leffler
+ * Copyright (c) 1991-1996 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.
+ */
+
+/*
+ * TIFF Library
+ *
+ * Written by Conrad J. Poelman, PL/WSAT, Kirtland AFB, NM on 26 Mar 96.
+ *
+ * This file contains code to allow a calling program to "iterate" over each
+ * pixels in an image as it is read from the file. The iterator takes care of
+ * reading strips versus (possibly clipped) tiles, decoding the information
+ * according to the decoding method, and so on, so that calling program can
+ * ignore those details. The calling program does, however, need to be
+ * conscious of the type of the pixel data that it is receiving.
+ *
+ * For reasons of efficiency, the callback function actually gets called for
+ * "blocks" of pixels rather than for individual pixels. The format of the
+ * callback arguments is given below.
+ *
+ * This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the original
+ * TIFF distribution, and simplified and generalized to provide this general
+ * iteration capability. Those routines could certainly be re-implemented in terms
+ * of a TIFFImageIter if desired.
+ *
+ */
+#include "tiffiop.h"
+#include "tif_imgiter.h"
+#include <assert.h>
+#include <stdio.h>
+
+static int gtTileContig(TIFFImageIter*, void *udata, uint32, uint32);
+static int gtTileSeparate(TIFFImageIter*, void *udata, uint32, uint32);
+static int gtStripContig(TIFFImageIter*, void *udata, uint32, uint32);
+static int gtStripSeparate(TIFFImageIter*, void *udata, uint32, uint32);
+
+static const char photoTag[] = "PhotometricInterpretation";
+
+static int
+isCCITTCompression(TIFF* tif)
+{
+ uint16 compress;
+ TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
+ return (compress == COMPRESSION_CCITTFAX3 ||
+ compress == COMPRESSION_CCITTFAX4 ||
+ compress == COMPRESSION_CCITTRLE ||
+ compress == COMPRESSION_CCITTRLEW);
+}
+
+int
+TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024])
+{
+ uint16* sampleinfo;
+ uint16 extrasamples;
+ uint16 planarconfig;
+ int colorchannels;
+
+ img->tif = tif;
+ img->stoponerr = stop;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample);
+ img->alpha = 0;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
+ &extrasamples, &sampleinfo);
+ if (extrasamples == 1)
+ switch (sampleinfo[0]) {
+ case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */
+ case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */
+ img->alpha = sampleinfo[0];
+ break;
+ }
+ colorchannels = img->samplesperpixel - extrasamples;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
+ if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) {
+ switch (colorchannels) {
+ case 1:
+ if (isCCITTCompression(tif))
+ img->photometric = PHOTOMETRIC_MINISWHITE;
+ else
+ img->photometric = PHOTOMETRIC_MINISBLACK;
+ break;
+ case 3:
+ img->photometric = PHOTOMETRIC_RGB;
+ break;
+ default:
+ sprintf(emsg, "Missing needed %s tag", photoTag);
+ return (0);
+ }
+ }
+ switch (img->photometric) {
+ case PHOTOMETRIC_PALETTE:
+ if (!TIFFGetField(tif, TIFFTAG_COLORMAP,
+ &img->redcmap, &img->greencmap, &img->bluecmap)) {
+ TIFFError(TIFFFileName(tif), "Missing required \"Colormap\" tag");
+ return (0);
+ }
+ /* fall thru... */
+ case PHOTOMETRIC_MINISWHITE:
+ case PHOTOMETRIC_MINISBLACK:
+/* This should work now so skip the check - BSR
+ if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) {
+ sprintf(emsg,
+ "Sorry, can not handle contiguous data with %s=%d, and %s=%d",
+ photoTag, img->photometric,
+ "Samples/pixel", img->samplesperpixel);
+ return (0);
+ }
+ */
+ break;
+ case PHOTOMETRIC_YCBCR:
+ if (planarconfig != PLANARCONFIG_CONTIG) {
+ sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d",
+ "Planarconfiguration", planarconfig);
+ return (0);
+ }
+ /* It would probably be nice to have a reality check here. */
+ { uint16 compress;
+ TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
+ if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
+ /* can rely on libjpeg to convert to RGB */
+ /* XXX should restore current state on exit */
+ TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
+ img->photometric = PHOTOMETRIC_RGB;
+ }
+ }
+ break;
+ case PHOTOMETRIC_RGB:
+ if (colorchannels < 3) {
+ sprintf(emsg, "Sorry, can not handle RGB image with %s=%d",
+ "Color channels", colorchannels);
+ return (0);
+ }
+ break;
+ case PHOTOMETRIC_SEPARATED: {
+ uint16 inkset;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
+ if (inkset != INKSET_CMYK) {
+ sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
+ "InkSet", inkset);
+ return (0);
+ }
+ if (img->samplesperpixel != 4) {
+ sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
+ "Samples/pixel", img->samplesperpixel);
+ return (0);
+ }
+ break;
+ }
+ default:
+ sprintf(emsg, "Sorry, can not handle image with %s=%d",
+ photoTag, img->photometric);
+ return (0);
+ }
+ TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
+ TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
+
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
+ switch (img->orientation) {
+ case ORIENTATION_BOTRIGHT:
+ case ORIENTATION_RIGHTBOT: /* XXX */
+ case ORIENTATION_LEFTBOT: /* XXX */
+ TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
+ img->orientation = ORIENTATION_BOTLEFT;
+ /* fall thru... */
+ case ORIENTATION_BOTLEFT:
+ break;
+ case ORIENTATION_TOPRIGHT:
+ case ORIENTATION_RIGHTTOP: /* XXX */
+ case ORIENTATION_LEFTTOP: /* XXX */
+ default:
+ TIFFWarning(TIFFFileName(tif), "using top-left orientation");
+ img->orientation = ORIENTATION_TOPLEFT;
+ /* fall thru... */
+ case ORIENTATION_TOPLEFT:
+ break;
+ }
+
+ img->isContig =
+ !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1);
+ if (img->isContig) {
+ img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig;
+ } else {
+ img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate;
+ }
+ return (1);
+}
+
+int
+TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
+{
+ if (img->get == NULL) {
+ TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup");
+ return (0);
+ }
+ if (img->callback.any == NULL) {
+ TIFFError(TIFFFileName(img->tif),
+ "No \"put\" routine setupl; probably can not handle image format");
+ return (0);
+ }
+ return (*img->get)(img, udata, w, h);
+}
+
+TIFFImageIterEnd(TIFFImageIter* img)
+{
+ /* Nothing to free... ? */
+}
+
+/*
+ * Read the specified image into an ABGR-format raster.
+ */
+int
+TIFFReadImageIter(TIFF* tif,
+ uint32 rwidth, uint32 rheight, uint8* raster, int stop)
+{
+ char emsg[1024];
+ TIFFImageIter img;
+ int ok;
+
+ if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
+ /* XXX verify rwidth and rheight against width and height */
+ ok = TIFFImageIterGet(&img, raster, rwidth, img.height);
+ TIFFImageIterEnd(&img);
+ } else {
+ TIFFError(TIFFFileName(tif), emsg);
+ ok = 0;
+ }
+ return (ok);
+}
+
+
+/*
+ * Get an tile-organized image that has
+ * PlanarConfiguration contiguous if SamplesPerPixel > 1
+ * or
+ * SamplesPerPixel == 1
+ */
+static int
+gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
+{
+ TIFF* tif = img->tif;
+ ImageIterTileContigRoutine callback = img->callback.contig;
+ uint16 orientation;
+ uint32 col, row;
+ uint32 tw, th;
+ u_char* buf;
+ int32 fromskew;
+ uint32 nrow;
+
+ buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
+ if (buf == 0) {
+ TIFFError(TIFFFileName(tif), "No space for tile buffer");
+ return (0);
+ }
+ TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
+ TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
+ orientation = img->orientation;
+ for (row = 0; row < h; row += th) {
+ nrow = (row + th > h ? h - row : th);
+ for (col = 0; col < w; col += tw) {
+ if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr)
+ break;
+ if (col + tw > w) {
+ /*
+ * Tile is clipped horizontally. Calculate
+ * visible portion and skewing factors.
+ */
+ uint32 npix = w - col;
+ fromskew = tw - npix;
+ (*callback)(img, udata, col, row, npix, nrow, fromskew, buf);
+ } else {
+ (*callback)(img, udata, col, row, tw, nrow, 0, buf);
+ }
+ }
+ }
+ _TIFFfree(buf);
+ return (1);
+}
+
+/*
+ * Get an tile-organized image that has
+ * SamplesPerPixel > 1
+ * PlanarConfiguration separated
+ * We assume that all such images are RGB.
+ */
+static int
+gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
+{
+ TIFF* tif = img->tif;
+ ImageIterTileSeparateRoutine callback = img->callback.separate;
+ uint16 orientation;
+ uint32 col, row;
+ uint32 tw, th;
+ u_char* buf;
+ u_char* r;
+ u_char* g;
+ u_char* b;
+ u_char* a;
+ tsize_t tilesize;
+ int32 fromskew;
+ int alpha = img->alpha;
+ uint32 nrow;
+
+ tilesize = TIFFTileSize(tif);
+ buf = (u_char*) _TIFFmalloc(4*tilesize);
+ if (buf == 0) {
+ TIFFError(TIFFFileName(tif), "No space for tile buffer");
+ return (0);
+ }
+ r = buf;
+ g = r + tilesize;
+ b = g + tilesize;
+ a = b + tilesize;
+ if (!alpha)
+ memset(a, 0xff, tilesize);
+ TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
+ TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
+ orientation = img->orientation;
+ for (row = 0; row < h; row += th) {
+ nrow = (row + th > h ? h - row : th);
+ for (col = 0; col < w; col += tw) {
+ if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr)
+ break;
+ if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr)
+ break;
+ if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr)
+ break;
+ if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr)
+ break;
+ if (col + tw > w) {
+ /*
+ * Tile is clipped horizontally. Calculate
+ * visible portion and skewing factors.
+ */
+ uint32 npix = w - col;
+ fromskew = tw - npix;
+ (*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a);
+ } else {
+ (*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a);
+ }
+ }
+ }
+ _TIFFfree(buf);
+ return (1);
+}
+
+/*
+ * Get a strip-organized image that has
+ * PlanarConfiguration contiguous if SamplesPerPixel > 1
+ * or
+ * SamplesPerPixel == 1
+ */
+static int
+gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
+{
+ TIFF* tif = img->tif;
+ ImageIterTileContigRoutine callback = img->callback.contig;
+ uint16 orientation;
+ uint32 row, nrow;
+ u_char* buf;
+ uint32 rowsperstrip;
+ uint32 imagewidth = img->width;
+ tsize_t scanline;
+ int32 fromskew;
+
+ buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
+ if (buf == 0) {
+ TIFFError(TIFFFileName(tif), "No space for strip buffer");
+ return (0);
+ }
+ orientation = img->orientation;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
+ scanline = TIFFScanlineSize(tif);
+ fromskew = (w < imagewidth ? imagewidth - w : 0);
+ for (row = 0; row < h; row += rowsperstrip) {
+ nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
+ buf, nrow*scanline) < 0 && img->stoponerr)
+ break;
+ (*callback)(img, udata, 0, row, w, nrow, fromskew, buf);
+ }
+ _TIFFfree(buf);
+ return (1);
+}
+
+/*
+ * Get a strip-organized image with
+ * SamplesPerPixel > 1
+ * PlanarConfiguration separated
+ * We assume that all such images are RGB.
+ */
+static int
+gtStripSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h)
+{
+ TIFF* tif = img->tif;
+ ImageIterTileSeparateRoutine callback = img->callback.separate;
+ uint16 orientation;
+ u_char *buf;
+ u_char *r, *g, *b, *a;
+ uint32 row, nrow;
+ tsize_t scanline;
+ uint32 rowsperstrip;
+ uint32 imagewidth = img->width;
+ tsize_t stripsize;
+ int32 fromskew;
+ int alpha = img->alpha;
+
+ stripsize = TIFFStripSize(tif);
+ r = buf = (u_char *)_TIFFmalloc(4*stripsize);
+ if (buf == 0) {
+ TIFFError(TIFFFileName(tif), "No space for tile buffer");
+ return (0);
+ }
+ g = r + stripsize;
+ b = g + stripsize;
+ a = b + stripsize;
+ if (!alpha)
+ memset(a, 0xff, stripsize);
+ orientation = img->orientation;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
+ scanline = TIFFScanlineSize(tif);
+ fromskew = (w < imagewidth ? imagewidth - w : 0);
+ for (row = 0; row < h; row += rowsperstrip) {
+ nrow = (row + rowsperstrip > h ? h - row : rowsperstrip);
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0),
+ r, nrow*scanline) < 0 && img->stoponerr)
+ break;
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1),
+ g, nrow*scanline) < 0 && img->stoponerr)
+ break;
+ if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2),
+ b, nrow*scanline) < 0 && img->stoponerr)
+ break;
+ if (alpha &&
+ (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3),
+ a, nrow*scanline) < 0 && img->stoponerr))
+ break;
+ (*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a);
+ }
+ _TIFFfree(buf);
+ return (1);
+}
+
+DECLAREContigCallbackFunc(TestContigCallback)
+{
+ printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
+ x, y, w, h, fromskew);
+}
+
+
+DECLARESepCallbackFunc(TestSepCallback)
+{
+ printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n",
+ x, y, w, h, fromskew);
+}
+
+
+#ifdef MAIN
+main(int argc, char **argv)
+{
+ char emsg[1024];
+ TIFFImageIter img;
+ int ok;
+ int stop = 1;
+
+ TIFF *tif;
+ unsigned long nx, ny;
+ unsigned short BitsPerSample, SamplesPerPixel;
+ int isColorMapped, isPliFile;
+ unsigned char *ColorMap;
+ unsigned char *data;
+
+ if (argc < 2) {
+ fprintf(stderr,"usage: %s tiff_file\n",argv[0]);
+ exit(1);
+ }
+ tif = (TIFF *)PLIGetImage(argv[1], (void *) &data, &ColorMap,
+ &nx, &ny, &BitsPerSample, &SamplesPerPixel,
+ &isColorMapped, &isPliFile);
+ if (tif != NULL) {
+
+ if (TIFFImageIterBegin(&img, tif, stop, emsg)) {
+ /* Here need to set data and callback function! */
+ if (img.isContig) {
+ img.callback = TestContigCallback;
+ } else {
+ img.callback = TestSepCallback;
+ }
+ ok = TIFFImageIterGet(&img, NULL, img.width, img.height);
+ TIFFImageIterEnd(&img);
+ } else {
+ TIFFError(TIFFFileName(tif), emsg);
+ }
+ }
+
+}
+#endif
diff --git a/contrib/pds/tif_imageiter.h b/contrib/pds/tif_imageiter.h
new file mode 100644
index 00000000..5b7ea40a
--- /dev/null
+++ b/contrib/pds/tif_imageiter.h
@@ -0,0 +1,57 @@
+typedef struct _TIFFImageIter TIFFImageIter;
+
+/* The callback function is called for each "block" of image pixel data after
+ it has been read from the file and decoded. This image pixel data is in the
+ buffer pp, and this data represents the image pixels from (x,y) to
+ (x+w,y+h). It is stored in pixel format, so each pixel contains
+ img->samplesperpixel consecutive samples each containing img->bitspersample
+ bits of data. The array pp is ordered in h consecutive rows of w+fromskew
+ pixels each. */
+typedef void (*ImageIterTileContigRoutine)
+ (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32,
+ unsigned char*);
+#define DECLAREContigCallbackFunc(name) \
+static void name(\
+ TIFFImageIter* img, \
+ void* user_data, \
+ uint32 x, uint32 y, \
+ uint32 w, uint32 h, \
+ int32 fromskew, \
+ u_char* pp \
+)
+
+typedef void (*ImageIterTileSeparateRoutine)
+ (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32,
+ unsigned char*, unsigned char*, unsigned char*, unsigned char*);
+#define DECLARESepCallbackFunc(name) \
+static void name(\
+ TIFFImageIter* img, \
+ void* user_data, \
+ uint32 x, uint32 y, \
+ uint32 w, uint32 h,\
+ int32 fromskew, \
+ u_char* r, u_char* g, u_char* b, u_char* a\
+)
+
+struct _TIFFImageIter {
+ TIFF* tif; /* image handle */
+ int stoponerr; /* stop on read error */
+ int isContig; /* data is packed/separate */
+ int alpha; /* type of alpha data present */
+ uint32 width; /* image width */
+ uint32 height; /* image height */
+ uint16 bitspersample; /* image bits/sample */
+ uint16 samplesperpixel; /* image samples/pixel */
+ uint16 orientation; /* image orientation */
+ uint16 photometric; /* image photometric interp */
+ uint16* redcmap; /* colormap pallete */
+ uint16* greencmap;
+ uint16* bluecmap;
+ /* get image data routine */
+ int (*get)(TIFFImageIter*, void *udata, uint32, uint32);
+ union {
+ void (*any)(TIFFImageIter*);
+ ImageIterTileContigRoutine contig;
+ ImageIterTileSeparateRoutine separate;
+ } callback; /* fn to exec for each block */
+};
diff --git a/contrib/pds/tif_pdsdirread.c b/contrib/pds/tif_pdsdirread.c
new file mode 100644
index 00000000..87ea11e3
--- /dev/null
+++ b/contrib/pds/tif_pdsdirread.c
@@ -0,0 +1,1124 @@
+/* $Header: /d1/sam/tiff/contrib/pds/RCS/tif_pdsdirread.c,v 1.1 1997/08/29 23:12:56 sam Exp $ */
+
+/*
+ * Copyright (c) 1988-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c( 1996 USAF Phillips Laboratory
+ *
+ * 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.
+ */
+
+/*
+ * TIFF Library.
+ *
+ * These routines written by Conrad J. Poelman on a single late-night of
+ * March 20-21, 1996.
+ *
+ * The entire purpose of this file is to provide a single external function,
+ * TIFFReadPrivateDataSubDirectory(). This function is intended for use in reading a
+ * private subdirectory from a TIFF file into a private structure. The
+ * actual writing of data into the structure is handled by the setFieldFn(),
+ * which is passed to TIFFReadPrivateDataSubDirectory() as a parameter. The idea is to
+ * enable any application wishing to store private subdirectories to do so
+ * easily using this function, without modifying the TIFF library.
+ *
+ * The astute observer will notice that only two functions are at all different
+ * from the original tif_dirread.c file: TIFFReadPrivateDataSubDirectory() and
+ * TIFFFetchNormalSubTag(). All the other stuff that makes this file so huge
+ * is only necessary because all of those functions are declared static in
+ * tif_dirread.c, so we have to totally duplicate them in order to use them.
+ *
+ * Oh, also note the bug fix in TIFFFetchFloat().
+ *
+ */
+
+#include "tiffiop.h"
+
+#define IGNORE 0 /* tag placeholder used below */
+
+#if HAVE_IEEEFP
+#define TIFFCvtIEEEFloatToNative(tif, n, fp)
+#define TIFFCvtIEEEDoubleToNative(tif, n, dp)
+#else
+extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*);
+extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*);
+#endif
+
+static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16);
+static void MissingRequired(TIFF*, const char*);
+static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32);
+static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*);
+static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*);
+static float TIFFFetchRational(TIFF*, TIFFDirEntry*);
+static int TIFFFetchNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*,
+ int (*getFieldFn)(TIFF *tif,ttag_t tag,...));
+static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, int*);
+static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*);
+static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*);
+static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**);
+static int TIFFFetchExtraSamples(TIFF*, TIFFDirEntry*);
+static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*);
+static float TIFFFetchFloat(TIFF*, TIFFDirEntry*);
+static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*);
+static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*);
+static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*);
+static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*);
+#if STRIPCHOP_SUPPORT
+static void ChopUpSingleUncompressedStrip(TIFF*);
+#endif
+
+static char *
+CheckMalloc(TIFF* tif, tsize_t n, const char* what)
+{
+ char *cp = (char*)_TIFFmalloc(n);
+ if (cp == NULL)
+ TIFFError(tif->tif_name, "No space %s", what);
+ return (cp);
+}
+
+/* Just as was done with TIFFWritePrivateDataSubDirectory(), here we implement
+ TIFFReadPrivateDataSubDirectory() which takes an offset into the TIFF file,
+ a TIFFFieldInfo structure specifying the types of the various tags,
+ and a function to use to set individual tags when they are encountered.
+ The data is read from the file, translated using the TIFF library's
+ built-in machine-independent conversion functions, and filled into
+ private subdirectory structure.
+
+ This code was written by copying the original TIFFReadDirectory() function
+ from tif_dirread.c and paring it down to what is needed for this.
+
+ It is the caller's responsibility to allocate and initialize the internal
+ structure that setFieldFn() will be writing into. If this function is being
+ called more than once before closing the file, the caller also must be
+ careful to free data in the structure before re-initializing.
+
+ It is also the caller's responsibility to verify the presence of
+ any required fields after reading the directory in.
+*/
+
+
+int
+TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset,
+ TIFFFieldInfo *field_info,
+ int (*setFieldFn)(TIFF *tif, ttag_t tag, ...))
+{
+ register TIFFDirEntry* dp;
+ register int n;
+ register TIFFDirectory* td;
+ TIFFDirEntry* dir;
+ int iv;
+ long v;
+ double dv;
+ const TIFFFieldInfo* fip;
+ int fix;
+ uint16 dircount;
+ uint32 nextdiroff;
+ char* cp;
+ int diroutoforderwarning = 0;
+
+ /* Skipped part about checking for directories or compression data. */
+
+ if (!isMapped(tif)) {
+ if (!SeekOK(tif, pdir_offset)) {
+ TIFFError(tif->tif_name,
+ "Seek error accessing TIFF private subdirectory");
+ return (0);
+ }
+ if (!ReadOK(tif, &dircount, sizeof (uint16))) {
+ TIFFError(tif->tif_name,
+ "Can not read TIFF private subdirectory count");
+ return (0);
+ }
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabShort(&dircount);
+ dir = (TIFFDirEntry *)CheckMalloc(tif,
+ dircount * sizeof (TIFFDirEntry), "to read TIFF private subdirectory");
+ if (dir == NULL)
+ return (0);
+ if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) {
+ TIFFError(tif->tif_name, "Can not read TIFF private subdirectory");
+ goto bad;
+ }
+ /*
+ * Read offset to next directory for sequential scans.
+ */
+ (void) ReadOK(tif, &nextdiroff, sizeof (uint32));
+ } else {
+ toff_t off = pdir_offset;
+
+ if (off + sizeof (short) > tif->tif_size) {
+ TIFFError(tif->tif_name,
+ "Can not read TIFF private subdirectory count");
+ return (0);
+ } else
+ _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16));
+ off += sizeof (uint16);
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabShort(&dircount);
+ dir = (TIFFDirEntry *)CheckMalloc(tif,
+ dircount * sizeof (TIFFDirEntry), "to read TIFF private subdirectory");
+ if (dir == NULL)
+ return (0);
+ if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) {
+ TIFFError(tif->tif_name, "Can not read TIFF private subdirectory");
+ goto bad;
+ } else
+ _TIFFmemcpy(dir, tif->tif_base + off,
+ dircount*sizeof (TIFFDirEntry));
+ off += dircount* sizeof (TIFFDirEntry);
+ if (off + sizeof (uint32) < tif->tif_size)
+ _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32));
+ }
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabLong(&nextdiroff);
+
+ /*
+ * Setup default value and then make a pass over
+ * the fields to check type and tag information,
+ * and to extract info required to size data
+ * structures. A second pass is made afterwards
+ * to read in everthing not taken in the first pass.
+ */
+ td = &tif->tif_dir;
+
+ for (fip = field_info, dp = dir, n = dircount;
+ n > 0; n--, dp++) {
+ if (tif->tif_flags & TIFF_SWAB) {
+ TIFFSwabArrayOfShort(&dp->tdir_tag, 2);
+ TIFFSwabArrayOfLong(&dp->tdir_count, 2);
+ }
+ /*
+ * Find the field information entry for this tag.
+ */
+ /*
+ * Silicon Beach (at least) writes unordered
+ * directory tags (violating the spec). Handle
+ * it here, but be obnoxious (maybe they'll fix it?).
+ */
+ if (dp->tdir_tag < fip->field_tag) {
+ if (!diroutoforderwarning) {
+ TIFFWarning(tif->tif_name,
+ "invalid TIFF private subdirectory; tags are not sorted in ascending order");
+ diroutoforderwarning = 1;
+ }
+ fip = field_info; /* O(n^2) */
+ }
+
+ while (fip->field_tag && fip->field_tag < dp->tdir_tag)
+ fip++;
+ if (!fip->field_tag || fip->field_tag != dp->tdir_tag) {
+ TIFFWarning(tif->tif_name,
+ "unknown field with tag %d (0x%x) in private subdirectory ignored",
+ dp->tdir_tag, dp->tdir_tag);
+ dp->tdir_tag = IGNORE;
+ fip = field_info;/* restart search */
+ continue;
+ }
+ /*
+ * Null out old tags that we ignore.
+ */
+
+ /* Not implemented yet, since FIELD_IGNORE is specific to
+ the main directories. Could pass this in too... */
+ if (0 /* && fip->field_bit == FIELD_IGNORE */) {
+ ignore:
+ dp->tdir_tag = IGNORE;
+ continue;
+ }
+
+ /*
+ * Check data type.
+ */
+
+ while (dp->tdir_type != (u_short)fip->field_type) {
+ if (fip->field_type == TIFF_ANY) /* wildcard */
+ break;
+ fip++;
+ if (!fip->field_tag || fip->field_tag != dp->tdir_tag) {
+ TIFFWarning(tif->tif_name,
+ "wrong data type %d for \"%s\"; tag ignored",
+ dp->tdir_type, fip[-1].field_name);
+ goto ignore;
+ }
+ }
+ /*
+ * Check count if known in advance.
+ */
+ if (fip->field_readcount != TIFF_VARIABLE) {
+ uint32 expected = (fip->field_readcount == TIFF_SPP) ?
+ (uint32) td->td_samplesperpixel :
+ (uint32) fip->field_readcount;
+ if (!CheckDirCount(tif, dp, expected))
+ goto ignore;
+ }
+
+ /* Now read in and process data from field. */
+ if (!TIFFFetchNormalSubTag(tif, dp, fip, setFieldFn))
+ goto bad;
+
+ }
+
+ if (dir)
+ _TIFFfree(dir);
+ return (1);
+bad:
+ if (dir)
+ _TIFFfree(dir);
+ return (0);
+}
+
+static void
+EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
+{
+ register TIFFDirEntry *dp;
+ register TIFFDirectory *td = &tif->tif_dir;
+ uint16 i;
+
+ if (td->td_stripbytecount)
+ _TIFFfree(td->td_stripbytecount);
+ td->td_stripbytecount = (uint32*)
+ CheckMalloc(tif, td->td_nstrips * sizeof (uint32),
+ "for \"StripByteCounts\" array");
+ if (td->td_compression != COMPRESSION_NONE) {
+ uint32 space = (uint32)(sizeof (TIFFHeader)
+ + sizeof (uint16)
+ + (dircount * sizeof (TIFFDirEntry))
+ + sizeof (uint32));
+ toff_t filesize = TIFFGetFileSize(tif);
+ uint16 n;
+
+ /* calculate amount of space used by indirect values */
+ for (dp = dir, n = dircount; n > 0; n--, dp++) {
+ uint32 cc = dp->tdir_count*tiffDataWidth[dp->tdir_type];
+ if (cc > sizeof (uint32))
+ space += cc;
+ }
+ space = (filesize - space) / td->td_samplesperpixel;
+ for (i = 0; i < td->td_nstrips; i++)
+ td->td_stripbytecount[i] = space;
+ /*
+ * This gross hack handles the case were the offset to
+ * the last strip is past the place where we think the strip
+ * should begin. Since a strip of data must be contiguous,
+ * it's safe to assume that we've overestimated the amount
+ * of data in the strip and trim this number back accordingly.
+ */
+ i--;
+ if (td->td_stripoffset[i] + td->td_stripbytecount[i] > filesize)
+ td->td_stripbytecount[i] =
+ filesize - td->td_stripoffset[i];
+ } else {
+ uint32 rowbytes = TIFFScanlineSize(tif);
+ uint32 rowsperstrip = td->td_imagelength / td->td_nstrips;
+ for (i = 0; i < td->td_nstrips; i++)
+ td->td_stripbytecount[i] = rowbytes*rowsperstrip;
+ }
+ TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
+ if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP))
+ td->td_rowsperstrip = td->td_imagelength;
+}
+
+static void
+MissingRequired(TIFF* tif, const char* tagname)
+{
+ TIFFError(tif->tif_name,
+ "TIFF directory is missing required \"%s\" field", tagname);
+}
+
+/*
+ * Check the count field of a directory
+ * entry against a known value. The caller
+ * is expected to skip/ignore the tag if
+ * there is a mismatch.
+ */
+static int
+CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
+{
+ if (count != dir->tdir_count) {
+ TIFFWarning(tif->tif_name,
+ "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
+ dir->tdir_count, count);
+ return (0);
+ }
+ return (1);
+}
+
+/*
+ * Fetch a contiguous directory item.
+ */
+static tsize_t
+TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp)
+{
+ int w = tiffDataWidth[dir->tdir_type];
+ tsize_t cc = dir->tdir_count * w;
+
+ if (!isMapped(tif)) {
+ if (!SeekOK(tif, dir->tdir_offset))
+ goto bad;
+ if (!ReadOK(tif, cp, cc))
+ goto bad;
+ } else {
+ if (dir->tdir_offset + cc > tif->tif_size)
+ goto bad;
+ _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc);
+ }
+ if (tif->tif_flags & TIFF_SWAB) {
+ switch (dir->tdir_type) {
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count);
+ break;
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ case TIFF_FLOAT:
+ TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count);
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count);
+ break;
+ case TIFF_DOUBLE:
+ TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count);
+ break;
+ }
+ }
+ return (cc);
+bad:
+ TIFFError(tif->tif_name, "Error fetching data for field \"%s\"",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
+ return ((tsize_t) 0);
+}
+
+/*
+ * Fetch an ASCII item from the file.
+ */
+static tsize_t
+TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp)
+{
+ if (dir->tdir_count <= 4) {
+ uint32 l = dir->tdir_offset;
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabLong(&l);
+ _TIFFmemcpy(cp, &l, dir->tdir_count);
+ return (1);
+ }
+ return (TIFFFetchData(tif, dir, cp));
+}
+
+/*
+ * Convert numerator+denominator to float.
+ */
+static int
+cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv)
+{
+ if (denom == 0) {
+ TIFFError(tif->tif_name,
+ "%s: Rational with zero denominator (num = %lu)",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num);
+ return (0);
+ } else {
+ if (dir->tdir_type == TIFF_RATIONAL)
+ *rv = ((float)num / (float)denom);
+ else
+ *rv = ((float)(int32)num / (float)(int32)denom);
+ return (1);
+ }
+}
+
+/*
+ * Fetch a rational item from the file
+ * at offset off and return the value
+ * as a floating point number.
+ */
+static float
+TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir)
+{
+ uint32 l[2];
+ float v;
+
+ return (!TIFFFetchData(tif, dir, (char *)l) ||
+ !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v);
+}
+
+/*
+ * Fetch a single floating point value
+ * from the offset field and return it
+ * as a native float.
+ */
+static float
+TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir)
+{
+ /* This appears to be a flagrant bug in the TIFF library, yet I
+ actually don't understand how it could have ever worked the old
+ way. Look at the comments in my new code and you'll understand. */
+#if (0)
+ float v = (float)
+ TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset);
+ TIFFCvtIEEEFloatToNative(tif, 1, &v);
+#else
+ float v;
+ /* This is a little bit tricky - if we just cast the uint32 to a float,
+ C will perform a numerical conversion, which is not what we want.
+ We want to take the actual bit pattern in the uint32 and interpret
+ it as a float. Thus we cast a uint32 * into a float * and then
+ dereference to get v. */
+ uint32 l = (uint32)
+ TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset);
+ v = * (float *) &l;
+ TIFFCvtIEEEFloatToNative(tif, 1, &v);
+#endif
+ return (v);
+
+}
+
+/*
+ * Fetch an array of BYTE or SBYTE values.
+ */
+static int
+TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v)
+{
+ if (dir->tdir_count <= 4) {
+ /*
+ * Extract data from offset field.
+ */
+ if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
+ switch (dir->tdir_count) {
+ case 4: v[3] = dir->tdir_offset & 0xff;
+ case 3: v[2] = (dir->tdir_offset >> 8) & 0xff;
+ case 2: v[1] = (dir->tdir_offset >> 16) & 0xff;
+ case 1: v[0] = dir->tdir_offset >> 24;
+ }
+ } else {
+ switch (dir->tdir_count) {
+ case 4: v[3] = dir->tdir_offset >> 24;
+ case 3: v[2] = (dir->tdir_offset >> 16) & 0xff;
+ case 2: v[1] = (dir->tdir_offset >> 8) & 0xff;
+ case 1: v[0] = dir->tdir_offset & 0xff;
+ }
+ }
+ return (1);
+ } else
+ return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */
+}
+
+/*
+ * Fetch an array of SHORT or SSHORT values.
+ */
+static int
+TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v)
+{
+ if (dir->tdir_count <= 2) {
+ if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
+ switch (dir->tdir_count) {
+ case 2: v[1] = dir->tdir_offset & 0xffff;
+ case 1: v[0] = dir->tdir_offset >> 16;
+ }
+ } else {
+ switch (dir->tdir_count) {
+ case 2: v[1] = dir->tdir_offset >> 16;
+ case 1: v[0] = dir->tdir_offset & 0xffff;
+ }
+ }
+ return (1);
+ } else
+ return (TIFFFetchData(tif, dir, (char *)v) != 0);
+}
+
+/*
+ * Fetch a pair of SHORT or BYTE values.
+ */
+static int
+TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir)
+{
+ uint16 v[2];
+ int ok = 0;
+
+ switch (dir->tdir_type) {
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ ok = TIFFFetchShortArray(tif, dir, v);
+ break;
+ case TIFF_BYTE:
+ case TIFF_SBYTE:
+ ok = TIFFFetchByteArray(tif, dir, v);
+ break;
+ }
+ if (ok)
+ TIFFSetField(tif, dir->tdir_tag, v[0], v[1]);
+ return (ok);
+}
+
+/*
+ * Fetch an array of LONG or SLONG values.
+ */
+static int
+TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v)
+{
+ if (dir->tdir_count == 1) {
+ v[0] = dir->tdir_offset;
+ return (1);
+ } else
+ return (TIFFFetchData(tif, dir, (char*) v) != 0);
+}
+
+/*
+ * Fetch an array of RATIONAL or SRATIONAL values.
+ */
+static int
+TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v)
+{
+ int ok = 0;
+ uint32* l;
+
+ l = (uint32*)CheckMalloc(tif,
+ dir->tdir_count*tiffDataWidth[dir->tdir_type],
+ "to fetch array of rationals");
+ if (l) {
+ if (TIFFFetchData(tif, dir, (char *)l)) {
+ uint32 i;
+ for (i = 0; i < dir->tdir_count; i++) {
+ ok = cvtRational(tif, dir,
+ l[2*i+0], l[2*i+1], &v[i]);
+ if (!ok)
+ break;
+ }
+ }
+ _TIFFfree((char *)l);
+ }
+ return (ok);
+}
+
+/*
+ * Fetch an array of FLOAT values.
+ */
+static int
+TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v)
+{
+
+ if (dir->tdir_count == 1) {
+ v[0] = *(float*) &dir->tdir_offset;
+ TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v);
+ return (1);
+ } else if (TIFFFetchData(tif, dir, (char*) v)) {
+ TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v);
+ return (1);
+ } else
+ return (0);
+}
+
+/*
+ * Fetch an array of DOUBLE values.
+ */
+static int
+TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v)
+{
+ if (TIFFFetchData(tif, dir, (char*) v)) {
+ TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v);
+ return (1);
+ } else
+ return (0);
+}
+
+/*
+ * Fetch an array of ANY values. The actual values are
+ * returned as doubles which should be able hold all the
+ * types. Yes, there really should be an tany_t to avoid
+ * this potential non-portability ... Note in particular
+ * that we assume that the double return value vector is
+ * large enough to read in any fundamental type. We use
+ * that vector as a buffer to read in the base type vector
+ * and then convert it in place to double (from end
+ * to front of course).
+ */
+static int
+TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v)
+{
+ int i;
+
+ switch (dir->tdir_type) {
+ case TIFF_BYTE:
+ case TIFF_SBYTE:
+ if (!TIFFFetchByteArray(tif, dir, (uint16*) v))
+ return (0);
+ if (dir->tdir_type == TIFF_BYTE) {
+ uint16* vp = (uint16*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ } else {
+ int16* vp = (int16*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ }
+ break;
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ if (!TIFFFetchShortArray(tif, dir, (uint16*) v))
+ return (0);
+ if (dir->tdir_type == TIFF_SHORT) {
+ uint16* vp = (uint16*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ } else {
+ int16* vp = (int16*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ }
+ break;
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ if (!TIFFFetchLongArray(tif, dir, (uint32*) v))
+ return (0);
+ if (dir->tdir_type == TIFF_LONG) {
+ uint32* vp = (uint32*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ } else {
+ int32* vp = (int32*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ }
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ if (!TIFFFetchRationalArray(tif, dir, (float*) v))
+ return (0);
+ { float* vp = (float*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ }
+ break;
+ case TIFF_FLOAT:
+ if (!TIFFFetchFloatArray(tif, dir, (float*) v))
+ return (0);
+ { float* vp = (float*) v;
+ for (i = dir->tdir_count-1; i >= 0; i--)
+ v[i] = vp[i];
+ }
+ break;
+ case TIFF_DOUBLE:
+ return (TIFFFetchDoubleArray(tif, dir, (double*) v));
+ default:
+ /* TIFF_NOTYPE */
+ /* TIFF_ASCII */
+ /* TIFF_UNDEFINED */
+ TIFFError(tif->tif_name,
+ "Cannot read TIFF_ANY type %d for field \"%s\"",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
+ return (0);
+ }
+ return (1);
+}
+
+
+/*
+ * Fetch a tag that is not handled by special case code.
+ */
+/* The standard function TIFFFetchNormalTag() could definitely be replaced
+ with a simple call to this function, just adding TIFFSetField() as the
+ last argument. */
+static int
+TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip,
+ int (*setFieldFn)(TIFF *tif, ttag_t tag, ...))
+{
+ static char mesg[] = "to fetch tag value";
+ int ok = 0;
+
+ if (dp->tdir_count > 1) { /* array of values */
+ char* cp = NULL;
+
+ switch (dp->tdir_type) {
+ case TIFF_BYTE:
+ case TIFF_SBYTE:
+ /* NB: always expand BYTE values to shorts */
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (uint16), mesg);
+ ok = cp && TIFFFetchByteArray(tif, dp, (uint16*) cp);
+ break;
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (uint16), mesg);
+ ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp);
+ break;
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (uint32), mesg);
+ ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp);
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (float), mesg);
+ ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp);
+ break;
+ case TIFF_FLOAT:
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (float), mesg);
+ ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp);
+ break;
+ case TIFF_DOUBLE:
+ cp = CheckMalloc(tif,
+ dp->tdir_count * sizeof (double), mesg);
+ ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp);
+ break;
+ case TIFF_ASCII:
+ case TIFF_UNDEFINED: /* bit of a cheat... */
+ /*
+ * Some vendors write strings w/o the trailing
+ * NULL byte, so always append one just in case.
+ */
+ cp = CheckMalloc(tif, dp->tdir_count+1, mesg);
+ if (ok = (cp && TIFFFetchString(tif, dp, cp)))
+ cp[dp->tdir_count] = '\0'; /* XXX */
+ break;
+ }
+ if (ok) {
+ ok = (fip->field_passcount ?
+ (*setFieldFn)(tif, dp->tdir_tag, dp->tdir_count, cp)
+ : (*setFieldFn)(tif, dp->tdir_tag, cp));
+ }
+ if (cp != NULL)
+ _TIFFfree(cp);
+ } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */
+ switch (dp->tdir_type) {
+ case TIFF_BYTE:
+ case TIFF_SBYTE:
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ /*
+ * If the tag is also acceptable as a LONG or SLONG
+ * then (*setFieldFn) will expect an uint32 parameter
+ * passed to it (through varargs). Thus, for machines
+ * where sizeof (int) != sizeof (uint32) we must do
+ * a careful check here. It's hard to say if this
+ * is worth optimizing.
+ *
+ * NB: We use TIFFFieldWithTag here knowing that
+ * it returns us the first entry in the table
+ * for the tag and that that entry is for the
+ * widest potential data type the tag may have.
+ */
+ { TIFFDataType type = fip->field_type;
+ if (type != TIFF_LONG && type != TIFF_SLONG) {
+ uint16 v = (uint16)
+ TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset);
+ ok = (fip->field_passcount ?
+ (*setFieldFn)(tif, dp->tdir_tag, 1, &v)
+ : (*setFieldFn)(tif, dp->tdir_tag, v));
+ break;
+ }
+ }
+ /* fall thru... */
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ { uint32 v32 =
+ TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset);
+ ok = (fip->field_passcount ?
+ (*setFieldFn)(tif, dp->tdir_tag, 1, &v32)
+ : (*setFieldFn)(tif, dp->tdir_tag, v32));
+ }
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ case TIFF_FLOAT:
+ { float v = (dp->tdir_type == TIFF_FLOAT ?
+ TIFFFetchFloat(tif, dp)
+ : TIFFFetchRational(tif, dp));
+ ok = (fip->field_passcount ?
+ (*setFieldFn)(tif, dp->tdir_tag, 1, &v)
+ : (*setFieldFn)(tif, dp->tdir_tag, v));
+ }
+ break;
+ case TIFF_DOUBLE:
+ { double v;
+ ok = (TIFFFetchDoubleArray(tif, dp, &v) &&
+ (fip->field_passcount ?
+ (*setFieldFn)(tif, dp->tdir_tag, 1, &v)
+ : (*setFieldFn)(tif, dp->tdir_tag, v))
+ );
+ }
+ break;
+ case TIFF_ASCII:
+ case TIFF_UNDEFINED: /* bit of a cheat... */
+ { char c[2];
+ if (ok = (TIFFFetchString(tif, dp, c) != 0)) {
+ c[1] = '\0'; /* XXX paranoid */
+ ok = (*setFieldFn)(tif, dp->tdir_tag, c);
+ }
+ }
+ break;
+ }
+ }
+ return (ok);
+}
+
+/* Everything after this is exactly duplicated from the standard tif_dirread.c
+ file, necessitated by the fact that they are declared static there so
+ we can't call them!
+*/
+#define NITEMS(x) (sizeof (x) / sizeof (x[0]))
+/*
+ * Fetch samples/pixel short values for
+ * the specified tag and verify that
+ * all values are the same.
+ */
+static int
+TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, int* pl)
+{
+ int samples = tif->tif_dir.td_samplesperpixel;
+ int status = 0;
+
+ if (CheckDirCount(tif, dir, (uint32) samples)) {
+ uint16 buf[10];
+ uint16* v = buf;
+
+ if (samples > NITEMS(buf))
+ v = (uint16*) _TIFFmalloc(samples * sizeof (uint16));
+ if (TIFFFetchShortArray(tif, dir, v)) {
+ int i;
+ for (i = 1; i < samples; i++)
+ if (v[i] != v[0]) {
+ TIFFError(tif->tif_name,
+ "Cannot handle different per-sample values for field \"%s\"",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
+ goto bad;
+ }
+ *pl = v[0];
+ status = 1;
+ }
+ bad:
+ if (v != buf)
+ _TIFFfree((char*) v);
+ }
+ return (status);
+}
+
+/*
+ * Fetch samples/pixel ANY values for
+ * the specified tag and verify that
+ * all values are the same.
+ */
+static int
+TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl)
+{
+ int samples = (int) tif->tif_dir.td_samplesperpixel;
+ int status = 0;
+
+ if (CheckDirCount(tif, dir, (uint32) samples)) {
+ double buf[10];
+ double* v = buf;
+
+ if (samples > NITEMS(buf))
+ v = (double*) _TIFFmalloc(samples * sizeof (double));
+ if (TIFFFetchAnyArray(tif, dir, v)) {
+ int i;
+ for (i = 1; i < samples; i++)
+ if (v[i] != v[0]) {
+ TIFFError(tif->tif_name,
+ "Cannot handle different per-sample values for field \"%s\"",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
+ goto bad;
+ }
+ *pl = v[0];
+ status = 1;
+ }
+ bad:
+ if (v != buf)
+ _TIFFfree(v);
+ }
+ return (status);
+}
+#undef NITEMS
+
+/*
+ * Fetch a set of offsets or lengths.
+ * While this routine says "strips",
+ * in fact it's also used for tiles.
+ */
+static int
+TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp)
+{
+ register uint32* lp;
+ int status;
+
+ if (!CheckDirCount(tif, dir, (uint32) nstrips))
+ return (0);
+ /*
+ * Allocate space for strip information.
+ */
+ if (*lpp == NULL &&
+ (*lpp = (uint32 *)CheckMalloc(tif,
+ nstrips * sizeof (uint32), "for strip array")) == NULL)
+ return (0);
+ lp = *lpp;
+ if (dir->tdir_type == (int)TIFF_SHORT) {
+ /*
+ * Handle uint16->uint32 expansion.
+ */
+ uint16* dp = (uint16*) CheckMalloc(tif,
+ dir->tdir_count* sizeof (uint16), "to fetch strip tag");
+ if (dp == NULL)
+ return (0);
+ if (status = TIFFFetchShortArray(tif, dir, dp)) {
+ register uint16* wp = dp;
+ while (nstrips-- > 0)
+ *lp++ = *wp++;
+ }
+ _TIFFfree((char*) dp);
+ } else
+ status = TIFFFetchLongArray(tif, dir, lp);
+ return (status);
+}
+
+#define NITEMS(x) (sizeof (x) / sizeof (x[0]))
+/*
+ * Fetch and set the ExtraSamples tag.
+ */
+static int
+TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir)
+{
+ uint16 buf[10];
+ uint16* v = buf;
+ int status;
+
+ if (dir->tdir_count > NITEMS(buf))
+ v = (uint16*) _TIFFmalloc(dir->tdir_count * sizeof (uint16));
+ if (dir->tdir_type == TIFF_BYTE)
+ status = TIFFFetchByteArray(tif, dir, v);
+ else
+ status = TIFFFetchShortArray(tif, dir, v);
+ if (status)
+ status = TIFFSetField(tif, dir->tdir_tag, dir->tdir_count, v);
+ if (v != buf)
+ _TIFFfree((char*) v);
+ return (status);
+}
+#undef NITEMS
+
+#ifdef COLORIMETRY_SUPPORT
+/*
+ * Fetch and set the RefBlackWhite tag.
+ */
+static int
+TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir)
+{
+ static char mesg[] = "for \"ReferenceBlackWhite\" array";
+ char* cp;
+ int ok;
+
+ if (dir->tdir_type == TIFF_RATIONAL)
+ return (1/*TIFFFetchNormalTag(tif, dir) just so linker won't complain - this part of the code is never used anyway */);
+ /*
+ * Handle LONG's for backward compatibility.
+ */
+ cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32), mesg);
+ if (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) {
+ float* fp = (float*)
+ CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg);
+ if (ok = (fp != NULL)) {
+ uint32 i;
+ for (i = 0; i < dir->tdir_count; i++)
+ fp[i] = (float)((uint32*) cp)[i];
+ ok = TIFFSetField(tif, dir->tdir_tag, fp);
+ _TIFFfree((char*) fp);
+ }
+ }
+ if (cp)
+ _TIFFfree(cp);
+ return (ok);
+}
+#endif
+
+#if STRIPCHOP_SUPPORT
+/*
+ * Replace a single strip (tile) of uncompressed data by
+ * multiple strips (tiles), each approximately 8Kbytes.
+ * This is useful for dealing with large images or
+ * for dealing with machines with a limited amount
+ * memory.
+ */
+static void
+ChopUpSingleUncompressedStrip(TIFF* tif)
+{
+ register TIFFDirectory *td = &tif->tif_dir;
+ uint32 bytecount = td->td_stripbytecount[0];
+ uint32 offset = td->td_stripoffset[0];
+ tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes;
+ tstrip_t strip, nstrips, rowsperstrip;
+ uint32* newcounts;
+ uint32* newoffsets;
+
+ /*
+ * Make the rows hold at least one
+ * scanline, but fill 8k if possible.
+ */
+ if (rowbytes > 8192) {
+ stripbytes = rowbytes;
+ rowsperstrip = 1;
+ } else {
+ rowsperstrip = 8192 / rowbytes;
+ stripbytes = rowbytes * rowsperstrip;
+ }
+ /* never increase the number of strips in an image */
+ if (rowsperstrip >= td->td_rowsperstrip)
+ return;
+ nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes);
+ newcounts = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32),
+ "for chopped \"StripByteCounts\" array");
+ newoffsets = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32),
+ "for chopped \"StripOffsets\" array");
+ if (newcounts == NULL || newoffsets == NULL) {
+ /*
+ * Unable to allocate new strip information, give
+ * up and use the original one strip information.
+ */
+ if (newcounts != NULL)
+ _TIFFfree(newcounts);
+ if (newoffsets != NULL)
+ _TIFFfree(newoffsets);
+ return;
+ }
+ /*
+ * Fill the strip information arrays with
+ * new bytecounts and offsets that reflect
+ * the broken-up format.
+ */
+ for (strip = 0; strip < nstrips; strip++) {
+ if (stripbytes > bytecount)
+ stripbytes = bytecount;
+ newcounts[strip] = stripbytes;
+ newoffsets[strip] = offset;
+ offset += stripbytes;
+ bytecount -= stripbytes;
+ }
+ /*
+ * Replace old single strip info with multi-strip info.
+ */
+ td->td_stripsperimage = td->td_nstrips = nstrips;
+ TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
+
+ _TIFFfree(td->td_stripbytecount);
+ _TIFFfree(td->td_stripoffset);
+ td->td_stripbytecount = newcounts;
+ td->td_stripoffset = newoffsets;
+}
+#endif /* STRIPCHOP_SUPPORT */
diff --git a/contrib/pds/tif_pdsdirwrite.c b/contrib/pds/tif_pdsdirwrite.c
new file mode 100644
index 00000000..73dbd9ce
--- /dev/null
+++ b/contrib/pds/tif_pdsdirwrite.c
@@ -0,0 +1,964 @@
+/* $Header: /d1/sam/tiff/contrib/pds/RCS/tif_pdsdirwrite.c,v 1.1 1997/08/29 23:12:56 sam Exp $ */
+
+/* When writing data to TIFF files, it is often useful to store application-
+ specific data in a private TIFF directory so that the tags don't need to
+ be registered and won't conflict with other people's user-defined tags.
+ One needs to have a registered public tag which contains some amount of
+ raw data. That raw data, however, is interpreted at an independent,
+ separate, private tiff directory. This file provides some routines which
+ will be useful for converting that data from its raw binary form into
+ the proper form for your application.
+*/
+
+/*
+ * Copyright (c) 1988-1996 Sam Leffler
+ * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c( 1996 USAF Phillips Laboratory
+ *
+ * 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.
+ */
+
+/*
+ * TIFF Library.
+ *
+ * These routines written by Conrad J. Poelman on a single late-night of
+ * March 20-21, 1996.
+ *
+ * The entire purpose of this file is to provide a single external function,
+ * TIFFWritePrivateDataSubDirectory(). This function is intended for use
+ * in writing a private subdirectory structure into a TIFF file. The
+ * actual reading of data from the structure is handled by the getFieldFn(),
+ * which is passed to TIFFWritePrivateDataSubDirectory() as a parameter. The
+ * idea is to enable any application wishing to read private subdirectories to
+ * do so easily using this function, without modifying the TIFF library.
+ *
+ * The astute observer will notice that only two functions are at all different
+ * from the original tif_dirwrite.c file: TIFFWritePrivateDataSubDirectory()and
+ * TIFFWriteNormalSubTag(). All the other stuff that makes this file so huge
+ * is only necessary because all of those functions are declared static in
+ * tif_dirwrite.c, so we have to totally duplicate them in order to use them.
+ *
+ * Oh, also please note the bug-fix in the routine TIFFWriteNormalSubTag(),
+ * which equally should be applied to TIFFWriteNormalTag().
+ *
+ */
+#include "tiffiop.h"
+
+#if HAVE_IEEEFP
+#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
+#define TIFFCvtNativeToIEEEDouble(tif, n, dp)
+#else
+extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*);
+extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*);
+#endif
+
+static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*);
+static int TIFFWriteNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*,
+ int (*getFieldFn)(TIFF *tif,ttag_t tag,...));
+static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32);
+static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*);
+static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*);
+static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*);
+static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**);
+static int TIFFWriteShortArray(TIFF*,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint16*);
+static int TIFFWriteLongArray(TIFF *,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint32*);
+static int TIFFWriteRationalArray(TIFF *,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*);
+static int TIFFWriteFloatArray(TIFF *,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*);
+static int TIFFWriteDoubleArray(TIFF *,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*);
+static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*);
+static int TIFFWriteAnyArray(TIFF*,
+ TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*);
+#ifdef COLORIMETRY_SUPPORT
+static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*);
+#endif
+static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*);
+static int TIFFLinkDirectory(TIFF*);
+
+#define WriteRationalPair(type, tag1, v1, tag2, v2) { \
+ if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \
+ goto bad; \
+ if (!TIFFWriteRational(tif, type, tag2, dir+1, v2)) \
+ goto bad; \
+ dir++; \
+}
+#define TIFFWriteRational(tif, type, tag, dir, v) \
+ TIFFWriteRationalArray((tif), (type), (tag), (dir), 1, &(v))
+#ifndef TIFFWriteRational
+static int TIFFWriteRational(TIFF*,
+ TIFFDataType, ttag_t, TIFFDirEntry*, float);
+#endif
+
+/* This function will write an entire directory to the disk, and return the
+ offset value indicating where in the file it wrote the beginning of the
+ directory structure. This is NOT the same as the offset value before
+ calling this function, because some of the fields may have caused various
+ data items to be written out BEFORE writing the directory structure.
+
+ This code was basically written by ripping of the TIFFWriteDirectory()
+ code and generalizing it, using RPS's TIFFWritePliIfd() code for
+ inspiration. My original goal was to make this code general enough that
+ the original TIFFWriteDirectory() could be rewritten to just call this
+ function with the appropriate field and field-accessing arguments.
+
+ However, now I realize that there's a lot of code that gets executed for
+ the main, standard TIFF directories that does not apply to special
+ private subdirectories, so such a reimplementation for the sake of
+ eliminating redundant or duplicate code is probably not possible,
+ unless we also pass in a Main flag to indiciate which type of handling
+ to do, which would be kind of a hack. I've marked those places where I
+ changed or ripped out code which would have to be re-inserted to
+ generalize this function. If it can be done in a clean and graceful way,
+ it would be a great way to generalize the TIFF library. Otherwise, I'll
+ just leave this code here where it duplicates but remains on top of and
+ hopefully mostly independent of the main TIFF library.
+
+ The caller will probably want to free the sub directory structure after
+ returning from this call, since otherwise once written out, the user
+ is likely to forget about it and leave data lying around.
+*/
+toff_t
+TIFFWritePrivateDataSubDirectory(TIFF* tif,
+ uint32 pdir_fieldsset[], int pdir_fields_last,
+ TIFFFieldInfo *field_info,
+ int (*getFieldFn)(TIFF *tif, ttag_t tag, ...))
+{
+ uint16 dircount;
+ uint32 diroff, nextdiroff;
+ ttag_t tag;
+ uint32 nfields;
+ tsize_t dirsize;
+ char* data;
+ TIFFDirEntry* dir;
+ u_long b, *fields, fields_size;
+ toff_t directory_offset;
+ TIFFFieldInfo* fip;
+
+ /*
+ * Deleted out all of the encoder flushing and such code from here -
+ * not necessary for subdirectories.
+ */
+
+ /* Finish writing out any image data. */
+ TIFFFlushData(tif);
+
+ /*
+ * Size the directory so that we can calculate
+ * offsets for the data items that aren't kept
+ * in-place in each field.
+ */
+ nfields = 0;
+ for (b = 0; b <= pdir_fields_last; b++)
+ if (FieldSet(pdir_fieldsset, b))
+ /* Deleted code to make size of first 4 tags 2
+ instead of 1. */
+ nfields += 1;
+ dirsize = nfields * sizeof (TIFFDirEntry);
+ data = (char*) _TIFFmalloc(dirsize);
+ if (data == NULL) {
+ TIFFError(tif->tif_name,
+ "Cannot write private subdirectory, out of space");
+ return (0);
+ }
+ /*
+ * Place directory in data section of the file. If there isn't one
+ * yet, place it at the end of the file. The directory is treated as
+ * data, so we don't link it into the directory structure at all.
+ */
+ if (tif->tif_dataoff == 0)
+ tif->tif_dataoff =(TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
+ diroff = tif->tif_dataoff;
+ tif->tif_dataoff = (toff_t)(
+ diroff + sizeof (uint16) + dirsize + sizeof (toff_t));
+ if (tif->tif_dataoff & 1)
+ tif->tif_dataoff++;
+ (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
+ /*tif->tif_curdir++;*/
+ dir = (TIFFDirEntry*) data;
+ /*
+ * Setup external form of directory
+ * entries and write data items.
+ */
+ /*
+ * We make a local copy of the fieldsset here so that we don't mess
+ * up the original one when we call ResetFieldBit(). But I'm not sure
+ * why the original code calls ResetFieldBit(), since we're already
+ * going through the fields in order...
+ *
+ * fields_size is the number of uint32's we will need to hold the
+ * bit-mask for all of the fields. If our highest field number is
+ * 100, then we'll need 100 / (8*4)+1 == 4 uint32's to hold the
+ * fieldset.
+ *
+ * Unlike the original code, we allocate fields dynamically based
+ * on the requested pdir_fields_last value, allowing private
+ * data subdirectories to contain more than the built-in code's limit
+ * of 95 tags in a directory.
+ */
+ fields_size = pdir_fields_last / (8*sizeof(uint32)) + 1;
+ fields = _TIFFmalloc(fields_size*sizeof(uint32));
+ _TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32));
+
+ /* Deleted "write out extra samples tag" code here. */
+
+ /* Deleted code for checking a billion little special cases for the
+ * standard TIFF tags. Should add a general mechanism for overloading
+ * write function for each field, just like Brian kept telling me!!!
+ */
+ for (fip = field_info; fip->field_tag; fip++) {
+ /* Deleted code to check for FIELD_IGNORE!! */
+ if (/* fip->field_bit == FIELD_IGNORE || */
+ !FieldSet(fields, fip->field_bit))
+ continue;
+ if (!TIFFWriteNormalSubTag(tif, dir, fip, getFieldFn))
+ goto bad;
+ dir++;
+ ResetFieldBit(fields, fip->field_bit);
+ }
+
+ /* Now we've written all of the referenced data, and are about to
+ write the main directory structure, so grab the tif_dataoff value
+ now so we can remember where we wrote the directory. */
+ directory_offset = tif->tif_dataoff;
+
+ /*
+ * Write directory.
+ */
+ dircount = (uint16) nfields;
+ /* Deleted code to link to the next directory - we set it to zero! */
+ nextdiroff = 0;
+ if (tif->tif_flags & TIFF_SWAB) {
+ /*
+ * The file's byte order is opposite to the
+ * native machine architecture. We overwrite
+ * the directory information with impunity
+ * because it'll be released below after we
+ * write it to the file. Note that all the
+ * other tag construction routines assume that
+ * we do this byte-swapping; i.e. they only
+ * byte-swap indirect data.
+ */
+ for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) {
+ TIFFSwabArrayOfShort(&dir->tdir_tag, 2);
+ TIFFSwabArrayOfLong(&dir->tdir_count, 2);
+ }
+ dircount = (uint16) nfields;
+ TIFFSwabShort(&dircount);
+ TIFFSwabLong(&nextdiroff);
+ }
+
+ (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
+ if (!WriteOK(tif, &dircount, sizeof (dircount))) {
+ TIFFError(tif->tif_name, "Error writing private subdirectory count");
+ goto bad;
+ }
+ if (!WriteOK(tif, data, dirsize)) {
+ TIFFError(tif->tif_name, "Error writing private subdirectory contents");
+ goto bad;
+ }
+ if (!WriteOK(tif, &nextdiroff, sizeof (nextdiroff))) {
+ TIFFError(tif->tif_name, "Error writing private subdirectory link");
+ goto bad;
+ }
+ tif->tif_dataoff += sizeof(dircount) + dirsize + sizeof(nextdiroff);
+
+ _TIFFfree(data);
+ _TIFFfree(fields);
+ tif->tif_flags &= ~TIFF_DIRTYDIRECT;
+
+#if (0)
+ /* This stuff commented out because I don't think we want it for
+ subdirectories, but I could be wrong. */
+ (*tif->tif_cleanup)(tif);
+
+ /*
+ * Reset directory-related state for subsequent
+ * directories.
+ */
+ TIFFDefaultDirectory(tif);
+ tif->tif_curoff = 0;
+ tif->tif_row = (uint32) -1;
+ tif->tif_curstrip = (tstrip_t) -1;
+#endif
+
+ return (directory_offset);
+bad:
+ _TIFFfree(data);
+ _TIFFfree(fields);
+ return (0);
+}
+#undef WriteRationalPair
+
+/*
+ * Process tags that are not special cased.
+ */
+/* The standard function TIFFWriteNormalTag() could definitely be replaced
+ with a simple call to this function, just adding TIFFGetField() as the
+ last argument. */
+static int
+TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip,
+ int (*getFieldFn)(TIFF *tif, ttag_t tag, ...))
+{
+ u_short wc = (u_short) fip->field_writecount;
+
+ dir->tdir_tag = fip->field_tag;
+ dir->tdir_type = (u_short) fip->field_type;
+ dir->tdir_count = wc;
+#define WRITEF(x,y) x(tif, fip->field_type, fip->field_tag, dir, wc, y)
+ switch (fip->field_type) {
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ if (wc > 1) {
+ uint16* wp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &wp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &wp);
+ if (!WRITEF(TIFFWriteShortArray, wp))
+ return (0);
+ } else {
+ uint16 sv;
+ (*getFieldFn)(tif, fip->field_tag, &sv);
+ dir->tdir_offset =
+ TIFFInsertData(tif, dir->tdir_type, sv);
+ }
+ break;
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ if (wc > 1) {
+ uint32* lp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &lp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &lp);
+ if (!WRITEF(TIFFWriteLongArray, lp))
+ return (0);
+ } else {
+ /* XXX handle LONG->SHORT conversion */
+ (*getFieldFn)(tif, fip->field_tag, &dir->tdir_offset);
+ }
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ if (wc > 1) {
+ float* fp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &fp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &fp);
+ if (!WRITEF(TIFFWriteRationalArray, fp))
+ return (0);
+ } else {
+ float fv;
+ (*getFieldFn)(tif, fip->field_tag, &fv);
+ if (!WRITEF(TIFFWriteRationalArray, &fv))
+ return (0);
+ }
+ break;
+ case TIFF_FLOAT:
+ if (wc > 1) {
+ float* fp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &fp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &fp);
+ if (!WRITEF(TIFFWriteFloatArray, fp))
+ return (0);
+ } else {
+ float fv;
+ (*getFieldFn)(tif, fip->field_tag, &fv);
+ if (!WRITEF(TIFFWriteFloatArray, &fv))
+ return (0);
+ }
+ break;
+ case TIFF_DOUBLE:
+ /* Hey - I think this is a bug, or at least a "gross
+ inconsistency", in the TIFF library. Look at the original
+ TIFF library code below within the "#if (0) ... #else".
+ Just from the type of *dp, you can see that this code
+ expects TIFFGetField() to be handed a double ** for
+ any TIFF_DOUBLE tag, even for the constant wc==1 case.
+ This is totally inconsistent with other fields (like
+ TIFF_FLOAT, above) and is also inconsistent with the
+ TIFFSetField() function for TIFF_DOUBLEs, which expects
+ to be passed a single double by value for the wc==1 case.
+ (See the handling of TIFFFetchNormalTag() in tif_dirread.c
+ for an example.) Maybe this function was written before
+ TIFFWriteDoubleArray() was written, not that that's an
+ excuse. Anyway, the new code below is a trivial modification
+ of the TIFF_FLOAT code above. The fact that even single
+ doubles get written out in the data segment and get an
+ offset value stored is irrelevant here - that is all
+ handled by TIFFWriteDoubleArray(). */
+#if (0)
+ { double* dp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &dp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &dp);
+ TIFFCvtNativeToIEEEDouble(tif, wc, dp);
+ if (!TIFFWriteData(tif, dir, (char*) dp))
+ return (0);
+ }
+#else
+ if (wc > 1) {
+ double* dp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &dp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &dp);
+ if (!WRITEF(TIFFWriteDoubleArray, dp))
+ return (0);
+ } else {
+ double dv;
+ (*getFieldFn)(tif, fip->field_tag, &dv);
+ if (!WRITEF(TIFFWriteDoubleArray, &dv))
+ return (0);
+ }
+#endif
+ break;
+ case TIFF_ASCII:
+ { char* cp;
+ (*getFieldFn)(tif, fip->field_tag, &cp);
+ dir->tdir_count = (uint32) (strlen(cp) + 1);
+ if (!TIFFWriteByteArray(tif, dir, cp))
+ return (0);
+ }
+ break;
+ case TIFF_UNDEFINED:
+ { char* cp;
+ if (wc == (u_short) TIFF_VARIABLE) {
+ (*getFieldFn)(tif, fip->field_tag, &wc, &cp);
+ dir->tdir_count = wc;
+ } else
+ (*getFieldFn)(tif, fip->field_tag, &cp);
+ if (!TIFFWriteByteArray(tif, dir, cp))
+ return (0);
+ }
+ break;
+ }
+ return (1);
+}
+#undef WRITEF
+
+/* Everything after this is exactly duplicated from the standard tif_dirwrite.c
+ file, necessitated by the fact that they are declared static there so
+ we can't call them!
+*/
+/*
+ * Setup a directory entry with either a SHORT
+ * or LONG type according to the value.
+ */
+static void
+TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v)
+{
+ dir->tdir_tag = tag;
+ dir->tdir_count = 1;
+ if (v > 0xffffL) {
+ dir->tdir_type = (short) TIFF_LONG;
+ dir->tdir_offset = v;
+ } else {
+ dir->tdir_type = (short) TIFF_SHORT;
+ dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v);
+ }
+}
+#undef MakeShortDirent
+
+#ifndef TIFFWriteRational
+/*
+ * Setup a RATIONAL directory entry and
+ * write the associated indirect value.
+ */
+static int
+TIFFWriteRational(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v)
+{
+ return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v));
+}
+#endif
+
+#define NITEMS(x) (sizeof (x) / sizeof (x[0]))
+/*
+ * Setup a directory entry that references a
+ * samples/pixel array of SHORT values and
+ * (potentially) write the associated indirect
+ * values.
+ */
+static int
+TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
+{
+ uint16 buf[10], v;
+ uint16* w = buf;
+ int i, status, samples = tif->tif_dir.td_samplesperpixel;
+
+ if (samples > NITEMS(buf))
+ w = (uint16*) _TIFFmalloc(samples * sizeof (uint16));
+ TIFFGetField(tif, tag, &v);
+ for (i = 0; i < samples; i++)
+ w[i] = v;
+ status = TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, samples, w);
+ if (w != buf)
+ _TIFFfree((char*) w);
+ return (status);
+}
+
+/*
+ * Setup a directory entry that references a samples/pixel array of ``type''
+ * values and (potentially) write the associated indirect values. The source
+ * data from TIFFGetField() for the specified tag must be returned as double.
+ */
+static int
+TIFFWritePerSampleAnys(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir)
+{
+ double buf[10], v;
+ double* w = buf;
+ int i, status;
+ int samples = (int) tif->tif_dir.td_samplesperpixel;
+
+ if (samples > NITEMS(buf))
+ w = (double*) _TIFFmalloc(samples * sizeof (double));
+ TIFFGetField(tif, tag, &v);
+ for (i = 0; i < samples; i++)
+ w[i] = v;
+ status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w);
+ if (w != buf)
+ _TIFFfree(w);
+ return (status);
+}
+#undef NITEMS
+
+/*
+ * Setup a pair of shorts that are returned by
+ * value, rather than as a reference to an array.
+ */
+static int
+TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
+{
+ uint16 v[2];
+
+ TIFFGetField(tif, tag, &v[0], &v[1]);
+ return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v));
+}
+
+/*
+ * Setup a directory entry for an NxM table of shorts,
+ * where M is known to be 2**bitspersample, and write
+ * the associated indirect data.
+ */
+static int
+TIFFWriteShortTable(TIFF* tif,
+ ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table)
+{
+ uint32 i, off;
+
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) TIFF_SHORT;
+ /* XXX -- yech, fool TIFFWriteData */
+ dir->tdir_count = (uint32) (1L<<tif->tif_dir.td_bitspersample);
+ off = tif->tif_dataoff;
+ for (i = 0; i < n; i++)
+ if (!TIFFWriteData(tif, dir, (char *)table[i]))
+ return (0);
+ dir->tdir_count *= n;
+ dir->tdir_offset = off;
+ return (1);
+}
+
+/*
+ * Write/copy data associated with an ASCII or opaque tag value.
+ */
+static int
+TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp)
+{
+ if (dir->tdir_count > 4) {
+ if (!TIFFWriteData(tif, dir, cp))
+ return (0);
+ } else
+ _TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count);
+ return (1);
+}
+
+/*
+ * Setup a directory entry of an array of SHORT
+ * or SSHORT and write the associated indirect values.
+ */
+static int
+TIFFWriteShortArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16* v)
+{
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ if (n <= 2) {
+ if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
+ dir->tdir_offset = (uint32) ((long) v[0] << 16);
+ if (n == 2)
+ dir->tdir_offset |= v[1] & 0xffff;
+ } else {
+ dir->tdir_offset = v[0] & 0xffff;
+ if (n == 2)
+ dir->tdir_offset |= (long) v[1] << 16;
+ }
+ return (1);
+ } else
+ return (TIFFWriteData(tif, dir, (char*) v));
+}
+
+/*
+ * Setup a directory entry of an array of LONG
+ * or SLONG and write the associated indirect values.
+ */
+static int
+TIFFWriteLongArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint32* v)
+{
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ if (n == 1) {
+ dir->tdir_offset = v[0];
+ return (1);
+ } else
+ return (TIFFWriteData(tif, dir, (char*) v));
+}
+
+/*
+ * Setup a directory entry of an array of RATIONAL
+ * or SRATIONAL and write the associated indirect values.
+ */
+static int
+TIFFWriteRationalArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
+{
+ uint32 i;
+ uint32* t;
+ int status;
+
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32));
+ for (i = 0; i < n; i++) {
+ float fv = v[i];
+ int sign = 1;
+ uint32 den;
+
+ if (fv < 0) {
+ if (type == TIFF_RATIONAL) {
+ TIFFWarning(tif->tif_name,
+ "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
+ _TIFFFieldWithTag(tif,tag)->field_name, v);
+ fv = 0;
+ } else
+ fv = -fv, sign = -1;
+ }
+ den = 1L;
+ if (fv > 0) {
+ while (fv < 1L<<(31-3) && den < 1L<<(31-3))
+ fv *= 1<<3, den *= 1L<<3;
+ }
+ t[2*i+0] = sign * (fv + 0.5);
+ t[2*i+1] = den;
+ }
+ status = TIFFWriteData(tif, dir, (char *)t);
+ _TIFFfree((char*) t);
+ return (status);
+}
+
+static int
+TIFFWriteFloatArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v)
+{
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ TIFFCvtNativeToIEEEFloat(tif, n, v);
+ if (n == 1) {
+ dir->tdir_offset = *(uint32*) &v[0];
+ return (1);
+ } else
+ return (TIFFWriteData(tif, dir, (char*) v));
+}
+
+static int
+TIFFWriteDoubleArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v)
+{
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ TIFFCvtNativeToIEEEDouble(tif, n, v);
+ return (TIFFWriteData(tif, dir, (char*) v));
+}
+
+/*
+ * Write an array of ``type'' values for a specified tag (i.e. this is a tag
+ * which is allowed to have different types, e.g. SMaxSampleType).
+ * Internally the data values are represented as double since a double can
+ * hold any of the TIFF tag types (yes, this should really be an abstract
+ * type tany_t for portability). The data is converted into the specified
+ * type in a temporary buffer and then handed off to the appropriate array
+ * writer.
+ */
+static int
+TIFFWriteAnyArray(TIFF* tif,
+ TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v)
+{
+ char buf[10 * sizeof(double)];
+ char* w = buf;
+ int i, status = 0;
+
+ if (n * tiffDataWidth[type] > sizeof buf)
+ w = (char*) _TIFFmalloc(n * tiffDataWidth[type]);
+ switch (type) {
+ case TIFF_BYTE:
+ { unsigned char* bp = (unsigned char*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (unsigned char) v[i];
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ if (!TIFFWriteByteArray(tif, dir, (char*) bp))
+ goto out;
+ }
+ break;
+ case TIFF_SBYTE:
+ { signed char* bp = (signed char*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (signed char) v[i];
+ dir->tdir_tag = tag;
+ dir->tdir_type = (short) type;
+ dir->tdir_count = n;
+ if (!TIFFWriteByteArray(tif, dir, (char*) bp))
+ goto out;
+ }
+ break;
+ case TIFF_SHORT:
+ { uint16* bp = (uint16*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (uint16) v[i];
+ if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp))
+ goto out;
+ }
+ break;
+ case TIFF_SSHORT:
+ { int16* bp = (int16*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (int16) v[i];
+ if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp))
+ goto out;
+ }
+ break;
+ case TIFF_LONG:
+ { uint32* bp = (uint32*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (uint32) v[i];
+ if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp))
+ goto out;
+ }
+ break;
+ case TIFF_SLONG:
+ { int32* bp = (int32*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (int32) v[i];
+ if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32*) bp))
+ goto out;
+ }
+ break;
+ case TIFF_FLOAT:
+ { float* bp = (float*) w;
+ for (i = 0; i < n; i++)
+ bp[i] = (float) v[i];
+ if (!TIFFWriteFloatArray(tif, type, tag, dir, n, bp))
+ goto out;
+ }
+ break;
+ case TIFF_DOUBLE:
+ return (TIFFWriteDoubleArray(tif, type, tag, dir, n, v));
+ default:
+ /* TIFF_NOTYPE */
+ /* TIFF_ASCII */
+ /* TIFF_UNDEFINED */
+ /* TIFF_RATIONAL */
+ /* TIFF_SRATIONAL */
+ goto out;
+ }
+ status = 1;
+ out:
+ if (w != buf)
+ _TIFFfree(w);
+ return (status);
+}
+
+#ifdef COLORIMETRY_SUPPORT
+static int
+TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ tsize_t n = (1L<<td->td_bitspersample) * sizeof (uint16);
+ uint16** tf = td->td_transferfunction;
+ int ncols;
+
+ /*
+ * Check if the table can be written as a single column,
+ * or if it must be written as 3 columns. Note that we
+ * write a 3-column tag if there are 2 samples/pixel and
+ * a single column of data won't suffice--hmm.
+ */
+ switch (td->td_samplesperpixel - td->td_extrasamples) {
+ default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; }
+ case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; }
+ case 1: case 0: ncols = 1;
+ }
+ return (TIFFWriteShortTable(tif,
+ TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf));
+}
+#endif
+
+/*
+ * Write a contiguous directory item.
+ */
+static int
+TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
+{
+ tsize_t cc;
+
+ if (tif->tif_flags & TIFF_SWAB) {
+ switch (dir->tdir_type) {
+ case TIFF_SHORT:
+ case TIFF_SSHORT:
+ TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count);
+ break;
+ case TIFF_LONG:
+ case TIFF_SLONG:
+ case TIFF_FLOAT:
+ TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count);
+ break;
+ case TIFF_RATIONAL:
+ case TIFF_SRATIONAL:
+ TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count);
+ break;
+ case TIFF_DOUBLE:
+ TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count);
+ break;
+ }
+ }
+ dir->tdir_offset = tif->tif_dataoff;
+ cc = dir->tdir_count * tiffDataWidth[dir->tdir_type];
+ if (SeekOK(tif, dir->tdir_offset) &&
+ WriteOK(tif, cp, cc)) {
+ tif->tif_dataoff += (cc + 1) & ~1;
+ return (1);
+ }
+ TIFFError(tif->tif_name, "Error writing data for field \"%s\"",
+ _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
+ return (0);
+}
+
+/*
+ * Link the current directory into the
+ * directory chain for the file.
+ */
+static int
+TIFFLinkDirectory(TIFF* tif)
+{
+ static const char module[] = "TIFFLinkDirectory";
+ uint32 nextdir;
+ uint32 diroff;
+
+ tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
+ diroff = (uint32) tif->tif_diroff;
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabLong(&diroff);
+#if SUBIFD_SUPPORT
+ if (tif->tif_flags & TIFF_INSUBIFD) {
+ (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
+ if (!WriteOK(tif, &diroff, sizeof (diroff))) {
+ TIFFError(module,
+ "%s: Error writing SubIFD directory link",
+ tif->tif_name);
+ return (0);
+ }
+ /*
+ * Advance to the next SubIFD or, if this is
+ * the last one configured, revert back to the
+ * normal directory linkage.
+ */
+ if (--tif->tif_nsubifd)
+ tif->tif_subifdoff += sizeof (diroff);
+ else
+ tif->tif_flags &= ~TIFF_INSUBIFD;
+ return (1);
+ }
+#endif
+ if (tif->tif_header.tiff_diroff == 0) {
+ /*
+ * First directory, overwrite offset in header.
+ */
+ tif->tif_header.tiff_diroff = (uint32) tif->tif_diroff;
+#define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f))
+ (void) TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET);
+ if (!WriteOK(tif, &diroff, sizeof (diroff))) {
+ TIFFError(tif->tif_name, "Error writing TIFF header");
+ return (0);
+ }
+ return (1);
+ }
+ /*
+ * Not the first directory, search to the last and append.
+ */
+ nextdir = tif->tif_header.tiff_diroff;
+ do {
+ uint16 dircount;
+
+ if (!SeekOK(tif, nextdir) ||
+ !ReadOK(tif, &dircount, sizeof (dircount))) {
+ TIFFError(module, "Error fetching directory count");
+ return (0);
+ }
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabShort(&dircount);
+ (void) TIFFSeekFile(tif,
+ dircount * sizeof (TIFFDirEntry), SEEK_CUR);
+ if (!ReadOK(tif, &nextdir, sizeof (nextdir))) {
+ TIFFError(module, "Error fetching directory link");
+ return (0);
+ }
+ if (tif->tif_flags & TIFF_SWAB)
+ TIFFSwabLong(&nextdir);
+ } while (nextdir != 0);
+ (void) TIFFSeekFile(tif, -(toff_t) sizeof (nextdir), SEEK_CUR);
+ if (!WriteOK(tif, &diroff, sizeof (diroff))) {
+ TIFFError(module, "Error writing directory link");
+ return (0);
+ }
+ return (1);
+}
diff --git a/contrib/ras/README b/contrib/ras/README
new file mode 100644
index 00000000..f87bfde0
--- /dev/null
+++ b/contrib/ras/README
@@ -0,0 +1,10 @@
+Sun May 19 22:28:16 PDT 1991
+
+These programs are from Patrick Naughton (naughton@wind.sun.com).
+I've tried to update them to reflect changes to the library, but
+I am unable to verify that they operate properly, because they
+require the Sun pixrect library.
+
+Please contact Patrick directly if you have questions/problems.
+
+ Sam
diff --git a/contrib/winnt/README.console b/contrib/winnt/README.console
new file mode 100644
index 00000000..05d7dd58
--- /dev/null
+++ b/contrib/winnt/README.console
@@ -0,0 +1,182 @@
+Date: Fri, 18 Apr 1997 09:25:09 EDT
+To: "'sam@cthulhu.engr.sgi.com'" <sam@cthulhu.engr.sgi.com>
+cc: "'tiff@sgi.engr.sgi.com'" <tiff@sgi.engr.sgi.com>
+
+From: xingong chang <xingong@feith1.FEITH.COM>
+Subject: Contribution: libtiff for Windows-nt console applications
+
+Return-Path: xingong@feith1.FEITH.COM
+Delivery-Date: Fri, 18 Apr 1997 06:37:38 -0700
+Return-Path: xingong@feith1.FEITH.COM
+MIME-Version: 1.0
+
+Hi,
+I built the libtiff under WINNT 4.0 as a 32-bit library for pure
+console applications. I made the makefile.nt based on Philippe
+Tenenhaus' makefile.w95 file. Since I want my stuff to be a pure
+console application running on WinNT, Dave Dyer's makefile for WINNT is
+not good for me since it is for Windows applications.
+
+I used the tif_msdos.c file instead of the tif_win32.c in the $(OBJS)
+list because tif_win32.c is not a pure console program, it includes
+some function calls such as MessageBox etc which requires windows
+application library ($winslib as defined in <ntwin32.mak>).
+
+unlike Philippe Tenenhaus' makefile.w95 file, this makefile.nt does
+support fax3 stuff. And to make the mkg3states.exe,the getopt.obj is
+needed. "getopt" package is ATT public domain source for getopt(3).
+Also you need to inlcude the g3states.h in tif_fax.c fileand modify the
+tif_fax3.h to delete the external declaration of FFFaxMainTable,
+TIFFFaxWhileTable and TIFFFaxBlackTable
+
+
+libtiff version: TIFFLIB_VERSION 19960307
+
+Hardware you are using: i386
+
+Operating system you are using: Windows NT 4.0
+
+C compiler : Microsoft Visual C++ 4.1
+
+NMAKE : Microsoft nmake 1.61
+
+
+Here is the makefile.nt I used:
+---------------------------------------------------------
+
+# makefile.nt for the tiff library
+# Tag Image File Format Library
+#
+# Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
+# Copyright (c) 1991, 1992 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.
+#
+# This Makefile is for use with microsoft nmake version 1.61
+#
+
+!include <ntwin32.mak>
+
+DEFS = -DBSDTYPES -DO_RDONLY=S_IREAD -DO_RDWR=S_IWRITE
+
+INCS= tiff.h tiffio.h
+SRCS= tif_aux.c \
+ tif_close.c \
+ tif_codec.c \
+ tif_compress.c \
+ tif_dir.c \
+ tif_dirinfo.c \
+ tif_dirread.c \
+ tif_dirwrite.c \
+ tif_dumpmode.c \
+ tif_error.c \
+ tif_getimage.c \
+ tif_jpeg.c \
+ tif_flush.c \
+ tif_lzw.c \
+ tif_next.c \
+ tif_open.c \
+ tif_packbits.c \
+ tif_predict \
+ tif_print.c \
+ tif_read.c \
+ tif_swab.c \
+ tif_strip.c \
+ tif_thunder.c \
+ tif_tile.c \
+ tif_version.c \
+ tif_warning.c \
+ tif_write.c \
+ tif_msdos.c \
+ tif_fax3.c
+
+
+OBJS= tif_aux.obj \
+ tif_close.obj \
+ tif_codec.obj \
+ tif_compress.obj \
+ tif_dir.obj \
+ tif_dirinfo.obj \
+ tif_dirread.obj \
+ tif_dirwrite.obj \
+ tif_dumpmode.obj \
+ tif_error.obj \
+ tif_getimage.obj \
+ tif_jpeg.obj \
+ tif_flush.obj \
+ tif_lzw.obj \
+ tif_next.obj \
+ tif_open.obj \
+ tif_packbits.obj \
+ tif_predict.obj \
+ tif_print.obj \
+ tif_read.obj \
+ tif_swab.obj \
+ tif_strip.obj \
+ tif_thunder.obj \
+ tif_tile.obj \
+ tif_version.obj \
+ tif_warning.obj \
+ tif_write.obj \
+ tif_msdos.obj \
+ tif_fax3.obj
+
+#To make the mkg3states.exe,the getopt.obj is needed. getopt package is
+# ATT public domain source for getopt(3).
+EXTRA_OBJS = getopt.obj
+
+all: libtiff.lib
+
+libtiff.lib: $(OBJS)
+ del libtiff.lib
+ lib -out:libtiff.lib $(OBJS)
+
+.c.obj:
+ $(cc) $(DEFS) $(cdebug) $(cflags) $(cvarsmt) $*.c
+
+
+#To include fax3 support, we did this modification
+#add to the build script : tif_fax3.c and tif_fax3.obj
+#define CCITT_SUPPORT in the file tifconf.h
+#inlcude the g3states.h in tif_fax.c file
+#modify the tif_fax3.h to delete the TIFFFaxMainTable,TIFFFaxWhileTable
+# TIFFFaxBlackTable etc external declaration
+#mkg3states.exe without any command line options will produce the g3states.h
+
+$(OBJS): tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h
+tif_fax3.obj: tif_fax3.c g3states.h t4.h tif_fax3.h
+
+g3states.h: mkg3states.obj t4.h
+ $(link) $(ldebug) $(conslflags) -out:mkg3states.exe mkg3states.obj \
+ $(EXTRA_OBJS)
+ mkg3states.exe
+
+clean:
+ del *.obj
+ del g3states.h
+
+clobber:
+ del libtiff.lib
+ del *.obj
+ del g3states.h
+
+
+
+
diff --git a/dist/newalpha b/dist/newalpha
index 5b1a2669..79966004 100755
--- a/dist/newalpha
+++ b/dist/newalpha
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Header: /usr/people/sam/tiff/dist/RCS/newalpha,v 1.1 1994/12/17 18:27:58 sam Exp $
+# $Header: /d1/sam/tiff/dist/RCS/newalpha,v 1.1 1994/12/17 18:27:58 sam Exp $
if test -r tiff.alpha; then
ALPHA=`cat tiff.alpha`; rm -f tiff.alpha
echo "$ALPHA" | awk '{ printf "define ALPHA %03d\n", $3+1}' > tiff.alpha
diff --git a/dist/newversion b/dist/newversion
index 22a5d294..d472057b 100644
--- a/dist/newversion
+++ b/dist/newversion
@@ -1,5 +1,5 @@
#! /bin/sh
-# $Header: /usr/people/sam/tiff/dist/RCS/newversion,v 1.2 1996/01/10 19:37:40 sam Exp $
+# $Header: /d1/sam/tiff/dist/RCS/newversion,v 1.2 1996/01/10 19:37:40 sam Exp $
#
# TIFF Software
#
diff --git a/dist/tiff.alpha b/dist/tiff.alpha
index 21bf733e..316b4d7b 100644
--- a/dist/tiff.alpha
+++ b/dist/tiff.alpha
@@ -1 +1 @@
-define ALPHA 036
+define ALPHA 037
diff --git a/dist/tiff.spec b/dist/tiff.spec
index 9ff118f1..762ab397 100644
--- a/dist/tiff.spec
+++ b/dist/tiff.spec
@@ -1,9 +1,9 @@
-# $Header: /usr/people/sam/tiff/dist/RCS/tiff.spec,v 1.6 1996/06/10 21:43:11 sam Exp $
+# $Header: /d1/sam/tiff/dist/RCS/tiff.spec,v 1.7 1997/08/29 21:49:10 sam Exp $
#
# TIFF Software
#
-# Copyright (c) 1994-1996 Sam Leffler
-# Copyright (c) 1994-1996 Silicon Graphics, Inc.
+# Copyright (c) 1994-1997 Sam Leffler
+# Copyright (c) 1994-1997 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
diff --git a/html/Makefile.in b/html/Makefile.in
index 8e6b677c..2a0f2787 100644
--- a/html/Makefile.in
+++ b/html/Makefile.in
@@ -1,11 +1,11 @@
-# $Header: /usr/people/sam/tiff/html/RCS/Makefile.in,v 1.14 1997/02/21 01:20:12 sam Exp $
+# $Header: /d1/sam/tiff/html/RCS/Makefile.in,v 1.15 1997/08/29 21:47:05 sam Exp $
#
# @WARNING@
#
# Tag Image File Format Library Manual Pages
#
-# Copyright (c) 1991-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1991-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/html/build.html b/html/build.html
index 193eafa8..66480c7c 100644
--- a/html/build.html
+++ b/html/build.html
@@ -10,14 +10,6 @@ Building the TIFF Software Distribution
Building the Software Distribution
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
<UL>
<LI><A HREF=#UNIX>Building on a UNIX system</A>.
<LI><A HREf=#MacMPW>Building on a Macintosh system with MPW</A>.
@@ -491,14 +483,15 @@ default this is <B>/usr/local/bin</B>.</TD>
<TR>
<TD VALIGN=top><TT>DIR_GZLIB</TT></TD>
-<TD>The options to pass to the C compiler to reference the zlib library
-when ZIP support is enabled; e.g. ``<TT>-L../src/zlib -lgz</TT>''.</TD>
+<TD>The pathname of the directory containing the zlib library
+(when ZIP or PixarLog compression support is enabled);
+e.g. ``<TT>../src/zlib</TT>''.</TD>
</TR>
<TR>
<TD VALIGN=top><TT>DIR_JPEGLIB</TT></TD>
-<TD>The options to pass to the C compiler to reference the JPEG library
-when JPEG support is enabled; e.g. ``<TT>-L/usr/local/lib -ljpeg</TT>''.</TD>
+<TD>The pathname of the directory containing the JPEG library
+(when JPEG support is enabled); e.g. ``<TT>/usr/local/lib</TT>''.</TD>
</TR>
<TR>
@@ -1099,6 +1092,7 @@ libtiff/t4.h CCITT Group 3/4 code tables+definitions
libtiff/tif_dir.h private defs for TIFF directory handling
libtiff/tif_fax3.h CCITT Group 3/4-related definitions
libtiff/tif_predict.h private defs for Predictor tag support
+libtiff/uvcode.h LogL/LogLuv codec-specific definitions
libtiff/version.h version string (generated by Makefile)
libtiff/tif_acorn.c Acorn-related OS support
@@ -1119,6 +1113,7 @@ libtiff/tif_fax3sm.c G3/G4 state tables (generated by mkg3states)
libtiff/tif_flush.c i/o and directory state flushing
libtiff/tif_getimage.c TIFFRGBAImage support
libtiff/tif_jpeg.c JPEG codec (interface to the IJG distribution)
+libtiff/tif_luv.c SGI LogL/LogLuv codec
libtiff/tif_lzw.c LZW codec
libtiff/tif_msdos.c MSDOS-related OS support
libtiff/tif_next.c NeXT 2-bit scheme codec (decoding only)
@@ -1151,7 +1146,7 @@ libtiff/mkversion.c program to generate libtiff/version.h.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 22:12:54 $
+Last updated: $Date: 1997/08/29 01:00:05 $
</ADDRESS>
</BODY>
diff --git a/html/contrib.html b/html/contrib.html
index 50fafd7c..9f4d5ac4 100644
--- a/html/contrib.html
+++ b/html/contrib.html
@@ -10,22 +10,14 @@ Contributed TIFF Software
Contributed TIFF Software
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
<P>
The <B>contrib</B> directory has contributed software that
uses the TIFF library or which is associated with the library
(typically glue and guidance for ports to non-UNIX platforms).
+<BR CLEAR=left>
+
<P>
<TABLE BORDER CELLPADDING=3>
@@ -44,7 +36,7 @@ scripts and files from Karsten Spang for building
<B>contrib/dbs</B>
</TD>
<TD>
-a simple X-based TIFF viewer from Dan & Chris Sears
+various tools from Dan & Chris Sears, including a simple X-based viewer
</TD>
</TR>
@@ -110,6 +102,26 @@ scripts and files from Niles Ritter for adding private
</TD>
</TR>
+<TR>
+<TD VALIGN=top>
+<B>contrib/mfs</B>
+</TD>
+<TD>
+code from Mike Johnson to read+write images in memory
+without modifying the library
+</TD>
+</TR>
+
+<TR>
+<TD VALIGN=top>
+<B>contrib/pds</B>
+</TD>
+<TD>
+various routines from Conrad Poelman; a TIFF image iterator and
+ code to support ``private sub-directories''
+</TD>
+</TR>
+
</TABLE>
<P>
@@ -124,7 +136,7 @@ and/or bug reports directly to the authors.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1997/09/02 00:11:22 $
</ADDRESS>
</BODY>
diff --git a/html/document.html b/html/document.html
index 2e200e24..e6a04e3a 100644
--- a/html/document.html
+++ b/html/document.html
@@ -10,20 +10,6 @@ TIFF Documentation
TIFF Documentation
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
-<PRE>
-
-</PRE>
-
<P>
A copy of the 6.0 specification is available by public ftp at
@@ -32,20 +18,24 @@ A copy of the 6.0 specification is available by public ftp at
</UL>
This is a PostScript version of the final 6.0 specification compressed
-the standard UNIX compress(1) program.
+with the standard UNIX compress(1) program.
An uncompressed PostScript file is also available as TIFF6.ps in
the same directory.
-Adobe (nee Aldus) also provides the 6.0 spec online in
+
+<BR CLEAR=left>
+
+<P>
+Adobe (nee Aldus) provides the 6.0 spec online in
Acrobat format (PDF); this can be found at
<UL>
-<A HREF="ftp://ftp.adobe.com/pub/adobe/devrelations/devtechnotes/pdffiles/tiff6.pdf">ftp://ftp.adobe.com/pub/adobe/devrelations/devtechnotes/pdffiles/tiff6.pdf</A>
+<A HREF="http://www.adobe.com/supportservice/devrelations/PDFS/TN/TIFF6.pdf">http://www.adobe.com/supportservice/devrelations/PDFS/TN/TIFF6.pdf</A>
</UL>
TIFF Technical Notes can be retrieved from
<UL>
-<A HREF=ftp://ftp.sgi.com/graphics/tiff>ftp://ftp.sgi.com/graphics/tiff</A>
+<A HREF="http://www.adobe.com/supportservice/devrelations/technotes.html">http://www.adobe.com/supportservice/devrelations/technotes.html</A>
</UL>
<P>
@@ -53,7 +43,7 @@ TIFF Technical Notes can be retrieved from
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/11/10 16:39:43 $
+Last updated: $Date: 1997/08/29 22:44:59 $
</ADDRESS>
</BODY>
diff --git a/html/images.html b/html/images.html
index cfc705d0..0f5fa3a1 100644
--- a/html/images.html
+++ b/html/images.html
@@ -10,22 +10,16 @@ TIFF Test Images
TIFF Test Images
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
<P>
Test images are available for most formats supported by the library.
Most of the images included in the test kit are also part of this
documentation (albeit in TIFF rather than GIF or JFIF).
The images are kept in a separate archive that should be located in
the same directory as this software.
+
+<BR CLEAR=left>
+
+<P>
The latest archive of test images is located at
<A HREF="ftp://ftp.sgi.com/graphics/tiff/v3.0pics.tar.Z">ftp://ftp.sgi.com/graphics/tiff/v3.0pics.tar.Z</A>.
@@ -41,7 +35,7 @@ of images with different storage characteristics.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1997/08/27 23:34:36 $
</ADDRESS>
</BODY>
diff --git a/html/index.html b/html/index.html
index 6934f31d..3f96fcaf 100644
--- a/html/index.html
+++ b/html/index.html
@@ -12,10 +12,10 @@ TIFF Software
</H1>
<B>Latest Release</B>: <A HREF="v3.4beta033.html">v3.4</A><BR>
-<B>Latest Software</B>: <A HREF="v3.4beta036.html">v3.4beta036</A><BR>
+<B>Latest Software</B>: <A HREF="v3.4beta037.html">v3.4beta037</A><BR>
<B>Master FTP Site</B>: <A HREF="ftp://ftp.sgi.com/graphics/tiff">ftp.sgi.com (192.48.153.1), directory graphics/tiff</A><BR>
-<B>Home Page</B>: <A HREF="http://www-mipl.jpl.nasa.gov/~ndr/tiff/">
- http://www-mipl.jpl.nasa.gov/~ndr/tiff/</A> <BR>
+<B>Home Page</B>: <A HREF="http://www.earthlink.net/~ritter/tiff/">
+ http://www.earthlink.net/~ritter/tiff/</A> <BR>
<B>FAQ Page</B>: <I>forthcoming</I><BR>
@@ -24,21 +24,12 @@ TIFF Software
</PRE>
-<H5>
-<IMG SRC=images/note.gif WIDTH=32 HEIGHT=32 ALIGN=left HSPACE=6>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
<P>
This software provides support for the <I>Tag Image File Format</I> (TIFF),
a widely used format for storing image data. The latest version of
the TIFF specification is <A HREF=document.html>available on-line</A>
in several different formats,
-as are a number of <A HREF=ftp://ftp.sgi.com/graphics/tiff>TIFF Technical Notes (TTN's)</A>.
+as are a number of <A HREF= http://www.adobe.com/supportservice/devrelations/technotes.html>TIFF Technical Notes (TTN's)</A>.
<P>
Included in this software distribution is a library, libtiff, for
@@ -75,13 +66,12 @@ The following sections are included in this documentation:
A PostScript version of this documentation is available on-line at
the master FTP site listed above.
-
<P>
<HR>
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1997/02/21 01:20:12 $
+Last updated: $Date: 1997/09/02 00:11:22 $
</ADDRESS>
</BODY>
diff --git a/html/internals.html b/html/internals.html
index 756b5ab0..70ec7f20 100644
--- a/html/internals.html
+++ b/html/internals.html
@@ -11,20 +11,6 @@ Modifying The TIFF Library
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
-<PRE>
-
-</PRE>
-
<P>
This chapter provides information about the internal structure of
the library, how to control the configuration when building it, and
@@ -67,11 +53,17 @@ Configuration defines are split into three areas:
<P>
If the define <TT>COMPRESSION_SUPPORT</TT> is <STRONG>not defined</STRONG>
then a default set of compression schemes is automatically
-configured: CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4,
-and 32771), the Macintosh PackBits algorithm (compression 32773),
-a Lempel-Ziv & Welch (LZW) algorithm (compression 5), a 4-bit
-run-length encoding scheme from ThunderScan (compression 32809),
-and a 2-bit encoding scheme used by NeXT (compression 32766).
+configured:
+<UL>
+<LI>CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771),
+<LI>the Macintosh PackBits algorithm (compression 32773),
+<LI>a Lempel-Ziv & Welch (LZW) algorithm (compression 5),
+<LI>a 4-bit run-length encoding scheme from ThunderScan (compression 32809),
+<LI>a 2-bit encoding scheme used by NeXT (compression 32766), and
+<LI>two experimental schemes intended for images with high dynamic range
+(compression 34676 and 34677).
+</UL>
+
To override this behaviour define <TT>COMPRESSION_SUPPORT</TT>
and then one or more additional defines to enable configuration of
the appropriate codecs (see the table below); e.g.
@@ -185,6 +177,11 @@ run-length encoding scheme from ThunderScan (compression 32809)</TD>
</TR>
<TR>
+<TD VALIGN=top><TT>SGILOG_SUPPORT</TT></TD>
+<TD>SGI's compression scheme for high-resolution color images (compression 34676 and 34677)</TD>
+</TR>
+
+<TR>
<TD VALIGN=top><TT>COLORIMETRY_SUPPORT</TT></TD>
<TD>support for the TIFF 6.0 colorimetry tags</TD>
</TR>
@@ -453,7 +450,8 @@ their type is presumed.
<P><HR WIDTH=65% ALIGN=right><H3>General Comments</H3></A>
-The library is designed to hide as much of the details of TIFF as
+The library is designed to hide as much of the details of TIFF from
+applications as
possible. In particular, TIFF directories are read in their entirety
into an internal format. Only the tags known by the library are
available to a user and certain tag data may be maintained that a user
@@ -471,7 +469,8 @@ the following guidelines to add support to the ``core library''.
<OL>
<LI>Define the tag in <B>tiff.h</B>.
<LI>Add a field to the directory structure in <B>tif_dir.h</B>
- and define a <TT>FIELD_*</TT> bit.
+ and define a <TT>FIELD_*</TT> bit (also update the definition of
+ <TT>FIELD_CODEC</TT> to reflect your addition).
<LI>Add an entry in the <TT>TIFFFieldInfo</TT> array defined at the top of
<B>tif_dirinfo.c</B>.
Note that you must keep this array sorted by tag
@@ -649,7 +648,7 @@ the portability of your TIFF files.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/12/13 05:31:06 $
+Last updated: $Date: 1997/08/27 23:34:39 $
</ADDRESS>
</BODY>
diff --git a/html/libtiff.html b/html/libtiff.html
index 75607d77..c0e9a2b1 100644
--- a/html/libtiff.html
+++ b/html/libtiff.html
@@ -10,21 +10,6 @@ Using The TIFF Library
Using The TIFF Library
</H1>
-
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
-<PRE>
-
-</PRE>
-
<P>
<TT>libtiff</TT> is a set of C functions (a library) that support
the manipulation of TIFF image files.
@@ -304,7 +289,7 @@ for reading, or by setting the tag when writing.
<P>
Compression schemes are implemented by software modules termed <I>codecs</I>
-that implements decoder and encoder routines that hook into the
+that implement decoder and encoder routines that hook into the
core library i/o support.
Codecs other than those bundled with the library can be registered
for use with the <TT>TIFFRegisterCODEC</TT> routine.
@@ -738,7 +723,7 @@ main()
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/08/29 01:08:05 $
+Last updated: $Date: 1997/08/27 23:34:42 $
</ADDRESS>
</BODY>
diff --git a/html/misc.html b/html/misc.html
index b550b9d6..6ec6efd8 100644
--- a/html/misc.html
+++ b/html/misc.html
@@ -10,20 +10,15 @@ Acknowledgments and Other Issues
Acknowledgments and Other Issues
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
+<P>
+Silicon Graphics has seen fit to allow me to give this work away. It
+is free. There is no support or guarantee of any sort as to its
+operations, correctness, or whatever. If you do anything useful with
+all or parts of it you need to honor the copyright notices. I would
+also be interested in knowing about it and, hopefully, be acknowledged.
<BR CLEAR=left>
-<PRE>
-
-</PRE>
-
<H2>Acknowledgements</H2>
@@ -64,15 +59,9 @@ guarantees with regard to the LZW support in this library.
<H2>Use and Copyright</H2>
-Silicon Graphics has seen fit to allow me to give this work away. It
-is free. There is no support or guarantee of any sort as to its
-operations, correctness, or whatever. If you do anything useful with
-all or parts of it you need to honor the copyright notices. I would
-also be interested in knowing about it and, hopefully, be acknowledged.
-
<P><H5><PRE>
-Copyright (c) 1988-1996 Sam Leffler
-Copyright (c) 1991-1996 Silicon Graphics, Inc.
+Copyright (c) 1988-1997 Sam Leffler
+Copyright (c) 1991-1997 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
@@ -99,7 +88,7 @@ OF THIS SOFTWARE.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:31:11 $
+Last updated: $Date: 1997/08/29 21:47:10 $
</ADDRESS>
</BODY>
diff --git a/html/support.html b/html/support.html
index 8080f07e..eae1bd76 100644
--- a/html/support.html
+++ b/html/support.html
@@ -11,16 +11,6 @@ TIFF 6.0 Specification Coverage
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
<P>
The library is capable of dealing with images that are written to
follow the 5.0 or 6.0 TIFF spec. There is also considerable support
@@ -179,7 +169,9 @@ that are, in some cases, of dubious value.
Compression = 32766 NeXT 2-bit encoding
Compression = 32809 ThunderScan 4-bit encoding
Compression = 32909 Pixar companded 11-bit ZIP encoding
- Compression = 34999 PKZIP-style Deflate encoding (experimental)
+ Compression = 32946 PKZIP-style Deflate encoding (experimental)
+ Compression = 34676 SGI 32-bit Log Luminance encoding (experimental)
+ Compression = 34677 SGI 24-bit Log Luminance encoding (experimental)
</PRE>
Note that there is no support for the JPEG-related tags defined
@@ -187,6 +179,20 @@ in the 6.0 specification; the JPEG support is based on the post-6.0
proposal given in TIFF Technical Note #2.
<P>
+<TABLE>
+<TR>
+<TD VALIGN=top><IMG SRC="images/info.gif"></TD>
+<TD>
+<EM>
+For more information on the experimental Log Luminance encoding
+consult the materials available at
+<A HREF=http://www.sgi.com/Technology/pixformat>http://www.sgi.com/Technology/pixformat</A>.
+</EM>
+</TD>
+</TR>
+</TABLE>
+
+<P>
The following table shows the tags that are recognized
and how they are used by the library. If no use is indicated,
then the library
@@ -623,6 +629,12 @@ reads and writes the tag, but does not use it internally.
<TD ALIGN=center>R/W</TD>
<TD>tile/strip calculations</TD>
</TR>
+<TR>
+<TD><TT>StoNits</TT></TD>
+<TD ALIGN=center>37439</TD>
+<TD ALIGN=center>R/W</TD>
+<TD>&nbsp;</TD>
+</TR>
</TABLE>
<P>
@@ -665,7 +677,7 @@ part of the TIFF 6.0 specification).
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1997/09/02 00:11:22 $
</ADDRESS>
</BODY>
diff --git a/html/tools.html b/html/tools.html
index 945db596..52593c46 100644
--- a/html/tools.html
+++ b/html/tools.html
@@ -10,16 +10,6 @@ TIFF Tools Overview
TIFF Tools Overview
</H1>
-<H5>
-This documentation is best viewed using a graphical browser that supports
-the latest HTML directives for formatting documents. In particular,
-this document was authored
-for viewing with version 1.1 or newer of the
-<A HREF="http://home.mcom.com/comprod/products/navigator/index.html">Netscape Navigator</A>.
-</H5>
-
-<BR CLEAR=left>
-
<P>
This software distribution comes with a small collection of programs
for converting non-TIFF format images to TIFF and for manipulating
@@ -181,7 +171,7 @@ Check out the manual pages for details about the above programs.
<ADDRESS>
<A HREF="sam.html">Sam Leffler</A> / <A HREF="mailto:sam@engr.sgi.com">sam@engr.sgi.com</A>.
-Last updated: $Date: 1996/04/29 19:18:06 $
+Last updated: $Date: 1997/08/27 23:34:47 $
</ADDRESS>
</BODY>
diff --git a/libtiff/Makefile.in b/libtiff/Makefile.in
index 111e6348..89fb8583 100644
--- a/libtiff/Makefile.in
+++ b/libtiff/Makefile.in
@@ -1,9 +1,9 @@
-# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.40 1996/11/11 16:15:16 sam Exp $
+# $Header: /d1/sam/tiff/libtiff/RCS/Makefile.in,v 1.43 1997/08/29 22:47:50 sam Exp $
#
# Tag Image File Format Library
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
@@ -81,6 +81,7 @@ SRCS = \
tif_getimage.c \
tif_jpeg.c \
tif_flush.c \
+ tif_luv.c \
tif_lzw.c \
tif_next.c \
tif_open.c \
@@ -115,6 +116,7 @@ OBJS = \
tif_getimage.o \
tif_jpeg.o \
tif_flush.o \
+ tif_luv.o \
tif_lzw.o \
tif_next.o \
tif_open.o \
@@ -169,7 +171,7 @@ IRIX52dso: ${OBJS}
${LD} -elf -o libtiff.@DSOSUF@ -shared -no_unresolved -all ${OBJS} \
@LIBJPEG@ @LIBGZ@ -lc -lm
touch $@
-# Solaris 2.4
+# Solaris 2.x
SOLARISdso: ${OBJS}
${LD} -L@DIR_LIB@ -G -h libtiff.@DSOSUF@ -o libtiff.@DSOSUF@ ${OBJS}
touch $@
@@ -257,6 +259,8 @@ tif_jpeg.o: ${SRCDIR}/tif_jpeg.c @DEPEND_JPEGLIB@
${CC} -c ${CFLAGS} ${SRCDIR}/tif_jpeg.c
tif_flush.o: ${SRCDIR}/tif_flush.c
${CC} -c ${CFLAGS} ${SRCDIR}/tif_flush.c
+tif_luv.o: ${SRCDIR}/tif_luv.c
+ ${CC} -c ${CFLAGS} ${SRCDIR}/tif_luv.c
tif_lzw.o: ${SRCDIR}/tif_lzw.c ${SRCDIR}/tif_predict.h
${CC} -c ${CFLAGS} ${SRCDIR}/tif_lzw.c
tif_next.o: ${SRCDIR}/tif_next.c
diff --git a/libtiff/Makefile.lcc b/libtiff/Makefile.lcc
index 46f8cbce..d3166bb5 100644
--- a/libtiff/Makefile.lcc
+++ b/libtiff/Makefile.lcc
@@ -1,9 +1,9 @@
-# $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.lcc,v 1.3 1996/01/10 19:32:51 sam Exp $
+# $Header: /d1/sam/tiff/libtiff/RCS/Makefile.lcc,v 1.4 1997/08/29 21:46:32 sam Exp $
#
# Tag Image File Format Library
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/libtiff/mkg3states.c b/libtiff/mkg3states.c
index dc477afb..4e39419d 100644
--- a/libtiff/mkg3states.c
+++ b/libtiff/mkg3states.c
@@ -1,8 +1,8 @@
-/* "$Header: /usr/people/sam/tiff/libtiff/RCS/mkg3states.c,v 1.34 1996/01/10 19:32:52 sam Exp $ */
+/* "$Header: /d1/sam/tiff/libtiff/RCS/mkg3states.c,v 1.35 1997/08/29 21:45:42 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/mkspans.c b/libtiff/mkspans.c
index 6a4fe312..8169115d 100644
--- a/libtiff/mkspans.c
+++ b/libtiff/mkspans.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/mkspans.c,v 1.10 1996/01/10 19:32:53 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/mkspans.c,v 1.11 1997/08/29 21:45:43 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/mkversion.c b/libtiff/mkversion.c
index 674ba87a..13314d14 100755
--- a/libtiff/mkversion.c
+++ b/libtiff/mkversion.c
@@ -1,8 +1,8 @@
-/* "$Header: /usr/people/sam/tiff/libtiff/RCS/mkversion.c,v 1.4 1996/01/10 19:34:25 sam Exp $ */
+/* "$Header: /d1/sam/tiff/libtiff/RCS/mkversion.c,v 1.5 1997/08/29 21:45:43 sam Exp $ */
/*
- * Copyright (c) 1995-1996 Sam Leffler
- * Copyright (c) 1995-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1995-1997 Sam Leffler
+ * Copyright (c) 1995-1997 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
diff --git a/libtiff/t4.h b/libtiff/t4.h
index 4873d35d..e7504091 100644
--- a/libtiff/t4.h
+++ b/libtiff/t4.h
@@ -1,8 +1,8 @@
-/* $Id: t4.h,v 1.16 1996/06/24 03:00:54 sam Exp $ */
+/* $Id: t4.h,v 1.17 1997/08/29 21:45:36 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_acorn.c b/libtiff/tif_acorn.c
index 40ce58dd..f4059be0 100755
--- a/libtiff/tif_acorn.c
+++ b/libtiff/tif_acorn.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_acorn.c,v 1.1 1995/09/06 00:24:10 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_acorn.c,v 1.2 1997/08/29 21:45:44 sam Exp $ */
/*
- * Copyright (c) 1988-1995 Sam Leffler
- * Copyright (c) 1991-1995 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_apple.c b/libtiff/tif_apple.c
index 81f87724..19d48617 100644
--- a/libtiff/tif_apple.c
+++ b/libtiff/tif_apple.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_apple.c,v 1.22 1996/02/06 23:50:58 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_apple.c,v 1.23 1997/08/29 21:45:45 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_atari.c b/libtiff/tif_atari.c
index 04966856..61e211c4 100644
--- a/libtiff/tif_atari.c
+++ b/libtiff/tif_atari.c
@@ -1,8 +1,8 @@
-/* "$Header: /usr/people/sam/tiff/libtiff/RCS/tif_atari.c,v 1.5 1996/01/10 19:32:54 sam Exp $" */
+/* "$Header: /d1/sam/tiff/libtiff/RCS/tif_atari.c,v 1.6 1997/08/29 21:45:45 sam Exp $" */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c
index 608115a6..c17792d5 100644
--- a/libtiff/tif_aux.c
+++ b/libtiff/tif_aux.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_aux.c,v 1.33 1996/08/01 19:10:34 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_aux.c,v 1.34 1997/08/29 21:45:45 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_close.c b/libtiff/tif_close.c
index d45e5c65..203d074e 100644
--- a/libtiff/tif_close.c
+++ b/libtiff/tif_close.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_close.c,v 1.31 1997/01/27 19:09:09 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_close.c,v 1.32 1997/08/29 21:45:46 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_codec.c b/libtiff/tif_codec.c
index a821de14..afc7f864 100644
--- a/libtiff/tif_codec.c
+++ b/libtiff/tif_codec.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_codec.c,v 1.9 1996/04/05 17:36:53 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_codec.c,v 1.12 1997/08/29 21:45:46 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -66,6 +66,9 @@ static int NotConfigured(TIFF*, int);
#ifndef PIXARLOG_SUPPORT
#define TIFFInitPixarLog NotConfigured
#endif
+#ifndef LOGLUV_SUPPORT
+#define TIFFInitSGILog NotConfigured
+#endif
/*
* Compression schemes statically built into the library.
@@ -89,7 +92,9 @@ TIFFCodec _TIFFBuiltinCODECS[] = {
{ "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG },
{ "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP },
{ "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
- { NULL },
+ { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
+ { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
+ { NULL }
};
static int
diff --git a/libtiff/tif_compress.c b/libtiff/tif_compress.c
index 3878d7ab..3af749c7 100644
--- a/libtiff/tif_compress.c
+++ b/libtiff/tif_compress.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_compress.c,v 1.52 1997/01/27 19:09:09 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_compress.c,v 1.53 1997/08/29 21:45:47 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index d219cbdf..63dea966 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.c,v 1.158 1996/12/13 05:25:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dir.c,v 1.162 1997/08/29 21:45:47 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -84,6 +84,34 @@ setExtraSamples(TIFFDirectory* td, va_list ap, int* v)
return (1);
}
+#ifdef CMYK_SUPPORT
+static int
+checkInkNamesString(TIFF* tif, int slen, const char* s)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ int i = td->td_samplesperpixel;
+
+ if (slen > 0) {
+ const char* ep = s+slen;
+ const char* cp = s;
+ for (; i > 0; i--) {
+ for (; *cp != '\0'; cp++)
+ if (cp >= ep)
+ goto bad;
+ cp++; /* skip \0 */
+ }
+ return (cp-s);
+ }
+bad:
+ TIFFError("TIFFSetField",
+ "%s: Invalid InkNames value; expecting %d names, found %d",
+ tif->tif_name,
+ td->td_samplesperpixel,
+ td->td_samplesperpixel-i);
+ return (0);
+}
+#endif
+
static int
_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
@@ -91,6 +119,8 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
int status = 1;
uint32 v32;
int i, v;
+ double d;
+ char* s;
switch (tag) {
case TIFFTAG_SUBFILETYPE:
@@ -314,6 +344,12 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
case TIFFTAG_IMAGEDEPTH:
td->td_imagedepth = va_arg(ap, uint32);
break;
+ case TIFFTAG_STONITS:
+ d = va_arg(ap, dblparam_t);
+ if (d <= 0.)
+ goto badvaluedbl;
+ td->td_stonits = d;
+ break;
#if SUBIFD_SUPPORT
case TIFFTAG_SUBIFD:
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
@@ -367,7 +403,12 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
break;
case TIFFTAG_INKNAMES:
i = va_arg(ap, int);
- _TIFFsetNString(&td->td_inknames, va_arg(ap, char*), i);
+ s = va_arg(ap, char*);
+ i = checkInkNamesString(tif, i, s);
+ if (status = (i > 0)) {
+ _TIFFsetNString(&td->td_inknames, s, i);
+ td->td_inknameslen = i;
+ }
break;
case TIFFTAG_NUMBEROFINKS:
td->td_ninks = (uint16) va_arg(ap, int);
@@ -418,6 +459,11 @@ badvalue32:
_TIFFFieldWithTag(tif, tag)->field_name);
va_end(ap);
return (0);
+badvaluedbl:
+ TIFFError(tif->tif_name, "%f: Bad value for \"%s\"", d,
+ _TIFFFieldWithTag(tif, tag)->field_name);
+ va_end(ap);
+ return (0);
}
/*
@@ -643,6 +689,9 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
case TIFFTAG_IMAGEDEPTH:
*va_arg(ap, uint32*) = td->td_imagedepth;
break;
+ case TIFFTAG_STONITS:
+ *va_arg(ap, double*) = td->td_stonits;
+ break;
#if SUBIFD_SUPPORT
case TIFFTAG_SUBIFD:
*va_arg(ap, uint16*) = td->td_nsubifd;
@@ -903,6 +952,20 @@ TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off)
}
/*
+ * Count the number of directories in a file.
+ */
+tdir_t
+TIFFNumberOfDirectories(TIFF* tif)
+{
+ uint32 nextdir = tif->tif_header.tiff_diroff;
+ tdir_t n = 0;
+
+ while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
+ n++;
+ return (n);
+}
+
+/*
* Set the n-th directory as the current directory.
* NB: Directories are numbered starting at 0.
*/
diff --git a/libtiff/tif_dir.h b/libtiff/tif_dir.h
index f9eac232..2a576249 100644
--- a/libtiff/tif_dir.h
+++ b/libtiff/tif_dir.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.h,v 1.6 1996/12/13 05:25:17 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dir.h,v 1.10 1997/08/29 21:45:37 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -61,6 +61,7 @@ typedef struct {
uint16 td_halftonehints[2];
uint16 td_extrasamples;
uint16* td_sampleinfo;
+ double td_stonits;
char* td_documentname;
char* td_artist;
char* td_datetime;
@@ -93,6 +94,7 @@ typedef struct {
uint16 td_inkset;
uint16 td_ninks;
uint16 td_dotrange[2];
+ int td_inknameslen;
char* td_inknames;
char* td_targetprinter;
#endif
@@ -172,8 +174,9 @@ typedef struct {
#define FIELD_SUBIFD 49
#define FIELD_NUMBEROFINKS 50
#define FIELD_ICCPROFILE 51
+#define FIELD_STONITS 52
/* end of support for well-known tags; codec-private tags follow */
-#define FIELD_CODEC 51 /* base of codec-private tags */
+#define FIELD_CODEC 53 /* base of codec-private tags */
/*
* Pseudo-tags don't normally need field bits since they
* are not written to an output file (by definition).
diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c
index c4584647..9b716c2a 100644
--- a/libtiff/tif_dirinfo.c
+++ b/libtiff/tif_dirinfo.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirinfo.c,v 1.40 1996/12/13 05:25:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dirinfo.c,v 1.43 1997/08/29 21:45:48 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -220,6 +220,8 @@ static const TIFFFieldInfo tiffFieldInfo[] = {
{ TIFFTAG_ICCPROFILE, -1,-3, TIFF_UNDEFINED, FIELD_ICCPROFILE,
FALSE, TRUE, "ICC Profile" },
#endif
+ { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_STONITS,
+ FALSE, FALSE, "StoNits" },
};
#define N(a) (sizeof (a) / sizeof (a[0]))
@@ -238,9 +240,11 @@ tagCompare(const void* a, const void* b)
{
const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a;
const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b;
- /* NB: width of c must match ttag_t */
- int32 c = ta->field_tag - tb->field_tag;
- return (c != 0 ? c : tb->field_type - ta->field_type);
+ /* NB: be careful of return values for 16-bit platforms */
+ if (ta->field_tag != tb->field_tag)
+ return (ta->field_tag < tb->field_tag ? -1 : 1);
+ else
+ return (tb->field_type < ta->field_type ? -1 : 1);
}
void
@@ -278,9 +282,9 @@ _TIFFPrintFieldInfo(TIFF* tif, FILE* fd)
fprintf(fd, "%s: \n", tif->tif_name);
for (i = 0; i < tif->tif_nfields; i++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
- fprintf(fd, "field[%2d] %5u, %2d, %2d, %d, %2d, %5s, %5s, %s\n"
+ fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n"
, i
- , fip->field_tag
+ , (unsigned long) fip->field_tag
, fip->field_readcount, fip->field_writecount
, fip->field_type
, fip->field_bit
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 8d9cac55..6cbfff48 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirread.c,v 1.76 1997/02/10 20:18:43 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dirread.c,v 1.77 1997/08/29 21:45:49 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index d177d6e0..b54972ca 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirwrite.c,v 1.58 1997/01/15 19:01:24 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dirwrite.c,v 1.60 1997/08/29 21:45:49 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -61,6 +61,9 @@ static int TIFFWriteAnyArray(TIFF*,
#ifdef COLORIMETRY_SUPPORT
static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*);
#endif
+#ifdef CMYK_SUPPORT
+static int TIFFWriteInkNames(TIFF*, TIFFDirEntry*);
+#endif
static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*);
static int TIFFLinkDirectory(TIFF*);
@@ -265,6 +268,12 @@ TIFFWriteDirectory(TIFF* tif)
if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad;
break;
+#ifdef CMYK_SUPPORT
+ case FIELD_INKNAMES:
+ if (!TIFFWriteInkNames(tif, dir))
+ goto bad;
+ break;
+#endif
#ifdef COLORIMETRY_SUPPORT
case FIELD_TRANSFERFUNCTION:
if (!TIFFWriteTransferFunction(tif, dir))
@@ -855,6 +864,19 @@ TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir)
}
#endif
+#ifdef CMYK_SUPPORT
+static int
+TIFFWriteInkNames(TIFF* tif, TIFFDirEntry* dir)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+
+ dir->tdir_tag = TIFFTAG_INKNAMES;
+ dir->tdir_type = (short) TIFF_ASCII;
+ dir->tdir_count = td->td_inknameslen;
+ return (TIFFWriteByteArray(tif, dir, td->td_inknames));
+}
+#endif
+
/*
* Write a contiguous directory item.
*/
diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c
index 08214652..2a9587d0 100644
--- a/libtiff/tif_dumpmode.c
+++ b/libtiff/tif_dumpmode.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dumpmode.c,v 1.40 1996/01/10 19:33:00 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_dumpmode.c,v 1.41 1997/08/29 21:45:50 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_error.c b/libtiff/tif_error.c
index 35eb5f76..fb9686d8 100644
--- a/libtiff/tif_error.c
+++ b/libtiff/tif_error.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_error.c,v 1.21 1996/01/10 19:33:01 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_error.c,v 1.22 1997/08/29 21:45:50 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c
index af5f2ee8..316522e8 100644
--- a/libtiff/tif_fax3.c
+++ b/libtiff/tif_fax3.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.c,v 1.136 1997/02/20 20:14:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_fax3.c,v 1.137 1997/08/29 21:45:51 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_fax3.h b/libtiff/tif_fax3.h
index 88f2cf2f..a6fdf13e 100644
--- a/libtiff/tif_fax3.h
+++ b/libtiff/tif_fax3.h
@@ -1,8 +1,8 @@
-/* $Id: tif_fax3.h,v 1.33 1996/08/22 18:17:39 sam Exp $ */
+/* $Id: tif_fax3.h,v 1.34 1997/08/29 21:45:37 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_flush.c b/libtiff/tif_flush.c
index 5cf4c67f..614bec57 100644
--- a/libtiff/tif_flush.c
+++ b/libtiff/tif_flush.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_flush.c,v 1.22 1996/01/10 19:33:03 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_flush.c,v 1.23 1997/08/29 21:45:51 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
index aae7100d..c279a4e2 100644
--- a/libtiff/tif_getimage.c
+++ b/libtiff/tif_getimage.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_getimage.c,v 1.41 1997/01/27 23:27:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_getimage.c,v 1.43 1997/08/29 21:45:52 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -118,6 +118,26 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
}
break;
#endif
+ case PHOTOMETRIC_LOGL:
+ if (td->td_compression != COMPRESSION_SGILOG) {
+ sprintf(emsg, "Sorry, LogL data must have %s=%d",
+ "Compression", COMPRESSION_SGILOG);
+ return (0);
+ }
+ break;
+ case PHOTOMETRIC_LOGLUV:
+ if (td->td_compression != COMPRESSION_SGILOG &&
+ td->td_compression != COMPRESSION_SGILOG24) {
+ sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d",
+ "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24);
+ return (0);
+ }
+ if (td->td_planarconfig != PLANARCONFIG_CONTIG) {
+ sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
+ "Planarconfiguration", td->td_planarconfig);
+ return (0);
+ }
+ break;
default:
sprintf(emsg, "Sorry, can not handle image with %s=%d",
photoTag, photometric);
@@ -156,6 +176,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
uint16* sampleinfo;
uint16 extrasamples;
uint16 planarconfig;
+ uint16 compress;
int colorchannels;
img->tif = tif;
@@ -182,6 +203,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
break;
}
colorchannels = img->samplesperpixel - extrasamples;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress);
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig);
if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) {
switch (colorchannels) {
@@ -224,14 +246,11 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
return (0);
}
/* It would probably be nice to have a reality check here. */
- { uint16 compress;
- TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress);
- if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
+ if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) {
/* can rely on libjpeg to convert to RGB */
/* XXX should restore current state on exit */
TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB);
img->photometric = PHOTOMETRIC_RGB;
- }
}
break;
case PHOTOMETRIC_RGB:
@@ -256,6 +275,31 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
}
break;
}
+ case PHOTOMETRIC_LOGL:
+ if (compress != COMPRESSION_SGILOG) {
+ sprintf(emsg, "Sorry, LogL data must have %s=%d",
+ "Compression", COMPRESSION_SGILOG);
+ return (0);
+ }
+ TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
+ img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */
+ img->bitspersample = 8;
+ break;
+ case PHOTOMETRIC_LOGLUV:
+ if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) {
+ sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d",
+ "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24);
+ return (0);
+ }
+ if (planarconfig != PLANARCONFIG_CONTIG) {
+ sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
+ "Planarconfiguration", planarconfig);
+ return (0);
+ }
+ TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
+ img->photometric = PHOTOMETRIC_RGB; /* little white lie */
+ img->bitspersample = 8;
+ break;
default:
sprintf(emsg, "Sorry, can not handle image with %s=%d",
photoTag, img->photometric);
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index 081b3c91..751734a9 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_jpeg.c,v 1.26 1997/01/27 19:36:58 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_jpeg.c,v 1.27 1997/08/29 21:45:53 sam Exp $ */
/*
- * Copyright (c) 1994-1996 Sam Leffler
- * Copyright (c) 1994-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1994-1997 Sam Leffler
+ * Copyright (c) 1994-1997 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
diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
new file mode 100644
index 00000000..682e618e
--- /dev/null
+++ b/libtiff/tif_luv.c
@@ -0,0 +1,1428 @@
+/*
+ * Copyright (c) 1997 Greg Ward Larson
+ * Copyright (c) 1997 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, Greg Larson 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, Greg Larson 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, GREG LARSON 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.
+ */
+
+#include "tiffiop.h"
+#ifdef LOGLUV_SUPPORT
+
+/*
+ * TIFF Library.
+ * LogLuv compression support for high dynamic range images.
+ *
+ * Contributed by Greg Larson.
+ *
+ * LogLuv image support uses the TIFF library to store 16 or 10-bit
+ * log luminance values with 8 bits each of u and v or a 14-bit index.
+ *
+ * The codec can take as input and produce as output 32-bit IEEE float values
+ * as well as 16-bit integer values. A 16-bit luminance is interpreted
+ * as a sign bit followed by a 15-bit integer that is converted
+ * to and from a linear magnitude using the transformation:
+ *
+ * L = 2^( (Le+.5)/256 - 64 ) # real from 15-bit
+ *
+ * Le = floor( 256*(log2(L) + 64) ) # 15-bit from real
+ *
+ * The actual conversion to world luminance units in candelas per sq. meter
+ * requires an additional multiplier, which is stored in the TIFFTAG_STONITS.
+ * This value is usually set such that a reasonable exposure comes from
+ * clamping decoded luminances above 1 to 1 in the displayed image.
+ *
+ * The 16-bit values for u and v may be converted to real values by dividing
+ * each by 32768. (This allows for negative values, which aren't useful as
+ * far as we know, but are left in case of future improvements in human
+ * color vision.)
+ *
+ * Conversion from (u,v), which is actually the CIE (u',v') system for
+ * you color scientists, is accomplished by the following transformation:
+ *
+ * u = 4*x / (-2*x + 12*y + 3)
+ * v = 9*y / (-2*x + 12*y + 3)
+ *
+ * x = 9*u / (6*u - 16*v + 12)
+ * y = 4*v / (6*u - 16*v + 12)
+ *
+ * This process is greatly simplified by passing 32-bit IEEE floats
+ * for each of three CIE XYZ coordinates. The codec then takes care
+ * of conversion to and from LogLuv, though the application is still
+ * responsible for interpreting the TIFFTAG_STONITS calibration factor.
+ *
+ * The information is compressed into one of two basic encodings, depending on
+ * the setting of the compression tag, which is one of COMPRESSION_SGILOG
+ * or COMPRESSION_SGILOG24. For COMPRESSION_SGILOG, greyscale data is
+ * stored as:
+ *
+ * 1 15
+ * |-+---------------|
+ *
+ * COMPRESSION_SGILOG color data is stored as:
+ *
+ * 1 15 8 8
+ * |-+---------------|--------+--------|
+ * S Le ue ve
+ *
+ * For the 24-bit COMPRESSION_SGILOG24 color format, the data is stored as:
+ *
+ * 10 14
+ * |----------|--------------|
+ * Le' Ce
+ *
+ * There is no sign bit in the 24-bit case, and the (u,v) chromaticity is
+ * encoded as an index for optimal color resolution. The 10 log bits are
+ * defined by the following conversions:
+ *
+ * L = 2^((Le'+.5)/64 - 12) # real from 10-bit
+ *
+ * Le' = floor( 64*(log2(L) + 12) ) # 10-bit from real
+ *
+ * The 10 bits of the smaller format may be converted into the 15 bits of
+ * the larger format by multiplying by 4 and adding 13314. Obviously,
+ * a smaller range of magnitudes is covered (about 5 orders of magnitude
+ * instead of 38), and the lack of a sign bit means that negative luminances
+ * are not allowed. (Well, they aren't allowed in the real world, either,
+ * but they are useful for certain types of image processing.)
+ *
+ * The desired user format is controlled by the setting the internal
+ * pseudo tag TIFFTAG_SGILOGDATAFMT to one of:
+ * SGILOGDATAFMT_FLOAT = IEEE 32-bit float XYZ values
+ * SGILOGDATAFMT_16BIT = 16-bit integer encodings of logL, u and v
+ * Raw data i/o is also possible using:
+ * SGILOGDATAFMT_RAW = 32-bit unsigned integer with encoded pixel
+ * In addition, the following decoding is provided for ease of display:
+ * SGILOGDATAFMT_8BIT = 8-bit default RGB gamma-corrected values
+ *
+ * For grayscale images, we provide the following data formats:
+ * SGILOGDATAFMT_FLOAT = IEEE 32-bit float Y values
+ * SGILOGDATAFMT_16BIT = 16-bit integer w/ encoded luminance
+ * SGILOGDATAFMT_8BIT = 8-bit gray monitor values
+ *
+ * Note that the COMPRESSION_SGILOG applies a simple run-length encoding
+ * scheme by separating the logL, u and v bytes for each row and applying
+ * a PackBits type of compression. Since the 24-bit encoding is not
+ * adaptive, the 32-bit color format takes less space in many cases.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <math.h>
+
+/*
+ * State block for each open TIFF
+ * file using LogLuv compression/decompression.
+ */
+typedef struct logLuvState LogLuvState;
+
+struct logLuvState {
+ int user_datafmt; /* user data format */
+ int pixel_size; /* bytes per pixel */
+
+ tidata_t* tbuf; /* translation buffer */
+ short tbuflen; /* buffer length */
+ void (*tfunc)(LogLuvState*, tidata_t, int);
+
+ TIFFVSetMethod vgetparent; /* super-class method */
+ TIFFVSetMethod vsetparent; /* super-class method */
+};
+
+#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data)
+#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data)
+
+#define N(a) (sizeof(a)/sizeof(a[0]))
+#define SGILOGDATAFMT_UNKNOWN -1
+
+#define MINRUN 4 /* minimum run length */
+
+/*
+ * Decode a string of 16-bit gray pixels.
+ */
+static int
+LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
+{
+ LogLuvState* sp = DecoderState(tif);
+ int shft, i, npixels;
+ u_char* bp;
+ int16* tp;
+ int16 b;
+ int cc, rc;
+
+ assert(s == 0);
+ assert(sp != NULL);
+
+ npixels = occ / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
+ tp = (int16*) op;
+ else {
+ assert(sp->tbuflen >= npixels);
+ tp = (int16*) sp->tbuf;
+ }
+ _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0]));
+
+ bp = (u_char*) tif->tif_rawcp;
+ cc = tif->tif_rawcc;
+ /* get each byte string */
+ for (shft = 2*8; (shft -= 8) >= 0; ) {
+ for (i = 0; i < npixels && cc > 0; )
+ if (*bp >= 128) { /* run */
+ rc = *bp++ + (2-128);
+ b = (int16)*bp++ << shft;
+ cc -= 2;
+ while (rc--)
+ tp[i++] |= b;
+ } else { /* non-run */
+ rc = *bp++; /* nul is noop */
+ while (--cc && rc--)
+ tp[i++] |= (int16)*bp++ << shft;
+ }
+ if (i != npixels) {
+ TIFFError(tif->tif_name,
+ "LogL16Decode: Not enough data at row %d (short %d pixels)",
+ tif->tif_row, npixels - i);
+ tif->tif_rawcp = (tidata_t) bp;
+ tif->tif_rawcc = cc;
+ return (0);
+ }
+ }
+ (*sp->tfunc)(sp, op, npixels);
+ tif->tif_rawcp = (tidata_t) bp;
+ tif->tif_rawcc = cc;
+ return (1);
+}
+
+/*
+ * Decode a string of 24-bit pixels.
+ */
+static int
+LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
+{
+ LogLuvState* sp = DecoderState(tif);
+ int cc, i, npixels;
+ u_char* bp;
+ uint32* tp;
+
+ assert(s == 0);
+ assert(sp != NULL);
+
+ npixels = occ / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_RAW)
+ tp = (uint32 *)op;
+ else {
+ assert(sp->tbuflen >= npixels);
+ tp = (uint32 *) sp->tbuf;
+ }
+ _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0]));
+ /* copy to array of uint32 */
+ bp = (u_char*) tif->tif_rawcp;
+ cc = tif->tif_rawcc;
+ for (i = 0; i < npixels && cc > 0; i++) {
+ tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
+ bp += 3;
+ cc -= 3;
+ }
+ tif->tif_rawcp = (tidata_t) bp;
+ tif->tif_rawcc = cc;
+ if (i != npixels) {
+ TIFFError(tif->tif_name,
+ "LogLuvDecode24: Not enough data at row %d (short %d pixels)",
+ tif->tif_row, npixels - i);
+ return (0);
+ }
+ (*sp->tfunc)(sp, op, npixels);
+ return (1);
+}
+
+/*
+ * Decode a string of 32-bit pixels.
+ */
+static int
+LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
+{
+ LogLuvState* sp;
+ int shft, i, npixels;
+ u_char* bp;
+ uint32* tp;
+ uint32 b;
+ int cc, rc;
+
+ assert(s == 0);
+ sp = DecoderState(tif);
+ assert(sp != NULL);
+
+ npixels = occ / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_RAW)
+ tp = (uint32*) op;
+ else {
+ assert(sp->tbuflen >= npixels);
+ tp = (uint32*) sp->tbuf;
+ }
+ _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0]));
+
+ bp = (u_char*) tif->tif_rawcp;
+ cc = tif->tif_rawcc;
+ /* get each byte string */
+ for (shft = 4*8; (shft -= 8) >= 0; ) {
+ for (i = 0; i < npixels && cc > 0; )
+ if (*bp >= 128) { /* run */
+ rc = *bp++ + (2-128);
+ b = (uint32)*bp++ << shft;
+ cc -= 2;
+ while (rc--)
+ tp[i++] |= b;
+ } else { /* non-run */
+ rc = *bp++; /* nul is noop */
+ while (--cc && rc--)
+ tp[i++] |= (uint32)*bp++ << shft;
+ }
+ if (i != npixels) {
+ TIFFError(tif->tif_name,
+ "LogLuvDecode32: Not enough data at row %d (short %d pixels)",
+ tif->tif_row, npixels - i);
+ tif->tif_rawcp = (tidata_t) bp;
+ tif->tif_rawcc = cc;
+ return (0);
+ }
+ }
+ (*sp->tfunc)(sp, op, npixels);
+ tif->tif_rawcp = (tidata_t) bp;
+ tif->tif_rawcc = cc;
+ return (1);
+}
+
+/*
+ * Decode a strip of pixels. We break it into rows to
+ * maintain synchrony with the encode algorithm, which
+ * is row by row.
+ */
+static int
+LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ tsize_t rowlen = TIFFScanlineSize(tif);
+
+ assert(cc%rowlen == 0);
+ while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
+ bp += rowlen, cc -= rowlen;
+ return (cc == 0);
+}
+
+/*
+ * Decode a tile of pixels. We break it into rows to
+ * maintain synchrony with the encode algorithm, which
+ * is row by row.
+ */
+static int
+LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ tsize_t rowlen = TIFFTileRowSize(tif);
+
+ assert(cc%rowlen == 0);
+ while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
+ bp += rowlen, cc -= rowlen;
+ return (cc == 0);
+}
+
+/*
+ * Encode a row of 16-bit pixels.
+ */
+static int
+LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ LogLuvState* sp = EncoderState(tif);
+ int shft, i, j, npixels;
+ tidata_t op;
+ int16* tp;
+ int16 b;
+ int occ, rc, mask, beg;
+
+ assert(s == 0);
+ assert(sp != NULL);
+ npixels = cc / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
+ tp = (int16*) bp;
+ else {
+ tp = (int16*) sp->tbuf;
+ assert(sp->tbuflen >= npixels);
+ (*sp->tfunc)(sp, bp, npixels);
+ }
+ /* compress each byte string */
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ for (shft = 2*8; (shft -= 8) >= 0; )
+ for (i = 0; i < npixels; i += rc) {
+ if (occ < 4) {
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+ if (!TIFFFlushData1(tif))
+ return (-1);
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ }
+ mask = 0xff << shft; /* find next run */
+ for (beg = i; beg < npixels; beg += rc) {
+ b = tp[beg] & mask;
+ rc = 1;
+ while (rc < 127+2 && beg+rc < npixels &&
+ (tp[beg+rc] & mask) == b)
+ rc++;
+ if (rc >= MINRUN)
+ break; /* long enough */
+ }
+ if (beg-i > 1 && beg-i < MINRUN) {
+ b = tp[i] & mask; /* check short run */
+ j = i+1;
+ while ((tp[j++] & mask) == b)
+ if (j == beg) {
+ *op++ = 128-2+j-i;
+ *op++ = b >> shft;
+ occ -= 2;
+ i = beg;
+ break;
+ }
+ }
+ while (i < beg) { /* write out non-run */
+ if ((j = beg-i) > 127) j = 127;
+ if (occ < j+3) {
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+ if (!TIFFFlushData1(tif))
+ return (-1);
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ }
+ *op++ = j; occ--;
+ while (j--) {
+ *op++ = tp[i++] >> shft & 0xff;
+ occ--;
+ }
+ }
+ if (rc >= MINRUN) { /* write out run */
+ *op++ = 128-2+rc;
+ *op++ = tp[beg] >> shft & 0xff;
+ occ -= 2;
+ } else
+ rc = 0;
+ }
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+
+ return (0);
+}
+
+/*
+ * Encode a row of 24-bit pixels.
+ */
+static int
+LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ LogLuvState* sp = EncoderState(tif);
+ int i, npixels, occ;
+ tidata_t op;
+ uint32* tp;
+
+ assert(s == 0);
+ assert(sp != NULL);
+ npixels = cc / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_RAW)
+ tp = (uint32*) bp;
+ else {
+ tp = (uint32*) sp->tbuf;
+ assert(sp->tbuflen >= npixels);
+ (*sp->tfunc)(sp, bp, npixels);
+ }
+ /* write out encoded pixels */
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ for (i = npixels; i--; ) {
+ if (occ < 3) {
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+ if (!TIFFFlushData1(tif))
+ return (-1);
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ }
+ *op++ = *tp >> 16;
+ *op++ = *tp >> 8 & 0xff;
+ *op++ = *tp++ & 0xff;
+ occ -= 3;
+ }
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+
+ return (0);
+}
+
+/*
+ * Encode a row of 32-bit pixels.
+ */
+static int
+LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ LogLuvState* sp = EncoderState(tif);
+ int shft, i, j, npixels;
+ tidata_t op;
+ uint32* tp;
+ uint32 b;
+ int occ, rc, mask, beg;
+
+ assert(s == 0);
+ assert(sp != NULL);
+
+ npixels = cc / sp->pixel_size;
+
+ if (sp->user_datafmt == SGILOGDATAFMT_RAW)
+ tp = (uint32*) bp;
+ else {
+ tp = (uint32*) sp->tbuf;
+ assert(sp->tbuflen >= npixels);
+ (*sp->tfunc)(sp, bp, npixels);
+ }
+ /* compress each byte string */
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ for (shft = 4*8; (shft -= 8) >= 0; )
+ for (i = 0; i < npixels; i += rc) {
+ if (occ < 4) {
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+ if (!TIFFFlushData1(tif))
+ return (-1);
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ }
+ mask = 0xff << shft; /* find next run */
+ for (beg = i; beg < npixels; beg += rc) {
+ b = tp[beg] & mask;
+ rc = 1;
+ while (rc < 127+2 && beg+rc < npixels &&
+ (tp[beg+rc] & mask) == b)
+ rc++;
+ if (rc >= MINRUN)
+ break; /* long enough */
+ }
+ if (beg-i > 1 && beg-i < MINRUN) {
+ b = tp[i] & mask; /* check short run */
+ j = i+1;
+ while ((tp[j++] & mask) == b)
+ if (j == beg) {
+ *op++ = 128-2+j-i;
+ *op++ = b >> shft;
+ occ -= 2;
+ i = beg;
+ break;
+ }
+ }
+ while (i < beg) { /* write out non-run */
+ if ((j = beg-i) > 127) j = 127;
+ if (occ < j+3) {
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+ if (!TIFFFlushData1(tif))
+ return (-1);
+ op = tif->tif_rawcp;
+ occ = tif->tif_rawdatasize - tif->tif_rawcc;
+ }
+ *op++ = j; occ--;
+ while (j--) {
+ *op++ = tp[i++] >> shft & 0xff;
+ occ--;
+ }
+ }
+ if (rc >= MINRUN) { /* write out run */
+ *op++ = 128-2+rc;
+ *op++ = tp[beg] >> shft & 0xff;
+ occ -= 2;
+ } else
+ rc = 0;
+ }
+ tif->tif_rawcp = op;
+ tif->tif_rawcc = tif->tif_rawdatasize - occ;
+
+ return (0);
+}
+
+/*
+ * Encode a strip of pixels. We break it into rows to
+ * avoid encoding runs across row boundaries.
+ */
+static int
+LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ tsize_t rowlen = TIFFScanlineSize(tif);
+
+ assert(cc%rowlen == 0);
+ while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0)
+ bp += rowlen, cc -= rowlen;
+ return (cc == 0);
+}
+
+/*
+ * Encode a tile of pixels. We break it into rows to
+ * avoid encoding runs across row boundaries.
+ */
+static int
+LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
+{
+ tsize_t rowlen = TIFFTileRowSize(tif);
+
+ assert(cc%rowlen == 0);
+ while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0)
+ bp += rowlen, cc -= rowlen;
+ return (cc == 0);
+}
+
+/*
+ * Encode/Decode functions for converting to and from user formats.
+ */
+#include "uvcode.h"
+
+#define U_NEU 0.210526316
+#define V_NEU 0.473684211
+
+#ifdef M_LN2
+#define LOGOF2 M_LN2
+#else
+#define LOGOF2 0.69314718055994530942
+#endif
+#define log2(x) ((1./LOGOF2)*log(x))
+#define exp2(x) exp(LOGOF2*(x))
+
+#define UVSCALE 410.
+
+static double
+pix16toY(int p16)
+{
+ int Le = p16 & 0x7fff;
+ double Y;
+
+ if (!Le)
+ return (0.);
+ Y = exp(LOGOF2/256.*(Le+.5) - LOGOF2*64.);
+ if (p16 & 0x8000)
+ return (-Y);
+ return (Y);
+}
+
+static int
+pix16fromY(double Y)
+{
+ if (Y >= 1.84467e19)
+ return (0x7fff);
+ if (Y <= -1.84467e19)
+ return (0xffff);
+ if (Y > 5.43571e-20)
+ return (int)(256.*(log2(Y) + 64.));
+ if (Y < -5.43571e-20)
+ return (~0x7fff | (int)(256.*(log2(-Y) + 64.)));
+ return (0);
+}
+
+static void
+L16toY(LogLuvState* sp, tidata_t op, int n)
+{
+ int16* l16 = (int16*) sp->tbuf;
+ float* yp = (float*) op;
+
+ while (n-- > 0)
+ *yp++ = pix16toY(*l16++);
+}
+
+static void
+L16toGry(LogLuvState* sp, tidata_t op, int n)
+{
+ int16* l16 = (int16*) sp->tbuf;
+ uint8* gp = (uint8*) op;
+
+ while (n-- > 0) {
+ double Y = pix16toY(*l16++);
+ *gp++ = (Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y));
+ }
+}
+
+static void
+L16fromY(LogLuvState* sp, tidata_t op, int n)
+{
+ int16* l16 = (int16*) sp->tbuf;
+ float* yp = (float*) op;
+
+ while (n-- > 0)
+ *l16++ = pix16fromY(*yp++);
+}
+
+static void
+XYZtoRGB24(float xyz[3], uint8 rgb[3])
+{
+ double r, g, b;
+ /* assume CCIR-709 primaries */
+ r = 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2];
+ g = -1.022*xyz[0] + 1.978*xyz[1] + 0.044*xyz[2];
+ b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2];
+ /* assume 2.0 gamma for speed */
+ /* could use integer sqrt approx., but this is probably faster */
+ rgb[0] = (r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r));
+ rgb[1] = (g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g));
+ rgb[2] = (b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b));
+}
+
+static int
+uv_encode(double u, double v) /* encode (u',v') coordinates */
+{
+ register int vi, ui;
+
+ if (v < UV_VSTART)
+ return(-1);
+ vi = (v - UV_VSTART)*(1./UV_SQSIZ);
+ if (vi >= UV_NVS)
+ return(-1);
+ if (u < uv_row[vi].ustart)
+ return(-1);
+ ui = (u - uv_row[vi].ustart)*(1./UV_SQSIZ);
+ if (ui >= uv_row[vi].nus)
+ return(-1);
+ return(uv_row[vi].ncum + ui);
+}
+
+static int
+uv_decode(double *up, double *vp, int c) /* decode (u',v') index */
+{
+ int upper, lower;
+ register int ui, vi;
+
+ if (c < 0 || c >= UV_NDIVS)
+ return(-1);
+ lower = 0; /* binary search */
+ upper = UV_NVS;
+ do {
+ vi = (lower + upper) >> 1;
+ ui = c - uv_row[vi].ncum;
+ if (ui > 0)
+ lower = vi;
+ else if (ui < 0)
+ upper = vi;
+ else
+ break;
+ } while (upper - lower > 1);
+ vi = lower;
+ ui = c - uv_row[vi].ncum;
+ *up = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ;
+ *vp = UV_VSTART + (vi+.5)*UV_SQSIZ;
+ return(0);
+}
+
+static void
+pix24toXYZ(uint32 p, float XYZ[3])
+{
+ int Le, Ce;
+ double L, u, v, s, x, y;
+ /* decode luminance */
+ Le = p >> 14 & 0x3ff;
+ if (Le == 0) {
+ XYZ[0] = XYZ[1] = XYZ[2] = 0.;
+ return;
+ }
+ L = exp(LOGOF2/64.*(Le+.5) - LOGOF2*12.);
+ /* decode color */
+ Ce = p & 0x3fff;
+ if (uv_decode(&u, &v, Ce) < 0) {
+ u = U_NEU; v = V_NEU;
+ }
+ s = 1./(6.*u - 16.*v + 12.);
+ x = 9.*u * s;
+ y = 4.*v * s;
+ /* convert to XYZ */
+ XYZ[0] = x/y * L;
+ XYZ[1] = L;
+ XYZ[2] = (1.-x-y)/y * L;
+}
+
+static uint32
+pix24fromXYZ(float XYZ[3])
+{
+ int Le, Ce;
+ double L, u, v, s;
+ /* encode luminance */
+ L = XYZ[1];
+ if (L >= 16.)
+ Le = 0x3ff;
+ else if (L <= 1./4096.)
+ Le = 0;
+ else
+ Le = 64.*(log2(L) + 12.);
+ /* encode color */
+ s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2];
+ if (s == 0.) {
+ u = U_NEU;
+ v = V_NEU;
+ } else {
+ u = 4.*XYZ[0] / s;
+ v = 9.*XYZ[1] / s;
+ }
+ Ce = uv_encode(u, v);
+ if (Ce < 0)
+ Ce = uv_encode(U_NEU, V_NEU);
+ /* combine encodings */
+ return (Le << 14 | Ce);
+}
+
+static void
+Luv24toXYZ(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ float* xyz = (float*) op;
+
+ while (n-- > 0) {
+ pix24toXYZ(*luv, xyz);
+ xyz += 3;
+ luv++;
+ }
+}
+
+static void
+Luv24toLuv48(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ int16* luv3 = (int16*) op;
+
+ while (n-- > 0) {
+ double u, v;
+
+ *luv3++ = (*luv >> 12 & 0xffd) + 13314;
+ if (uv_decode(&u, &v, *luv&0x3fff) < 0) {
+ u = U_NEU;
+ v = V_NEU;
+ }
+ *luv3++ = u * (1L<<15);
+ *luv3++ = v * (1L<<15);
+ luv++;
+ }
+}
+
+static void
+Luv24toRGB(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ uint8* rgb = (uint8*) op;
+
+ while (n-- > 0) {
+ float xyz[3];
+
+ pix24toXYZ(*luv++, xyz);
+ XYZtoRGB24(xyz, rgb);
+ rgb += 3;
+ }
+}
+
+static void
+Luv24fromXYZ(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ float* xyz = (float*) op;
+
+ while (n-- > 0) {
+ *luv++ = pix24fromXYZ(xyz);
+ xyz += 3;
+ }
+}
+
+static void
+Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ int16* luv3 = (int16*) op;
+
+ while (n-- > 0) {
+ int Le, Ce;
+
+ if (luv3[0] <= 0)
+ Le = 0;
+ else if (luv3[0] >= (1<<12)+3314)
+ Le = (1<<10) - 1;
+ else
+ Le = (luv3[0]-3314) >> 2;
+ Ce = uv_encode((luv[1]+.5)/(1<<15), (luv[2]+.5)/(1<<15));
+ if (Ce < 0)
+ Ce = uv_encode(U_NEU, V_NEU);
+ *luv++ = (uint32)Le << 14 | Ce;
+ luv3 += 3;
+ }
+}
+
+static void
+pix32toXYZ(uint32 p, float XYZ[3])
+{
+ double L, u, v, s, x, y;
+ /* decode luminance */
+ L = pix16toY((int)p >> 16);
+ if (L == 0.) {
+ XYZ[0] = XYZ[1] = XYZ[2] = 0.;
+ return;
+ }
+ /* decode color */
+ u = 1./UVSCALE * ((p>>8 & 0xff) + .5);
+ v = 1./UVSCALE * ((p & 0xff) + .5);
+ s = 1./(6.*u - 16.*v + 12.);
+ x = 9.*u * s;
+ y = 4.*v * s;
+ /* convert to XYZ */
+ XYZ[0] = x/y * L;
+ XYZ[1] = L;
+ XYZ[2] = (1.-x-y)/y * L;
+}
+
+static uint32
+pix32fromXYZ(float XYZ[3])
+{
+ unsigned int Le, ue, ve;
+ double u, v, s;
+ /* encode luminance */
+ Le = (unsigned int)pix16fromY(XYZ[1]);
+ /* encode color */
+ s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2];
+ if (s == 0.) {
+ u = U_NEU;
+ v = V_NEU;
+ } else {
+ u = 4.*XYZ[0] / s;
+ v = 9.*XYZ[1] / s;
+ }
+ if (u <= 0.) ue = 0;
+ else ue = UVSCALE * u;
+ if (ue > 255) ue = 255;
+ if (v <= 0.) ve = 0;
+ else ve = UVSCALE * v;
+ if (ve > 255) ve = 255;
+ /* combine encodings */
+ return (Le << 16 | ue << 8 | ve);
+}
+
+static void
+Luv32toXYZ(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ float* xyz = (float*) op;
+
+ while (n-- > 0) {
+ pix32toXYZ(*luv++, xyz);
+ xyz += 3;
+ }
+}
+
+static void
+Luv32toLuv48(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ int16* luv3 = (int16*) op;
+
+ while (n-- > 0) {
+ double u, v;
+
+ *luv3++ = *luv >> 16;
+ u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5);
+ v = 1./UVSCALE * ((*luv & 0xff) + .5);
+ *luv3++ = u * (1L<<15);
+ *luv3++ = v * (1L<<15);
+ luv++;
+ }
+}
+
+static void
+Luv32toRGB(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ uint8* rgb = (uint8*) op;
+
+ while (n-- > 0) {
+ float xyz[3];
+
+ pix32toXYZ(*luv++, xyz);
+ XYZtoRGB24(xyz, rgb);
+ rgb += 3;
+ }
+}
+
+static void
+Luv32fromXYZ(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ float* xyz = (float*) op;
+
+ while (n-- > 0) {
+ *luv++ = pix32fromXYZ(xyz);
+ xyz += 3;
+ }
+}
+
+static void
+Luv32fromLuv48(LogLuvState* sp, tidata_t op, int n)
+{
+ uint32* luv = (uint32*) sp->tbuf;
+ int16* luv3 = (int16*) op;
+
+ while (n-- > 0) {
+ *luv++ = (uint32)luv3[0] << 16 |
+ (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) |
+ (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff);
+ luv3 += 3;
+ }
+}
+
+static void
+_logLuvNop(LogLuvState* sp, tidata_t op, int n)
+{
+ (void) sp; (void) op; (void) n;
+}
+
+static int
+LogL16GuessDataFmt(TIFFDirectory *td)
+{
+#define PACK(s,b,f) (((b)<<6)|((s)<<3)|(f))
+ switch (PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat)) {
+ case PACK(1, 32, SAMPLEFORMAT_IEEEFP):
+ return (SGILOGDATAFMT_FLOAT);
+ case PACK(1, 16, SAMPLEFORMAT_VOID):
+ case PACK(1, 16, SAMPLEFORMAT_INT):
+ case PACK(1, 16, SAMPLEFORMAT_UINT):
+ return (SGILOGDATAFMT_16BIT);
+ case PACK(1, 8, SAMPLEFORMAT_VOID):
+ case PACK(1, 8, SAMPLEFORMAT_UINT):
+ return (SGILOGDATAFMT_8BIT);
+ }
+#undef PACK
+ return (SGILOGDATAFMT_UNKNOWN);
+}
+
+static int
+LogL16InitState(TIFF* tif)
+{
+ TIFFDirectory *td = &tif->tif_dir;
+ LogLuvState* sp = DecoderState(tif);
+ static const char module[] = "LogL16InitState";
+
+ assert(sp != NULL);
+ assert(td->td_photometric == PHOTOMETRIC_LOGL);
+
+ /* for some reason, we can't do this in TIFFInitLogL16 */
+ if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
+ sp->user_datafmt = LogL16GuessDataFmt(td);
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->pixel_size = sizeof (float);
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->pixel_size = sizeof (int16);
+ break;
+ case SGILOGDATAFMT_8BIT:
+ sp->pixel_size = sizeof (uint8);
+ break;
+ default:
+ TIFFError(tif->tif_name,
+ "No support for converting user data format to LogL");
+ return (0);
+ }
+ sp->tbuflen = td->td_imagewidth * td->td_rowsperstrip;
+ sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16));
+ if (sp->tbuf == NULL) {
+ TIFFError(module, "%s: No space for SGILog translation buffer",
+ tif->tif_name);
+ return (0);
+ }
+ return (1);
+}
+
+static int
+LogLuvGuessDataFmt(TIFFDirectory *td)
+{
+ int guess;
+
+ /*
+ * If the user didn't tell us their datafmt,
+ * take our best guess from the bitspersample.
+ */
+#define PACK(a,b) (((a)<<3)|(b))
+ switch (PACK(td->td_bitspersample, td->td_sampleformat)) {
+ case PACK(32, SAMPLEFORMAT_IEEEFP):
+ guess = SGILOGDATAFMT_FLOAT;
+ break;
+ case PACK(32, SAMPLEFORMAT_VOID):
+ case PACK(32, SAMPLEFORMAT_UINT):
+ case PACK(32, SAMPLEFORMAT_INT):
+ guess = SGILOGDATAFMT_RAW;
+ break;
+ case PACK(16, SAMPLEFORMAT_VOID):
+ case PACK(16, SAMPLEFORMAT_INT):
+ case PACK(16, SAMPLEFORMAT_UINT):
+ guess = SGILOGDATAFMT_16BIT;
+ break;
+ case PACK( 8, SAMPLEFORMAT_VOID):
+ case PACK( 8, SAMPLEFORMAT_UINT):
+ guess = SGILOGDATAFMT_8BIT;
+ break;
+ default:
+ guess = SGILOGDATAFMT_UNKNOWN;
+ break;
+#undef PACK
+ }
+ /*
+ * Double-check samples per pixel.
+ */
+ switch (td->td_samplesperpixel) {
+ case 1:
+ if (guess != SGILOGDATAFMT_RAW)
+ guess = SGILOGDATAFMT_UNKNOWN;
+ break;
+ case 3:
+ if (guess == SGILOGDATAFMT_RAW)
+ guess = SGILOGDATAFMT_UNKNOWN;
+ break;
+ default:
+ guess = SGILOGDATAFMT_UNKNOWN;
+ break;
+ }
+ return (guess);
+}
+
+static int
+LogLuvInitState(TIFF* tif)
+{
+ TIFFDirectory* td = &tif->tif_dir;
+ LogLuvState* sp = DecoderState(tif);
+ static const char module[] = "LogLuvInitState";
+
+ assert(sp != NULL);
+ assert(td->td_photometric == PHOTOMETRIC_LOGLUV);
+
+ /* for some reason, we can't do this in TIFFInitLogLuv */
+ if (td->td_planarconfig != PLANARCONFIG_CONTIG) {
+ TIFFError(module,
+ "SGILog compression cannot handle non-contiguous data");
+ return (0);
+ }
+ if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN)
+ sp->user_datafmt = LogLuvGuessDataFmt(td);
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->pixel_size = 3*sizeof (float);
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->pixel_size = 3*sizeof (int16);
+ break;
+ case SGILOGDATAFMT_RAW:
+ sp->pixel_size = sizeof (uint32);
+ break;
+ case SGILOGDATAFMT_8BIT:
+ sp->pixel_size = 3*sizeof (uint8);
+ break;
+ default:
+ TIFFError(tif->tif_name,
+ "No support for converting user data format to LogLuv");
+ return (0);
+ }
+ sp->tbuflen = td->td_imagewidth * td->td_rowsperstrip;
+ sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32));
+ if (sp->tbuf == NULL) {
+ TIFFError(module, "%s: No space for SGILog translation buffer",
+ tif->tif_name);
+ return (0);
+ }
+ return (1);
+}
+
+static int
+LogLuvSetupDecode(TIFF* tif)
+{
+ LogLuvState* sp = DecoderState(tif);
+ TIFFDirectory* td = &tif->tif_dir;
+
+ tif->tif_postdecode = _TIFFNoPostDecode;
+ switch (td->td_photometric) {
+ case PHOTOMETRIC_LOGLUV:
+ if (!LogLuvInitState(tif))
+ break;
+ if (td->td_compression == COMPRESSION_SGILOG24) {
+ tif->tif_decoderow = LogLuvDecode24;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = Luv24toXYZ;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->tfunc = Luv24toLuv48;
+ break;
+ case SGILOGDATAFMT_8BIT:
+ sp->tfunc = Luv24toRGB;
+ break;
+ }
+ } else {
+ tif->tif_decoderow = LogLuvDecode32;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = Luv32toXYZ;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->tfunc = Luv32toLuv48;
+ break;
+ case SGILOGDATAFMT_8BIT:
+ sp->tfunc = Luv32toRGB;
+ break;
+ }
+ }
+ return (1);
+ case PHOTOMETRIC_LOGL:
+ if (!LogL16InitState(tif))
+ break;
+ tif->tif_decoderow = LogL16Decode;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = L16toY;
+ break;
+ case SGILOGDATAFMT_8BIT:
+ sp->tfunc = L16toGry;
+ break;
+ }
+ return (1);
+ default:
+ TIFFError(tif->tif_name,
+ "Inappropriate photometric interpretation %d for SGILog compression; %s",
+ td->td_photometric, "must be either LogLUV or LogL");
+ break;
+ }
+ return (0);
+}
+
+static int
+LogLuvSetupEncode(TIFF* tif)
+{
+ LogLuvState* sp = EncoderState(tif);
+ TIFFDirectory* td = &tif->tif_dir;
+
+ switch (td->td_photometric) {
+ case PHOTOMETRIC_LOGLUV:
+ if (!LogLuvInitState(tif))
+ break;
+ if (td->td_compression == COMPRESSION_SGILOG24) {
+ tif->tif_encoderow = LogLuvEncode24;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = Luv24fromXYZ;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->tfunc = Luv24fromLuv48;
+ break;
+ case SGILOGDATAFMT_RAW:
+ break;
+ default:
+ goto notsupported;
+ }
+ } else {
+ tif->tif_encoderow = LogLuvEncode32;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = Luv32fromXYZ;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ sp->tfunc = Luv32fromLuv48;
+ break;
+ case SGILOGDATAFMT_RAW:
+ break;
+ default:
+ goto notsupported;
+ }
+ }
+ break;
+ case PHOTOMETRIC_LOGL:
+ if (!LogL16InitState(tif))
+ break;
+ tif->tif_encoderow = LogL16Encode;
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ sp->tfunc = L16fromY;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ break;
+ default:
+ goto notsupported;
+ }
+ break;
+ default:
+ TIFFError(tif->tif_name,
+ "Inappropriate photometric interpretation %d for SGILog compression; %s",
+ td->td_photometric, "must be either LogLUV or LogL");
+ break;
+ }
+ return (1);
+notsupported:
+ TIFFError(tif->tif_name,
+ "SGILog compression supported only for %s, or raw data",
+ td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv");
+ return (0);
+}
+
+static void
+LogLuvClose(TIFF* tif)
+{
+ TIFFDirectory *td = &tif->tif_dir;
+
+ /*
+ * For consistency, we always want to write out the same
+ * bitspersample and sampleformat for our TIFF file,
+ * regardless of the data format being used by the application.
+ * Since this routine is called after tags have been set but
+ * before they have been recorded in the file, we reset them here.
+ */
+ td->td_samplesperpixel =
+ (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3;
+ td->td_bitspersample = 16;
+ td->td_sampleformat = SAMPLEFORMAT_INT;
+}
+
+static void
+LogLuvCleanup(TIFF* tif)
+{
+ LogLuvState* sp = (LogLuvState *)tif->tif_data;
+
+ if (sp) {
+ if (sp->tbuf)
+ _TIFFfree(sp->tbuf);
+ _TIFFfree(sp);
+ tif->tif_data = NULL;
+ }
+}
+
+static int
+LogLuvVSetField(TIFF* tif, ttag_t tag, va_list ap)
+{
+ LogLuvState* sp = DecoderState(tif);
+ int bps, fmt;
+
+ switch (tag) {
+ case TIFFTAG_SGILOGDATAFMT:
+ sp->user_datafmt = va_arg(ap, int);
+ /*
+ * Tweak the TIFF header so that the rest of libtiff knows what
+ * size of data will be passed between app and library, and
+ * assume that the app knows what it is doing and is not
+ * confused by these header manipulations...
+ */
+ switch (sp->user_datafmt) {
+ case SGILOGDATAFMT_FLOAT:
+ bps = 32, fmt = SAMPLEFORMAT_IEEEFP;
+ break;
+ case SGILOGDATAFMT_16BIT:
+ bps = 16, fmt = SAMPLEFORMAT_INT;
+ break;
+ case SGILOGDATAFMT_RAW:
+ bps = 32, fmt = SAMPLEFORMAT_UINT;
+ break;
+ case SGILOGDATAFMT_8BIT:
+ bps = 8, fmt = SAMPLEFORMAT_UINT;
+ break;
+ default:
+ TIFFError(tif->tif_name,
+ "Unknown data format %d for LogLuv compression",
+ sp->user_datafmt);
+ return (0);
+ }
+ TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
+ TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt);
+ /*
+ * Must recalculate sizes should bits/sample change.
+ */
+ tif->tif_tilesize = TIFFTileSize(tif);
+ tif->tif_scanlinesize = TIFFScanlineSize(tif);
+ return (1);
+ default:
+ return (*sp->vsetparent)(tif, tag, ap);
+ }
+}
+
+static int
+LogLuvVGetField(TIFF* tif, ttag_t tag, va_list ap)
+{
+ LogLuvState *sp = (LogLuvState *)tif->tif_data;
+
+ switch (tag) {
+ case TIFFTAG_SGILOGDATAFMT:
+ *va_arg(ap, int*) = sp->user_datafmt;
+ return (1);
+ default:
+ return (*sp->vgetparent)(tif, tag, ap);
+ }
+}
+
+static const TIFFFieldInfo LogLuvFieldInfo[] = {
+ { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, FIELD_PSEUDO,
+ TRUE, FALSE, "SGILogDataFmt"}
+};
+
+int
+TIFFInitSGILog(TIFF* tif, int scheme)
+{
+ static const char module[] = "TIFFInitSGILog";
+ LogLuvState* sp;
+
+ assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
+
+ /*
+ * Allocate state block so tag methods have storage to record values.
+ */
+ tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LogLuvState));
+ if (tif->tif_data == NULL)
+ goto bad;
+ sp = (LogLuvState*) tif->tif_data;
+ memset(sp, 0, sizeof (*sp));
+ sp->user_datafmt = SGILOGDATAFMT_UNKNOWN;
+ sp->tfunc = _logLuvNop;
+
+ /*
+ * Install codec methods.
+ * NB: tif_decoderow & tif_encoderow are filled
+ * in at setup time.
+ */
+ tif->tif_setupdecode = LogLuvSetupDecode;
+ tif->tif_decodestrip = LogLuvDecodeStrip;
+ tif->tif_decodetile = LogLuvDecodeTile;
+ tif->tif_setupencode = LogLuvSetupEncode;
+ tif->tif_encodestrip = LogLuvEncodeStrip;
+ tif->tif_encodetile = LogLuvEncodeTile;
+ tif->tif_close = LogLuvClose;
+ tif->tif_cleanup = LogLuvCleanup;
+
+ /* override SetField so we can handle our private pseudo-tag */
+ _TIFFMergeFieldInfo(tif, LogLuvFieldInfo, N(LogLuvFieldInfo));
+ sp->vgetparent = tif->tif_vgetfield;
+ tif->tif_vgetfield = LogLuvVGetField; /* hook for codec tags */
+ sp->vsetparent = tif->tif_vsetfield;
+ tif->tif_vsetfield = LogLuvVSetField; /* hook for codec tags */
+
+ return (1);
+bad:
+ TIFFError(module, "%s: No space for LogLuv state block", tif->tif_name);
+ return (0);
+}
+#endif /* LOGLUV_SUPPORT */
diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
index be43e54f..6ee9af61 100644
--- a/libtiff/tif_lzw.c
+++ b/libtiff/tif_lzw.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_lzw.c,v 1.72 1997/01/27 19:36:58 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_lzw.c,v 1.73 1997/08/29 21:45:54 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_msdos.c b/libtiff/tif_msdos.c
index 5a44c8ae..e2b0ef51 100644
--- a/libtiff/tif_msdos.c
+++ b/libtiff/tif_msdos.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_msdos.c,v 1.14 1996/01/10 19:33:06 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_msdos.c,v 1.15 1997/08/29 21:45:55 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_next.c b/libtiff/tif_next.c
index eb191c11..ce7b4196 100644
--- a/libtiff/tif_next.c
+++ b/libtiff/tif_next.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_next.c,v 1.27 1996/01/10 19:33:07 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_next.c,v 1.28 1997/08/29 21:45:55 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
index bd995664..8b43cadc 100644
--- a/libtiff/tif_open.c
+++ b/libtiff/tif_open.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_open.c,v 1.65 1997/01/27 23:05:36 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_open.c,v 1.66 1997/08/29 21:45:56 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c
index 7a2e4452..b8d9bec6 100644
--- a/libtiff/tif_packbits.c
+++ b/libtiff/tif_packbits.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_packbits.c,v 1.49 1996/01/10 19:33:08 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_packbits.c,v 1.50 1997/08/29 21:45:56 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
index f7a0eea4..27f2a9d7 100644
--- a/libtiff/tif_pixarlog.c
+++ b/libtiff/tif_pixarlog.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996-1996 Sam Leffler
+ * Copyright (c) 1996-1997 Sam Leffler
* Copyright (c) 1996 Pixar
*
* Permission to use, copy, modify, distribute, and sell this software and
@@ -178,7 +178,7 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
register float t0, t1, t2, t3;
#define SCALE12 2048.0
-#define CLAMP12(t) (((t) > 3071) ? 3071 : (uint16) (t))
+#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071)
if (n >= stride) {
mask = CODE_MASK;
@@ -230,7 +230,7 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
n -= stride;
while (n > 0) {
REPEAT(stride,
- wp[stride] += *wp; t0 = ToLinearF[*wp&mask] * SCALE12;
+ wp[stride] += *wp; t0 = ToLinearF[wp[stride]&mask]*SCALE12;
*op = CLAMP12(t0); wp++; op++)
n -= stride;
}
@@ -456,8 +456,8 @@ typedef struct {
z_stream stream;
uint16 *tbuf;
uint16 stride;
- short user_datafmt;
- short state;
+ int state;
+ int user_datafmt;
int quality;
#define PLSTATE_INIT 1
@@ -1147,11 +1147,14 @@ PixarLogCleanup(TIFF* tif)
if (sp->ToLinearF) _TIFFfree(sp->ToLinearF);
if (sp->ToLinear16) _TIFFfree(sp->ToLinear16);
if (sp->ToLinear8) _TIFFfree(sp->ToLinear8);
- if (tif->tif_mode == O_RDONLY)
- inflateEnd(&sp->stream);
- else
- deflateEnd(&sp->stream);
- _TIFFfree(sp->tbuf);
+ if (sp->state&PLSTATE_INIT) {
+ if (tif->tif_mode == O_RDONLY)
+ inflateEnd(&sp->stream);
+ else
+ deflateEnd(&sp->stream);
+ }
+ if (sp->tbuf)
+ _TIFFfree(sp->tbuf);
_TIFFfree(sp);
tif->tif_data = NULL;
}
@@ -1206,6 +1209,11 @@ PixarLogVSetField(TIFF* tif, ttag_t tag, va_list ap)
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
break;
}
+ /*
+ * Must recalculate sizes should bits/sample change.
+ */
+ tif->tif_tilesize = TIFFTileSize(tif);
+ tif->tif_scanlinesize = TIFFScanlineSize(tif);
result = 1; /* NB: pseudo tag */
break;
default:
@@ -1220,6 +1228,9 @@ PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap)
PixarLogState *sp = (PixarLogState *)tif->tif_data;
switch (tag) {
+ case TIFFTAG_PIXARLOGQUALITY:
+ *va_arg(ap, int*) = sp->quality;
+ break;
case TIFFTAG_PIXARLOGDATAFMT:
*va_arg(ap, int*) = sp->user_datafmt;
break;
@@ -1230,7 +1241,7 @@ PixarLogVGetField(TIFF* tif, ttag_t tag, va_list ap)
}
static const TIFFFieldInfo pixarlogFieldInfo[] = {
- {TIFFTAG_PIXARLOGDATAFMT,0,0,TIFF_SHORT,FIELD_PSEUDO,FALSE,FALSE,""},
+ {TIFFTAG_PIXARLOGDATAFMT,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""},
{TIFFTAG_PIXARLOGQUALITY,0,0,TIFF_ANY, FIELD_PSEUDO,FALSE,FALSE,""}
};
@@ -1248,9 +1259,7 @@ TIFFInitPixarLog(TIFF* tif, int scheme)
if (tif->tif_data == NULL)
goto bad;
sp = (PixarLogState*) tif->tif_data;
- sp->stream.zalloc = NULL;
- sp->stream.zfree = NULL;
- sp->stream.opaque = NULL;
+ memset(sp, 0, sizeof (*sp));
sp->stream.data_type = Z_BINARY;
sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN;
diff --git a/libtiff/tif_predict.c b/libtiff/tif_predict.c
index 62a38179..90bc55e8 100644
--- a/libtiff/tif_predict.c
+++ b/libtiff/tif_predict.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_predict.c,v 1.4 1996/01/10 19:33:09 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_predict.c,v 1.6 1997/08/29 21:45:58 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -155,13 +155,6 @@ PredictorSetupEncode(TIFF* tif)
case 1: op; \
case 0: ; \
}
-#define XREPEAT4(n, op) \
- switch (n) { \
- default: { int i; for (i = n-4; i > 0; i--) { op; } } \
- case 2: op; \
- case 1: op; \
- case 0: ; \
- }
static void
horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc)
@@ -199,7 +192,7 @@ horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc)
} while ((int32) cc > 0);
} else {
do {
- XREPEAT4(stride, cp[stride] += *cp; cp++)
+ REPEAT4(stride, cp[stride] += *cp; cp++)
cc -= stride;
} while ((int32) cc > 0);
}
diff --git a/libtiff/tif_predict.h b/libtiff/tif_predict.h
index 56a0ecdb..8af37ace 100644
--- a/libtiff/tif_predict.h
+++ b/libtiff/tif_predict.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_predict.h,v 1.2 1996/01/10 19:33:22 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_predict.h,v 1.3 1997/08/29 21:45:38 sam Exp $ */
/*
- * Copyright (c) 1995-1996 Sam Leffler
- * Copyright (c) 1995-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1995-1997 Sam Leffler
+ * Copyright (c) 1995-1997 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
diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
index 1e2d3b20..753ba6dc 100644
--- a/libtiff/tif_print.c
+++ b/libtiff/tif_print.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_print.c,v 1.69 1996/12/13 05:25:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_print.c,v 1.71 1997/08/29 21:45:58 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -168,9 +168,20 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, " Photometric Interpretation: ");
if (td->td_photometric < NPHOTONAMES)
fprintf(fd, "%s\n", photoNames[td->td_photometric]);
- else
- fprintf(fd, "%u (0x%x)\n",
- td->td_photometric, td->td_photometric);
+ else {
+ switch (td->td_photometric) {
+ case PHOTOMETRIC_LOGL:
+ fprintf(fd, "CIE Log2(L)\n");
+ break;
+ case PHOTOMETRIC_LOGLUV:
+ fprintf(fd, "CIE Log2(L) (u',v')\n");
+ break;
+ default:
+ fprintf(fd, "%u (0x%x)\n",
+ td->td_photometric, td->td_photometric);
+ break;
+ }
+ }
}
if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) {
fprintf(fd, " Extra Samples: %u<", td->td_extrasamples);
@@ -195,6 +206,10 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
}
fprintf(fd, ">\n");
}
+ if (TIFFFieldSet(tif,FIELD_STONITS)) {
+ fprintf(fd, " Sample to Nits conversion factor: %.4e\n",
+ td->td_stonits);
+ }
#ifdef CMYK_SUPPORT
if (TIFFFieldSet(tif,FIELD_INKSET)) {
fprintf(fd, " Ink Set: ");
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
index 5f261618..185d340a 100644
--- a/libtiff/tif_read.c
+++ b/libtiff/tif_read.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_read.c,v 1.71 1996/07/18 22:48:25 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_read.c,v 1.73 1997/08/29 21:45:59 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -109,7 +109,7 @@ TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)
(*tif->tif_postdecode)(tif, (tidata_t) buf,
tif->tif_scanlinesize);
}
- return (e ? 1 : -1);
+ return (e > 0 ? 1 : -1);
}
/*
diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
index 4897c2b6..81d91eab 100644
--- a/libtiff/tif_strip.c
+++ b/libtiff/tif_strip.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_strip.c,v 1.25 1996/01/10 19:33:11 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_strip.c,v 1.26 1997/08/29 21:45:59 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_swab.c b/libtiff/tif_swab.c
index 5afb71d6..a4195056 100644
--- a/libtiff/tif_swab.c
+++ b/libtiff/tif_swab.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_swab.c,v 1.22 1996/01/10 19:33:12 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_swab.c,v 1.23 1997/08/29 21:46:00 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_thunder.c b/libtiff/tif_thunder.c
index fbc93c26..1e91e22c 100644
--- a/libtiff/tif_thunder.c
+++ b/libtiff/tif_thunder.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_thunder.c,v 1.29 1996/01/10 19:33:13 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_thunder.c,v 1.30 1997/08/29 21:46:00 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_tile.c b/libtiff/tif_tile.c
index 64b89a84..02ff2f82 100644
--- a/libtiff/tif_tile.c
+++ b/libtiff/tif_tile.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_tile.c,v 1.27 1996/01/10 19:33:14 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_tile.c,v 1.28 1997/08/29 21:46:01 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c
index ae0f6bb8..f02c7f31 100644
--- a/libtiff/tif_unix.c
+++ b/libtiff/tif_unix.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_unix.c,v 1.16 1996/01/10 19:33:14 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_unix.c,v 1.17 1997/08/29 21:46:02 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_version.c b/libtiff/tif_version.c
index 7ff3af08..4891c5f1 100644
--- a/libtiff/tif_version.c
+++ b/libtiff/tif_version.c
@@ -1,7 +1,7 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_version.c,v 1.16 1996/01/10 19:33:15 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_version.c,v 1.17 1997/08/29 21:46:02 sam Exp $ */
/*
- * Copyright (c) 1992-1996 Sam Leffler
- * Copyright (c) 1992-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1992-1997 Sam Leffler
+ * Copyright (c) 1992-1997 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
diff --git a/libtiff/tif_vms.c b/libtiff/tif_vms.c
index aede7734..e782770b 100644
--- a/libtiff/tif_vms.c
+++ b/libtiff/tif_vms.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_vms.c,v 1.21 1996/03/29 16:37:53 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_vms.c,v 1.22 1997/08/29 21:46:03 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_warning.c b/libtiff/tif_warning.c
index 7ec97cbe..7e578f38 100644
--- a/libtiff/tif_warning.c
+++ b/libtiff/tif_warning.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_warning.c,v 1.21 1996/01/10 19:33:17 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_warning.c,v 1.22 1997/08/29 21:46:03 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tif_win3.c b/libtiff/tif_win3.c
index 16e24781..727cf5c2 100644
--- a/libtiff/tif_win3.c
+++ b/libtiff/tif_win3.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_win3.c,v 1.6 1996/01/10 19:33:17 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_win3.c,v 1.8 1997/08/29 21:46:03 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -89,7 +89,7 @@ TIFFFdOpen(int fd, const char* name, const char* mode)
TIFF* tif;
tif = TIFFClientOpen(name, mode,
- (void*) fd,
+ (thandle_t) fd,
_tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc,
_tiffSizeProc, _tiffMapProc, _tiffUnmapProc);
if (tif)
diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c
index ea5e6996..ff2cd76d 100644
--- a/libtiff/tif_win32.c
+++ b/libtiff/tif_win32.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_win32.c,v 1.3 1996/01/10 19:33:18 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_win32.c,v 1.6 1997/08/29 21:46:04 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -83,43 +83,39 @@ _tiffSizeProc(thandle_t fd)
return ((toff_t)GetFileSize(fd, NULL));
}
-/*
- * Because Windows uses both a handle and a pointer for file mapping, and only
- * the pointer is returned, the handle must be saved for later use (by the
- * unmap function). To do this, the tiff structure has an extra member,
- * pv_map_handle, which is contiguous with (4 bytes or one 32-bit word above)
- * the tif_base parameter which is passed as *pbase to the map function.
- * pv_map_handle is then accessed indirectly (and perhaps somewhat unsafely)
- * as an offset from the *pbase parameter by _tiffMapProc. The handle thus
- * created and saved is destroyed by _tiffUnmapProc, which does not need size
- * in Win32 but receives the map handle value in the size parameter instead.
- */
-
#pragma argsused
static int
_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
- return(0);
+ return (0);
}
+/*
+ * From "Hermann Josef Hill" <lhill@rhein-zeitung.de>:
+ *
+ * Windows uses both a handle and a pointer for file mapping,
+ * but according to the SDK documentation and Richter's book
+ * "Advanced Windows Programming" it is safe to free the handle
+ * after obtaining the file mapping pointer
+ *
+ * This removes a nasty OS dependency and cures a problem
+ * with Visual C++ 5.0
+ */
static int
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
toff_t size;
- HANDLE *phMapFile;
+ HANDLE hMapFile;
+
if ((size = _tiffSizeProc(fd)) == (toff_t)-1)
- return(0);
- phMapFile = (HANDLE *)(((BYTE *)pbase) + 4);
- if ((*phMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL))
- == NULL)
- return(0);
- if ((*pbase = MapViewOfFile(*phMapFile, FILE_MAP_READ, 0, 0, 0)) ==
- NULL)
- {
- CloseHandle(*phMapFile);
- *phMapFile = NULL;
- return(0);
- }
+ return (0);
+ hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, size, NULL);
+ if (hMapFile == NULL)
+ return (0);
+ *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
+ CloseHandle(hMapFile);
+ if (*pbase == NULL)
+ return (0);
*psize = size;
return(1);
}
@@ -128,15 +124,12 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
static void
_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
- return;
}
static void
-_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t map_handle)
+_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
UnmapViewOfFile(base);
- CloseHandle((HANDLE)map_handle);
- return;
}
/*
@@ -223,7 +216,7 @@ _TIFFrealloc(tdata_t p, tsize_t s)
void* pvTmp;
if ((pvTmp = GlobalReAlloc(p, s, 0)) == NULL) {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
- CopyMemory(pvTmp, p, s);
+ CopyMemory(pvTmp, p, GlobalSize(p));
GlobalFree(p);
}
}
diff --git a/libtiff/tif_write.c b/libtiff/tif_write.c
index c5b64d22..203037cb 100644
--- a/libtiff/tif_write.c
+++ b/libtiff/tif_write.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_write.c,v 1.72 1996/01/10 19:33:19 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_write.c,v 1.76 1997/08/29 21:46:04 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -215,13 +215,13 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc)
if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample))
return ((tsize_t) 0);
if (!(*tif->tif_postencode)(tif))
- return (-1);
+ return ((tsize_t) -1);
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc);
if (tif->tif_rawcc > 0 &&
!TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))
- return (-1);
+ return ((tsize_t) -1);
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
return (cc);
@@ -395,8 +395,8 @@ TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc)
cc : (tsize_t) -1);
}
-#define isUnspecified(td, v) \
- (td->v == (uint32) -1 || (td)->td_imagelength == 0)
+#define isUnspecified(tif, f) \
+ (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0)
static int
TIFFSetupStrips(TIFF* tif)
@@ -404,11 +404,13 @@ TIFFSetupStrips(TIFF* tif)
TIFFDirectory* td = &tif->tif_dir;
if (isTiled(tif))
- td->td_stripsperimage = isUnspecified(td, td_tilelength) ?
- td->td_samplesperpixel : TIFFNumberOfTiles(tif);
+ td->td_stripsperimage =
+ isUnspecified(tif, FIELD_TILEDIMENSIONS) ?
+ td->td_samplesperpixel : TIFFNumberOfTiles(tif);
else
- td->td_stripsperimage = isUnspecified(td, td_rowsperstrip) ?
- td->td_samplesperpixel : TIFFNumberOfStrips(tif);
+ td->td_stripsperimage =
+ isUnspecified(tif, FIELD_ROWSPERSTRIP) ?
+ td->td_samplesperpixel : TIFFNumberOfStrips(tif);
td->td_nstrips = td->td_stripsperimage;
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
td->td_stripsperimage /= td->td_samplesperpixel;
diff --git a/libtiff/tif_zip.c b/libtiff/tif_zip.c
index 902c1c82..e2dc1444 100644
--- a/libtiff/tif_zip.c
+++ b/libtiff/tif_zip.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_zip.c,v 1.9 1997/01/27 19:36:58 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tif_zip.c,v 1.11 1997/08/29 21:46:05 sam Exp $ */
/*
- * Copyright (c) 1995-1996 Sam Leffler
- * Copyright (c) 1995-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1995-1997 Sam Leffler
+ * Copyright (c) 1995-1997 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
@@ -250,10 +250,13 @@ ZIPCleanup(TIFF* tif)
{
ZIPState* sp = ZState(tif);
if (sp) {
- if (tif->tif_mode == O_RDONLY)
- inflateEnd(&sp->stream);
- else
- deflateEnd(&sp->stream);
+ if (sp->state&ZSTATE_INIT) {
+ /* NB: avoid problems in the library */
+ if (tif->tif_mode == O_RDONLY)
+ inflateEnd(&sp->stream);
+ else
+ deflateEnd(&sp->stream);
+ }
_TIFFfree(sp);
tif->tif_data = NULL;
}
diff --git a/libtiff/tiff.h b/libtiff/tiff.h
index 2ccec968..49f05a98 100644
--- a/libtiff/tiff.h
+++ b/libtiff/tiff.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiff.h,v 1.75 1996/12/13 05:25:39 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tiff.h,v 1.78 1997/08/29 21:45:38 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -162,6 +162,8 @@ typedef enum {
/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */
#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */
#define COMPRESSION_JBIG 34661 /* ISO JBIG */
+#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */
+#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */
#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */
#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */
#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */
@@ -171,6 +173,8 @@ typedef enum {
#define PHOTOMETRIC_SEPARATED 5 /* !color separations */
#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */
#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */
+#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */
+#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */
#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */
#define THRESHHOLD_BILEVEL 1 /* b&w art scan */
#define THRESHHOLD_HALFTONE 2 /* or dithered scan */
@@ -342,6 +346,10 @@ typedef enum {
#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */
#define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */
#define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */
+/* tags 37439-37443 are registered to SGI <gregl@sgi.com> */
+#define TIFFTAG_STONITS 37439 /* Sample value to Nits */
+/* tag 34929 is a private tag registered to FedEx */
+#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */
/* tag 65535 is an undefined tag used by Eastman Kodak */
#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */
@@ -402,4 +410,9 @@ typedef enum {
#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */
/* 65559 is allocated to Oceana Matrix <dev@oceana.com> */
#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */
+#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */
+#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */
+#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */
+#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */
+#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */
#endif /* _TIFF_ */
diff --git a/libtiff/tiffcomp.h b/libtiff/tiffcomp.h
index c8673592..b3b6f9fc 100644
--- a/libtiff/tiffcomp.h
+++ b/libtiff/tiffcomp.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.49 1996/04/29 21:56:21 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.50 1997/08/29 21:45:39 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/libtiff/tiffconf.h b/libtiff/tiffconf.h
index 8d36f5d6..a4408b8d 100644
--- a/libtiff/tiffconf.h
+++ b/libtiff/tiffconf.h
@@ -1,7 +1,7 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffconf.h,v 1.15 1997/01/27 23:05:36 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tiffconf.h,v 1.17 1997/08/29 21:45:40 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -93,12 +93,14 @@
* ZIP_SUPPORT enable support for Deflate algorithm
* (requires freely available zlib software, see tif_zip.c)
* PIXARLOG_SUPPORT enable support for Pixar log-format algorithm
+ * LOGLUV_SUPPORT enable support for LogLuv high dynamic range encoding
*/
#define CCITT_SUPPORT
#define PACKBITS_SUPPORT
#define LZW_SUPPORT
#define THUNDER_SUPPORT
#define NEXT_SUPPORT
+#define LOGLUV_SUPPORT
#endif /* COMPRESSION_SUPPORT */
/*
diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h
index dd37437c..c19ca097 100644
--- a/libtiff/tiffio.h
+++ b/libtiff/tiffio.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffio.h,v 1.95 1997/01/27 23:05:10 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tiffio.h,v 1.97 1997/08/29 21:45:40 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -242,6 +242,7 @@ extern int TIFFIsUpSampled(TIFF*);
extern int TIFFIsMSB2LSB(TIFF*);
extern uint32 TIFFCurrentRow(TIFF*);
extern tdir_t TIFFCurrentDirectory(TIFF*);
+extern tdir_t TIFFNumberOfDirectories(TIFF*);
extern uint32 TIFFCurrentDirOffset(TIFF*);
extern tstrip_t TIFFCurrentStrip(TIFF*);
extern ttile_t TIFFCurrentTile(TIFF*);
diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h
index dd86dc0d..5690be45 100644
--- a/libtiff/tiffiop.h
+++ b/libtiff/tiffiop.h
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffiop.h,v 1.81 1997/01/27 19:09:09 sam Exp $ */
+/* $Header: /d1/sam/tiff/libtiff/RCS/tiffiop.h,v 1.84 1997/08/29 21:45:41 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -134,13 +134,6 @@ struct tiff {
tsize_t tif_rawcc; /* bytes unread from raw buffer */
/* memory-mapped file support */
tidata_t tif_base; /* base of mapped file */
-#ifdef __WIN32__
- void* pv_map_handle; /* WIN32 file mapping handle;
- * must be contiguous with tif_base
- * since map & unmap only get tif_base
- * and assume 4 byte offset to
- * pv_map_handle. */
-#endif
toff_t tif_size; /* size of mapped file region (bytes) */
TIFFMapFileProc tif_mapproc; /* map file method */
TIFFUnmapFileProc tif_unmapproc;/* unmap file method */
@@ -179,14 +172,8 @@ struct tiff {
((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
#define TIFFMapFileContents(tif, paddr, psize) \
((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize))
-#ifdef __WIN32__
-#define TIFFUnmapFileContents(tif, addr, dummy) \
- ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,\
- (toff_t)(tif)->pv_map_handle))
-#else
#define TIFFUnmapFileContents(tif, addr, size) \
((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size))
-#endif
/*
* Default Read/Seek/Write definitions.
@@ -276,6 +263,9 @@ extern int TIFFInitZIP(TIFF*, int);
#ifdef PIXARLOG_SUPPORT
extern int TIFFInitPixarLog(TIFF*, int);
#endif
+#ifdef LOGLUV_SUPPORT
+extern int TIFFInitSGILog(TIFF*, int);
+#endif
#ifdef VMS
extern const TIFFCodec _TIFFBuiltinCODECS[];
#else
diff --git a/libtiff/uvcode.h b/libtiff/uvcode.h
new file mode 100644
index 00000000..330c60b7
--- /dev/null
+++ b/libtiff/uvcode.h
@@ -0,0 +1,173 @@
+/* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */
+#define UV_SQSIZ 0.003500
+#define UV_NDIVS 16289
+#define UV_VSTART 0.016940
+#define UV_NVS 163
+static struct {
+ float ustart;
+ short nus, ncum;
+} uv_row[UV_NVS] = {
+ 0.247663, 4, 0,
+ 0.243779, 6, 4,
+ 0.241684, 7, 10,
+ 0.237874, 9, 17,
+ 0.235906, 10, 26,
+ 0.232153, 12, 36,
+ 0.228352, 14, 48,
+ 0.226259, 15, 62,
+ 0.222371, 17, 77,
+ 0.220410, 18, 94,
+ 0.214710, 21, 112,
+ 0.212714, 22, 133,
+ 0.210721, 23, 155,
+ 0.204976, 26, 178,
+ 0.202986, 27, 204,
+ 0.199245, 29, 231,
+ 0.195525, 31, 260,
+ 0.193560, 32, 291,
+ 0.189878, 34, 323,
+ 0.186216, 36, 357,
+ 0.186216, 36, 393,
+ 0.182592, 38, 429,
+ 0.179003, 40, 467,
+ 0.175466, 42, 507,
+ 0.172001, 44, 549,
+ 0.172001, 44, 593,
+ 0.168612, 46, 637,
+ 0.168612, 46, 683,
+ 0.163575, 49, 729,
+ 0.158642, 52, 778,
+ 0.158642, 52, 830,
+ 0.158642, 52, 882,
+ 0.153815, 55, 934,
+ 0.153815, 55, 989,
+ 0.149097, 58, 1044,
+ 0.149097, 58, 1102,
+ 0.142746, 62, 1160,
+ 0.142746, 62, 1222,
+ 0.142746, 62, 1284,
+ 0.138270, 65, 1346,
+ 0.138270, 65, 1411,
+ 0.138270, 65, 1476,
+ 0.132166, 69, 1541,
+ 0.132166, 69, 1610,
+ 0.126204, 73, 1679,
+ 0.126204, 73, 1752,
+ 0.126204, 73, 1825,
+ 0.120381, 77, 1898,
+ 0.120381, 77, 1975,
+ 0.120381, 77, 2052,
+ 0.120381, 77, 2129,
+ 0.112962, 82, 2206,
+ 0.112962, 82, 2288,
+ 0.112962, 82, 2370,
+ 0.107450, 86, 2452,
+ 0.107450, 86, 2538,
+ 0.107450, 86, 2624,
+ 0.107450, 86, 2710,
+ 0.100343, 91, 2796,
+ 0.100343, 91, 2887,
+ 0.100343, 91, 2978,
+ 0.095126, 95, 3069,
+ 0.095126, 95, 3164,
+ 0.095126, 95, 3259,
+ 0.095126, 95, 3354,
+ 0.088276, 100, 3449,
+ 0.088276, 100, 3549,
+ 0.088276, 100, 3649,
+ 0.088276, 100, 3749,
+ 0.081523, 105, 3849,
+ 0.081523, 105, 3954,
+ 0.081523, 105, 4059,
+ 0.081523, 105, 4164,
+ 0.074861, 110, 4269,
+ 0.074861, 110, 4379,
+ 0.074861, 110, 4489,
+ 0.074861, 110, 4599,
+ 0.068290, 115, 4709,
+ 0.068290, 115, 4824,
+ 0.068290, 115, 4939,
+ 0.068290, 115, 5054,
+ 0.063573, 119, 5169,
+ 0.063573, 119, 5288,
+ 0.063573, 119, 5407,
+ 0.063573, 119, 5526,
+ 0.057219, 124, 5645,
+ 0.057219, 124, 5769,
+ 0.057219, 124, 5893,
+ 0.057219, 124, 6017,
+ 0.050985, 129, 6141,
+ 0.050985, 129, 6270,
+ 0.050985, 129, 6399,
+ 0.050985, 129, 6528,
+ 0.050985, 129, 6657,
+ 0.044859, 134, 6786,
+ 0.044859, 134, 6920,
+ 0.044859, 134, 7054,
+ 0.044859, 134, 7188,
+ 0.040571, 138, 7322,
+ 0.040571, 138, 7460,
+ 0.040571, 138, 7598,
+ 0.040571, 138, 7736,
+ 0.036339, 142, 7874,
+ 0.036339, 142, 8016,
+ 0.036339, 142, 8158,
+ 0.036339, 142, 8300,
+ 0.032139, 146, 8442,
+ 0.032139, 146, 8588,
+ 0.032139, 146, 8734,
+ 0.032139, 146, 8880,
+ 0.027947, 150, 9026,
+ 0.027947, 150, 9176,
+ 0.027947, 150, 9326,
+ 0.023739, 154, 9476,
+ 0.023739, 154, 9630,
+ 0.023739, 154, 9784,
+ 0.023739, 154, 9938,
+ 0.019504, 158, 10092,
+ 0.019504, 158, 10250,
+ 0.019504, 158, 10408,
+ 0.016976, 161, 10566,
+ 0.016976, 161, 10727,
+ 0.016976, 161, 10888,
+ 0.016976, 161, 11049,
+ 0.012639, 165, 11210,
+ 0.012639, 165, 11375,
+ 0.012639, 165, 11540,
+ 0.009991, 168, 11705,
+ 0.009991, 168, 11873,
+ 0.009991, 168, 12041,
+ 0.009016, 170, 12209,
+ 0.009016, 170, 12379,
+ 0.009016, 170, 12549,
+ 0.006217, 173, 12719,
+ 0.006217, 173, 12892,
+ 0.005097, 175, 13065,
+ 0.005097, 175, 13240,
+ 0.005097, 175, 13415,
+ 0.003909, 177, 13590,
+ 0.003909, 177, 13767,
+ 0.002340, 177, 13944,
+ 0.002389, 170, 14121,
+ 0.001068, 164, 14291,
+ 0.001653, 157, 14455,
+ 0.000717, 150, 14612,
+ 0.001614, 143, 14762,
+ 0.000270, 136, 14905,
+ 0.000484, 129, 15041,
+ 0.001103, 123, 15170,
+ 0.001242, 115, 15293,
+ 0.001188, 109, 15408,
+ 0.001011, 103, 15517,
+ 0.000709, 97, 15620,
+ 0.000301, 89, 15717,
+ 0.002416, 82, 15806,
+ 0.003251, 76, 15888,
+ 0.003246, 69, 15964,
+ 0.004141, 62, 16033,
+ 0.005963, 55, 16095,
+ 0.008839, 47, 16150,
+ 0.010490, 40, 16197,
+ 0.016994, 31, 16237,
+ 0.023659, 21, 16268,
+};
diff --git a/man/Makefile.in b/man/Makefile.in
index 39b70460..d9480375 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -1,12 +1,12 @@
#! smake
-# $Header: /usr/people/sam/tiff/man/RCS/Makefile.in,v 1.13 1996/03/18 20:56:29 sam Exp $
+# $Header: /d1/sam/tiff/man/RCS/Makefile.in,v 1.14 1997/08/29 21:47:57 sam Exp $
#
# @WARNING@
#
# Tag Image File Format Library Manual Pages
#
-# Copyright (c) 1991-1995 Sam Leffler
-# Copyright (c) 1991-1995 Silicon Graphics, Inc.
+# Copyright (c) 1991-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/man/TIFFClose.3t b/man/TIFFClose.3t
index 7c89f9d8..8ed54998 100644
--- a/man/TIFFClose.3t
+++ b/man/TIFFClose.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFClose.3t,v 1.11 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFClose.3t,v 1.12 1997/08/29 21:48:06 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFError.3t b/man/TIFFError.3t
index 17fd33a4..3aa99625 100644
--- a/man/TIFFError.3t
+++ b/man/TIFFError.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFError.3t,v 1.13 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFError.3t,v 1.14 1997/08/29 21:48:07 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFFlush.3t b/man/TIFFFlush.3t
index 23bbec15..602b7243 100644
--- a/man/TIFFFlush.3t
+++ b/man/TIFFFlush.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFFlush.3t,v 1.12 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFFlush.3t,v 1.13 1997/08/29 21:48:07 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFGetField.3t b/man/TIFFGetField.3t
index 9768658e..fa20ac6e 100644
--- a/man/TIFFGetField.3t
+++ b/man/TIFFGetField.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFGetField.3t,v 1.17 1996/12/13 05:25:58 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFGetField.3t,v 1.19 1997/08/29 21:48:08 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
@@ -23,7 +23,7 @@
.\" OF THIS SOFTWARE.
.\"
.if n .po 0
-.TH TIFFGetField 3T "October 15, 1995"
+.TH TIFFGetField 3T "August 22, 1997"
.SH NAME
TIFFGetField, TIFFVGetField \- get the value(s) of a tag in an open
.SM TIFF
@@ -159,6 +159,7 @@ TIFFTAG_SAMPLESPERPIXEL 1 uint16*
TIFFTAG_SMAXSAMPLEVALUE 1 double*
TIFFTAG_SMINSAMPLEVALUE 1 double*
TIFFTAG_SOFTWARE 1 char**
+TIFFTAG_STONITS 1 double**
TIFFTAG_STRIPBYTECOUNTS 1 uint32**
TIFFTAG_STRIPOFFSETS 1 uint32**
TIFFTAG_SUBFILETYPE 1 uint32*
diff --git a/man/TIFFOpen.3t b/man/TIFFOpen.3t
index 5e98c301..092ed6f1 100644
--- a/man/TIFFOpen.3t
+++ b/man/TIFFOpen.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFOpen.3t,v 1.15 1997/01/27 23:46:06 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFOpen.3t,v 1.16 1997/08/29 21:48:08 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFPrintDirectory.3t b/man/TIFFPrintDirectory.3t
index cf96701f..a4a4aceb 100644
--- a/man/TIFFPrintDirectory.3t
+++ b/man/TIFFPrintDirectory.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFPrintDirectory.3t,v 1.7 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFPrintDirectory.3t,v 1.8 1997/08/29 21:48:09 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFRGBAImage.3t b/man/TIFFRGBAImage.3t
index 1a7090c7..7810c2e1 100644
--- a/man/TIFFRGBAImage.3t
+++ b/man/TIFFRGBAImage.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFRGBAImage.3t,v 1.1 1995/10/11 22:53:37 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFRGBAImage.3t,v 1.2 1997/08/29 21:48:09 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadDirectory.3t b/man/TIFFReadDirectory.3t
index d124018d..8103d452 100644
--- a/man/TIFFReadDirectory.3t
+++ b/man/TIFFReadDirectory.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadDirectory.3t,v 1.13 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadDirectory.3t,v 1.14 1997/08/29 21:48:10 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadEncodedStrip.3t b/man/TIFFReadEncodedStrip.3t
index ce4ccc2d..22a4dfd4 100644
--- a/man/TIFFReadEncodedStrip.3t
+++ b/man/TIFFReadEncodedStrip.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadEncodedStrip.3t,v 1.15 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadEncodedStrip.3t,v 1.16 1997/08/29 21:48:10 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadEncodedTile.3t b/man/TIFFReadEncodedTile.3t
index f865654b..1001dc88 100644
--- a/man/TIFFReadEncodedTile.3t
+++ b/man/TIFFReadEncodedTile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadEncodedTile.3t,v 1.11 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadEncodedTile.3t,v 1.12 1997/08/29 21:48:11 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadRGBAImage.3t b/man/TIFFReadRGBAImage.3t
index 9c1b5e4d..b72453e4 100644
--- a/man/TIFFReadRGBAImage.3t
+++ b/man/TIFFReadRGBAImage.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRGBAImage.3t,v 1.10 1995/10/11 22:53:44 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadRGBAImage.3t,v 1.11 1997/08/29 21:48:11 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadRawStrip.3t b/man/TIFFReadRawStrip.3t
index 3c237b46..39c81707 100644
--- a/man/TIFFReadRawStrip.3t
+++ b/man/TIFFReadRawStrip.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRawStrip.3t,v 1.12 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadRawStrip.3t,v 1.13 1997/08/29 21:48:12 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadRawTile.3t b/man/TIFFReadRawTile.3t
index 23a5e7da..d23c4bd8 100644
--- a/man/TIFFReadRawTile.3t
+++ b/man/TIFFReadRawTile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRawTile.3t,v 1.11 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadRawTile.3t,v 1.12 1997/08/29 21:48:12 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadScanline.3t b/man/TIFFReadScanline.3t
index 7abad14b..a0630eb5 100644
--- a/man/TIFFReadScanline.3t
+++ b/man/TIFFReadScanline.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadScanline.3t,v 1.15 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadScanline.3t,v 1.16 1997/08/29 21:48:13 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFReadTile.3t b/man/TIFFReadTile.3t
index d8c116a9..8c9d463d 100644
--- a/man/TIFFReadTile.3t
+++ b/man/TIFFReadTile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadTile.3t,v 1.11 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFReadTile.3t,v 1.12 1997/08/29 21:48:13 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFSetDirectory.3t b/man/TIFFSetDirectory.3t
index 5eab2796..b6fa6dcb 100644
--- a/man/TIFFSetDirectory.3t
+++ b/man/TIFFSetDirectory.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFSetDirectory.3t,v 1.12 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFSetDirectory.3t,v 1.13 1997/08/29 21:48:13 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFSetField.3t b/man/TIFFSetField.3t
index 0c7a29d3..06b3af2f 100644
--- a/man/TIFFSetField.3t
+++ b/man/TIFFSetField.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFSetField.3t,v 1.16 1996/12/13 05:25:58 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFSetField.3t,v 1.20 1997/08/29 21:48:14 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
@@ -23,7 +23,7 @@
.\" OF THIS SOFTWARE.
.\"
.if n .po 0
-.TH TIFFSetField 3T "October 15, 1995"
+.TH TIFFSetField 3T "August 28, 1997"
.SH NAME
TIFFSetField \- set the value(s) of a tag in a
.SM TIFF
@@ -49,8 +49,11 @@ file
is a parameter that is used to control the operation of the
.SM TIFF
library but whose value is not read or written to the underlying file.)
-The file must have been previously opened for writing with
-.IR TIFFOpen (3T).
+To set the value of a field
+the file must have been previously opened for writing with
+.IR TIFFOpen (3T);
+pseudo-tags can be set whether the file was opened for reading
+or writing.
The field is identified by
.IR tag ,
one of the values defined in the include file
@@ -139,7 +142,7 @@ TIFFTAG_PAGENUMBER 2 uint16
TIFFTAG_PHOTOMETRIC 1 uint16
TIFFTAG_PLANARCONFIG 1 uint16 \(dg
TIFFTAG_PREDICTOR 1 uint16 \(dg
-TIFFTAG_PRIMARYCHROMATICITIES 1 float 6-entry array
+TIFFTAG_PRIMARYCHROMATICITIES 1 float* 6-entry array
TIFFTAG_REFERENCEBLACKWHITE 1 float* \(dg 2*SamplesPerPixel array
TIFFTAG_RESOLUTIONUNIT 1 uint16
TIFFTAG_ROWSPERSTRIP 1 uint32 \(dg must be > 0
@@ -148,6 +151,7 @@ TIFFTAG_SAMPLESPERPIXEL 1 uint16 \(dg value must be <= 4
TIFFTAG_SMAXSAMPLEVALUE 1 double
TIFFTAG_SMINSAMPLEVALUE 1 double
TIFFTAG_SOFTWARE 1 char*
+TIFFTAG_STONITS 1 double \(dg
TIFFTAG_SUBFILETYPE 1 uint32
TIFFTAG_SUBIFD 2 uint16,uint32* count & offsets array
TIFFTAG_TARGETPRINTER 1 char*
@@ -158,7 +162,7 @@ TIFFTAG_TILEWIDTH 1 uint32 \(dg must be a multiple of 8
TIFFTAG_TRANSFERFUNCTION 1 or 3 \(dd uint16* 1<<BitsPerSample entry arrays
TIFFTAG_XPOSITION 1 float
TIFFTAG_XRESOLUTION 1 float
-TIFFTAG_WHITEPOINT 1 float 2-entry array
+TIFFTAG_WHITEPOINT 1 float* 2-entry array
TIFFTAG_YCBCRCOEFFICIENTS 1 float* \(dg 3-entry array
TIFFTAG_YCBCRPOSITIONING 1 uint16 \(dg
TIFFTAG_YCBCRSAMPLING 2 uint16 \(dg
diff --git a/man/TIFFWarning.3t b/man/TIFFWarning.3t
index a3e59902..0ca7e27e 100644
--- a/man/TIFFWarning.3t
+++ b/man/TIFFWarning.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWarning.3t,v 1.13 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWarning.3t,v 1.14 1997/08/29 21:48:14 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteDirectory.3t b/man/TIFFWriteDirectory.3t
index f390737d..6e0f2221 100644
--- a/man/TIFFWriteDirectory.3t
+++ b/man/TIFFWriteDirectory.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteDirectory.3t,v 1.12 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteDirectory.3t,v 1.13 1997/08/29 21:48:15 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteEncodedStrip.3t b/man/TIFFWriteEncodedStrip.3t
index 6be98cc2..28b85203 100644
--- a/man/TIFFWriteEncodedStrip.3t
+++ b/man/TIFFWriteEncodedStrip.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteEncodedStrip.3t,v 1.13 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteEncodedStrip.3t,v 1.14 1997/08/29 21:48:15 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteEncodedTile.3t b/man/TIFFWriteEncodedTile.3t
index 9decae89..b8bae7b9 100644
--- a/man/TIFFWriteEncodedTile.3t
+++ b/man/TIFFWriteEncodedTile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteEncodedTile.3t,v 1.10 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteEncodedTile.3t,v 1.11 1997/08/29 21:48:16 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteRawStrip.3t b/man/TIFFWriteRawStrip.3t
index ba6d489c..a5745862 100644
--- a/man/TIFFWriteRawStrip.3t
+++ b/man/TIFFWriteRawStrip.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteRawStrip.3t,v 1.12 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteRawStrip.3t,v 1.13 1997/08/29 21:48:16 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteRawTile.3t b/man/TIFFWriteRawTile.3t
index 441cd9e3..75995360 100644
--- a/man/TIFFWriteRawTile.3t
+++ b/man/TIFFWriteRawTile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteRawTile.3t,v 1.10 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteRawTile.3t,v 1.11 1997/08/29 21:48:16 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFWriteScanline.3t b/man/TIFFWriteScanline.3t
index a09beecf..1ab26892 100644
--- a/man/TIFFWriteScanline.3t
+++ b/man/TIFFWriteScanline.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteScanline.3t,v 1.13 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFWriteScanline.3t,v 1.14 1997/08/29 21:48:17 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFbuffer.3t b/man/TIFFbuffer.3t
index bb80474a..eedeb195 100644
--- a/man/TIFFbuffer.3t
+++ b/man/TIFFbuffer.3t
@@ -1,4 +1,4 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFbuffer.3t,v 1.1 1995/10/12 00:43:54 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFbuffer.3t,v 1.1 1995/10/12 00:43:54 sam Exp $
.\"
.\" Copyright (c) 1995 Sam Leffler
.\" Copyright (c) 1995 Silicon Graphics, Inc.
diff --git a/man/TIFFcodec.3t b/man/TIFFcodec.3t
index 9c0a753c..effcc538 100644
--- a/man/TIFFcodec.3t
+++ b/man/TIFFcodec.3t
@@ -1,4 +1,4 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFcodec.3t,v 1.1 1995/10/12 00:04:30 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFcodec.3t,v 1.1 1995/10/12 00:04:30 sam Exp $
.\"
.\" Copyright (c) 1995 Sam Leffler
.\" Copyright (c) 1995 Silicon Graphics, Inc.
diff --git a/man/TIFFmemory.3t b/man/TIFFmemory.3t
index 69464c84..781bce2e 100644
--- a/man/TIFFmemory.3t
+++ b/man/TIFFmemory.3t
@@ -1,4 +1,4 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFmemory.3t,v 1.1 1995/10/12 00:04:21 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFmemory.3t,v 1.1 1995/10/12 00:04:21 sam Exp $
.\"
.\" Copyright (c) 1995 Sam Leffler
.\" Copyright (c) 1995 Silicon Graphics, Inc.
diff --git a/man/TIFFquery.3t b/man/TIFFquery.3t
index a37ab86d..5de321ed 100644
--- a/man/TIFFquery.3t
+++ b/man/TIFFquery.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFquery.3t,v 1.14 1995/10/12 00:44:17 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFquery.3t,v 1.15 1997/08/29 21:48:19 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFsize.3t b/man/TIFFsize.3t
index f5db2664..72c16a75 100644
--- a/man/TIFFsize.3t
+++ b/man/TIFFsize.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFsize.3t,v 1.13 1995/10/12 00:44:17 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFsize.3t,v 1.14 1997/08/29 21:48:19 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFstrip.3t b/man/TIFFstrip.3t
index 506c399b..e85786ce 100644
--- a/man/TIFFstrip.3t
+++ b/man/TIFFstrip.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFstrip.3t,v 1.7 1995/10/12 00:44:17 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFstrip.3t,v 1.8 1997/08/29 21:48:20 sam Exp $
.\"
-.\" Copyright (c) 1992-1995 Sam Leffler
-.\" Copyright (c) 1992-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1992-1997 Sam Leffler
+.\" Copyright (c) 1992-1997 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
diff --git a/man/TIFFswab.3t b/man/TIFFswab.3t
index dfb8d56a..0f1f20ff 100644
--- a/man/TIFFswab.3t
+++ b/man/TIFFswab.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFswab.3t,v 1.10 1995/10/11 19:45:29 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFswab.3t,v 1.11 1997/08/29 21:48:20 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/TIFFtile.3t b/man/TIFFtile.3t
index d9f555c5..da4cc96e 100644
--- a/man/TIFFtile.3t
+++ b/man/TIFFtile.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/TIFFtile.3t,v 1.13 1995/10/12 00:44:17 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/TIFFtile.3t,v 1.14 1997/08/29 21:48:20 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/fax2ps.1 b/man/fax2ps.1
index 9cd1bf4c..628c0e1c 100644
--- a/man/fax2ps.1
+++ b/man/fax2ps.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/fax2ps.1,v 1.9 1995/07/05 18:52:42 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/fax2ps.1,v 1.10 1997/08/29 21:47:58 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/fax2tiff.1 b/man/fax2tiff.1
index 65965c28..662a3a4b 100644
--- a/man/fax2tiff.1
+++ b/man/fax2tiff.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/fax2tiff.1,v 1.17 1995/10/11 19:41:58 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/fax2tiff.1,v 1.18 1997/08/29 21:47:58 sam Exp $
.\"
-.\" Copyright (c) 1990-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/gif2tiff.1 b/man/gif2tiff.1
index 352dd5e8..91b795a1 100644
--- a/man/gif2tiff.1
+++ b/man/gif2tiff.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/gif2tiff.1,v 1.8 1995/10/11 19:41:58 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/gif2tiff.1,v 1.9 1997/08/29 21:47:59 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/libtiff.3t b/man/libtiff.3t
index 411a4659..96430850 100644
--- a/man/libtiff.3t
+++ b/man/libtiff.3t
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/libtiff.3t,v 1.23 1996/08/01 19:10:20 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/libtiff.3t,v 1.25 1997/08/29 21:48:21 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
@@ -23,7 +23,7 @@
.\" OF THIS SOFTWARE.
.\"
.if n .po 0
-.TH INTRO 3T "August 1, 1996"
+.TH INTRO 3T "August 21, 1997"
.SH NAME
libtiff \- introduction to
.IR libtiff ,
@@ -64,8 +64,10 @@ the 4-bit compression algorithm used
by the
.I ThunderScan
program (32809) (decompression only),
-NeXT's 2-bit compression algorithm (32766) (decompression only), and
-an experimental LZ-style algorithm known as Deflate (32946).
+NeXT's 2-bit compression algorithm (32766) (decompression only),
+an experimental LZ-style algorithm known as Deflate (32946), and
+an experimental CIE LogLuv compression scheme designed for images
+with high dynamic range (32845 for LogL and 32845 for LogLuv).
Directory information may be in either little- or big-endian byte
order\-byte swapping is automatically done by the library.
Data bit ordering may be either Most Significant Bit (\c
@@ -301,6 +303,7 @@ SamplesPerPixel 277 R/W lots
SMinSampleValue 340 R/W
SMaxSampleValue 341 R/W
Software 305 R/W
+StoNits 37439 R/W
StripByteCounts 279 R/W data i/o
StripOffsets 273 R/W data i/o
SubFileType 255 R/W called OSubFileType in spec
@@ -342,6 +345,10 @@ TIFFTAG_FAXFILLFUNC G3/G4 R/W bitmap fill function
TIFFTAG_JPEGQUALITY JPEG R/W compression quality control
TIFFTAG_JPEGCOLORMODE JPEG R/W control colorspace conversions
TIFFTAG_JPEGTABLESMODE JPEG R/W control contents of \fIJPEGTables\fP tag
+TIFFTAG_ZIPQUALITY Deflate R/W compression quality level
+TIFFTAG_PIXARLOGDATAFMT PixarLog R/W user data format
+TIFFTAG_PIXARLOGQUALITY PixarLog R/W compression quality level
+TIFFTAG_SGILOGDATAFMT SGILog R/W user data format
.fi
.TP
.B TIFFTAG_FAXMODE
@@ -403,6 +410,62 @@ and
JPEGTABLESMODE_HUFF
(include Huffman encoding tables).
The default value is JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF.
+.TP
+.B TIFFTAG_ZIPQUALITY
+Control the compression technique used by the Deflate codec.
+Quality levels are in the range 1-9 with larger numbers yielding better
+compression at the cost of more computation.
+The default quality level is 6 which yields a good time-space tradeoff.
+.TP
+.B TIFFTAG_PIXARLOGDATAFMT
+Control the format of user data passed
+.I in
+to the PixarLog codec when encoding and passed
+.I out
+from when decoding.
+Possible values are:
+PIXARLOGDATAFMT_8BIT
+for 8-bit unsigned pixels,
+PIXARLOGDATAFMT_8BITABGR
+for 8-bit unsigned ABGR-ordered pixels,
+PIXARLOGDATAFMT_11BITLOG
+for 11-bit log-encoded raw data,
+PIXARLOGDATAFMT_12BITPICIO
+for 12-bit PICIO-compatible data,
+PIXARLOGDATAFMT_16BIT
+for 16-bit signed samples,
+and
+PIXARLOGDATAFMT_FLOAT
+for 32-bit IEEE floating point samples.
+.TP
+.B TIFFTAG_PIXARLOGQUALITY
+Control the compression technique used by the PixarLog codec.
+This value is treated identically to TIFFTAG_ZIPQUALITY; see the
+above description.
+.TP
+.B TIFFTAG_SGILOGDATAFMT
+Control the format of client data passed
+.I in
+to the SGILog codec when encoding and passed
+.I out
+from when decoding.
+Possible values are:
+SGILOGDATAFMT_FLTXYZ
+for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels,
+SGILOGDATAFMT_16BITLUV
+for 16-bit encoded Luv pixels,
+SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW
+for no conversion of data,
+SGILOGDATAFMT_8BITRGB
+for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data),
+SGILOGDATAFMT_FLTY
+for converting between LogL and 32-bit IEEE floating valued Y pixels,
+SGILOGDATAFMT_16BITL
+for 16-bit encoded L pixels,
+and
+SGILOGDATAFMT_8BITGRY
+for returning 8-bit greyscale data
+(valid only when decoding LogL-encoded data).
.SH DIAGNOSTICS
All error messages are directed through the
.IR TIFFError
diff --git a/man/pal2rgb.1 b/man/pal2rgb.1
index 2b55beb2..30b2bcb8 100644
--- a/man/pal2rgb.1
+++ b/man/pal2rgb.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/pal2rgb.1,v 1.13 1995/10/11 19:41:59 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/pal2rgb.1,v 1.14 1997/08/29 21:47:59 sam Exp $
.\"
-.\" Copyright (c) 1990-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/ppm2tiff.1 b/man/ppm2tiff.1
index 4ea052b5..34393207 100644
--- a/man/ppm2tiff.1
+++ b/man/ppm2tiff.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/ppm2tiff.1,v 1.10 1995/10/11 19:42:00 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/ppm2tiff.1,v 1.11 1997/08/29 21:47:59 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/ras2tiff.1 b/man/ras2tiff.1
index 77f090d0..28874e5f 100644
--- a/man/ras2tiff.1
+++ b/man/ras2tiff.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/ras2tiff.1,v 1.13 1995/10/11 19:42:00 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/ras2tiff.1,v 1.14 1997/08/29 21:48:00 sam Exp $
.\"
-.\" Copyright (c) 1990-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/rgb2ycbcr.1 b/man/rgb2ycbcr.1
index 029253c4..ab5b400a 100644
--- a/man/rgb2ycbcr.1
+++ b/man/rgb2ycbcr.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/rgb2ycbcr.1,v 1.7 1995/10/11 19:42:01 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/rgb2ycbcr.1,v 1.8 1997/08/29 21:48:00 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/sgi2tiff.1 b/man/sgi2tiff.1
index e40a2a3b..1ca7c704 100644
--- a/man/sgi2tiff.1
+++ b/man/sgi2tiff.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/sgi2tiff.1,v 1.8 1995/10/11 19:42:02 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/sgi2tiff.1,v 1.9 1997/08/29 21:48:01 sam Exp $
.\"
-.\" Copyright (c) 1991-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1991-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/thumbnail.1 b/man/thumbnail.1
index 26cbbebc..d7dfe488 100644
--- a/man/thumbnail.1
+++ b/man/thumbnail.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/thumbnail.1,v 1.3 1995/10/11 19:42:36 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/thumbnail.1,v 1.4 1997/08/29 21:48:01 sam Exp $
.\"
-.\" Copyright (c) 1994-1995 Sam Leffler
-.\" Copyright (c) 1994-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1994-1997 Sam Leffler
+.\" Copyright (c) 1994-1997 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
diff --git a/man/tiff2bw.1 b/man/tiff2bw.1
index a1f454f5..51930345 100644
--- a/man/tiff2bw.1
+++ b/man/tiff2bw.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiff2bw.1,v 1.14 1995/10/11 19:42:03 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiff2bw.1,v 1.15 1997/08/29 21:48:01 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiff2ps.1 b/man/tiff2ps.1
index d636524b..06d309ed 100644
--- a/man/tiff2ps.1
+++ b/man/tiff2ps.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiff2ps.1,v 1.19 1997/01/27 23:48:56 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiff2ps.1,v 1.20 1997/08/29 21:48:02 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffcmp.1 b/man/tiffcmp.1
index 2cc3059c..59013fa0 100644
--- a/man/tiffcmp.1
+++ b/man/tiffcmp.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffcmp.1,v 1.18 1995/10/11 19:42:04 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffcmp.1,v 1.19 1997/08/29 21:48:02 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffcp.1 b/man/tiffcp.1
index e0cc4ef4..64952661 100644
--- a/man/tiffcp.1
+++ b/man/tiffcp.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffcp.1,v 1.24 1996/08/07 00:01:40 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffcp.1,v 1.25 1997/08/29 21:48:03 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffdither.1 b/man/tiffdither.1
index f8765deb..f211a60a 100644
--- a/man/tiffdither.1
+++ b/man/tiffdither.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffdither.1,v 1.16 1995/10/11 19:42:06 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffdither.1,v 1.17 1997/08/29 21:48:03 sam Exp $
.\"
-.\" Copyright (c) 1990-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffdump.1 b/man/tiffdump.1
index bdbb7013..c4c8f250 100644
--- a/man/tiffdump.1
+++ b/man/tiffdump.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffdump.1,v 1.14 1995/10/11 19:42:06 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffdump.1,v 1.15 1997/08/29 21:48:04 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffgt.1 b/man/tiffgt.1
index f4e548ab..6833a993 100644
--- a/man/tiffgt.1
+++ b/man/tiffgt.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffgt.1,v 1.20 1995/10/11 19:42:07 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffgt.1,v 1.21 1997/08/29 21:48:04 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffinfo.1 b/man/tiffinfo.1
index 550efcbd..0474d5c3 100644
--- a/man/tiffinfo.1
+++ b/man/tiffinfo.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffinfo.1,v 1.18 1997/01/27 23:49:18 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffinfo.1,v 1.19 1997/08/29 21:48:04 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffmedian.1 b/man/tiffmedian.1
index 3f3bb2f2..46ec319e 100644
--- a/man/tiffmedian.1
+++ b/man/tiffmedian.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffmedian.1,v 1.18 1995/10/11 19:42:09 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffmedian.1,v 1.19 1997/08/29 21:48:05 sam Exp $
.\"
-.\" Copyright (c) 1990-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1990-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/man/tiffsplit.1 b/man/tiffsplit.1
index e42a0357..cb2d81f6 100644
--- a/man/tiffsplit.1
+++ b/man/tiffsplit.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffsplit.1,v 1.5 1995/10/11 19:42:09 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffsplit.1,v 1.6 1997/08/29 21:48:05 sam Exp $
.\"
-.\" Copyright (c) 1992-1995 Sam Leffler
-.\" Copyright (c) 1992-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1992-1997 Sam Leffler
+.\" Copyright (c) 1992-1997 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
diff --git a/man/tiffsv.1 b/man/tiffsv.1
index 3adeeeb8..b891dadb 100644
--- a/man/tiffsv.1
+++ b/man/tiffsv.1
@@ -1,7 +1,7 @@
-.\" $Header: /usr/people/sam/tiff/man/RCS/tiffsv.1,v 1.16 1995/10/11 19:42:10 sam Exp $
+.\" $Header: /d1/sam/tiff/man/RCS/tiffsv.1,v 1.17 1997/08/29 21:48:06 sam Exp $
.\"
-.\" Copyright (c) 1988-1995 Sam Leffler
-.\" Copyright (c) 1991-1995 Silicon Graphics, Inc.
+.\" Copyright (c) 1988-1997 Sam Leffler
+.\" Copyright (c) 1991-1997 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
diff --git a/port/Makefile.in b/port/Makefile.in
index 13893578..eada81f9 100644
--- a/port/Makefile.in
+++ b/port/Makefile.in
@@ -1,12 +1,12 @@
#! smake
-# $Header: /usr/people/sam/tiff/port/RCS/Makefile.in,v 1.6 1996/03/18 20:55:51 sam Exp $
+# $Header: /d1/sam/tiff/port/RCS/Makefile.in,v 1.7 1997/08/29 21:48:53 sam Exp $
#
# @WARNING@
#
# Tag Image File Format Library
#
-# Copyright (c) 1995-1996 Sam Leffler
-# Copyright (c) 1995-1996 Silicon Graphics, Inc.
+# Copyright (c) 1995-1997 Sam Leffler
+# Copyright (c) 1995-1997 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
diff --git a/port/install.sh.in b/port/install.sh.in
index c4c52153..5558d7f9 100644
--- a/port/install.sh.in
+++ b/port/install.sh.in
@@ -1,12 +1,12 @@
#! @SCRIPT_SH@
-# $Header: /usr/people/sam/tiff/port/RCS/install.sh.in,v 1.19 1996/01/10 19:36:09 sam Exp $
+# $Header: /d1/sam/tiff/port/RCS/install.sh.in,v 1.20 1997/08/29 21:48:53 sam Exp $
#
# @WARNING@
#
# HylaFAX Facsimile Software
#
-# Copyright (c) 1990-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1990-1997 Sam Leffler
+# Copyright (c) 1991-1997 Silicon Graphics, Inc.
# HylaFAX is a trademark of Silicon Graphics
#
# Permission to use, copy, modify, distribute, and sell this software and
diff --git a/tools/Makefile.in b/tools/Makefile.in
index dc522592..cb0c13af 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -1,11 +1,11 @@
-# $Header: /usr/people/sam/tiff/tools/RCS/Makefile.in,v 1.21 1996/08/26 23:39:12 sam Exp $
+# $Header: /d1/sam/tiff/tools/RCS/Makefile.in,v 1.22 1997/08/29 21:46:45 sam Exp $
#
# @WARNING@
#
# TIFF Library Tools
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/tools/Makefile.lcc b/tools/Makefile.lcc
index 0e78b453..4e6643a1 100644
--- a/tools/Makefile.lcc
+++ b/tools/Makefile.lcc
@@ -1,9 +1,9 @@
-# $Header: /usr/people/sam/tiff/tools/RCS/Makefile.lcc,v 1.4 1996/01/10 19:35:26 sam Exp $
+# $Header: /d1/sam/tiff/tools/RCS/Makefile.lcc,v 1.5 1997/08/29 21:46:45 sam Exp $
#
# TIFF Library Tools
#
-# Copyright (c) 1988-1996 Sam Leffler
-# Copyright (c) 1991-1996 Silicon Graphics, Inc.
+# Copyright (c) 1988-1997 Sam Leffler
+# Copyright (c) 1991-1997 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
diff --git a/tools/fax2ps.c b/tools/fax2ps.c
index 65f68c90..f2efa53a 100644
--- a/tools/fax2ps.c
+++ b/tools/fax2ps.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/fax2ps.c,v 1.10 1996/04/29 21:58:49 sam Exp $" */
+/* $Header: /d1/sam/tiff/tools/RCS/fax2ps.c,v 1.11 1997/08/29 21:46:46 sam Exp $" */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c
index 9ceb5278..941d7a0e 100644
--- a/tools/fax2tiff.c
+++ b/tools/fax2tiff.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/fax2tiff.c,v 1.40 1996/01/10 19:35:27 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/fax2tiff.c,v 1.41 1997/08/29 21:46:46 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/gif2tiff.c b/tools/gif2tiff.c
index 263bcff7..e6691928 100644
--- a/tools/gif2tiff.c
+++ b/tools/gif2tiff.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/gif2tiff.c,v 1.27 1996/04/22 22:03:26 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/gif2tiff.c,v 1.29 1997/08/29 21:46:46 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -450,8 +450,8 @@ void
rasterize(int interleaved, char* mode)
{
register long row;
- register unsigned char *rr;
unsigned char *newras;
+ unsigned char *ras;
TIFF *tif;
tstrip_t strip;
tsize_t stripsize;
@@ -461,13 +461,12 @@ rasterize(int interleaved, char* mode)
return;
}
#define DRAWSEGMENT(offset, step) { \
- register unsigned char* ras = raster; \
for (row = offset; row < height; row += step) { \
- rr = newras + row*width; \
- _TIFFmemcpy(rr, ras, width); \
+ _TIFFmemcpy(newras + row*width, ras, width);\
ras += width; \
} \
}
+ ras = raster;
if (interleaved) {
DRAWSEGMENT(0, 8);
DRAWSEGMENT(4, 8);
diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c
index fced076c..9b853182 100644
--- a/tools/pal2rgb.c
+++ b/tools/pal2rgb.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/pal2rgb.c,v 1.30 1996/06/20 18:55:15 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/pal2rgb.c,v 1.31 1997/08/29 21:46:47 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/ppm2tiff.c b/tools/ppm2tiff.c
index b53e06b7..489cb9fa 100644
--- a/tools/ppm2tiff.c
+++ b/tools/ppm2tiff.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/ppm2tiff.c,v 1.26 1996/04/22 22:03:26 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/ppm2tiff.c,v 1.27 1997/08/29 21:46:47 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/ras2tiff.c b/tools/ras2tiff.c
index 467f0e85..86b9168d 100644
--- a/tools/ras2tiff.c
+++ b/tools/ras2tiff.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/ras2tiff.c,v 1.30 1996/06/10 20:47:54 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/ras2tiff.c,v 1.31 1997/08/29 21:46:48 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/rasterfile.h b/tools/rasterfile.h
index 30c09a7c..1ebf3528 100644
--- a/tools/rasterfile.h
+++ b/tools/rasterfile.h
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/rasterfile.h,v 1.1 1990/10/08 17:24:23 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/rasterfile.h,v 1.1 1990/10/08 17:24:23 sam Exp $ */
/*
* Description of header for files containing raster images
diff --git a/tools/rgb2ycbcr.c b/tools/rgb2ycbcr.c
index 925efe0a..f08fae2f 100644
--- a/tools/rgb2ycbcr.c
+++ b/tools/rgb2ycbcr.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/rgb2ycbcr.c,v 1.28 1996/06/10 20:47:54 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/rgb2ycbcr.c,v 1.29 1997/08/29 21:46:48 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/sgi2tiff.c b/tools/sgi2tiff.c
index 01d3d7c6..dbe30cf5 100644
--- a/tools/sgi2tiff.c
+++ b/tools/sgi2tiff.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/sgi2tiff.c,v 1.26 1996/01/10 19:35:31 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/sgi2tiff.c,v 1.27 1997/08/29 21:46:49 sam Exp $ */
/*
- * Copyright (c) 1991-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1991-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/sgigt.c b/tools/sgigt.c
index 98f04cd4..d9d14d46 100644
--- a/tools/sgigt.c
+++ b/tools/sgigt.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/sgigt.c,v 1.67 1996/11/11 16:18:16 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/sgigt.c,v 1.70 1997/08/31 23:54:02 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -183,7 +183,8 @@ main(int argc, char* argv[])
(img.photometric == PHOTOMETRIC_RGB ||
img.photometric == PHOTOMETRIC_YCBCR ||
img.photometric == PHOTOMETRIC_SEPARATED ||
- img.photometric == PHOTOMETRIC_PALETTE));
+ img.photometric == PHOTOMETRIC_PALETTE ||
+ img.photometric == PHOTOMETRIC_LOGLUV));
/*
* Check to see if the hardware can display 24-bit RGB.
*/
@@ -545,6 +546,10 @@ photoArg(const char* arg)
return (PHOTOMETRIC_YCBCR);
else if (strcmp(arg, "cielab") == 0)
return (PHOTOMETRIC_CIELAB);
+ else if (strcmp(arg, "logl") == 0)
+ return (PHOTOMETRIC_LOGL);
+ else if (strcmp(arg, "logluv") == 0)
+ return (PHOTOMETRIC_LOGLUV);
else
return ((uint16) -1);
}
@@ -575,9 +580,9 @@ putSeparateAndDraw(TIFFRGBAImage* img, uint32* raster,
if (x+w == width) {
w = width;
if (img->orientation == ORIENTATION_TOPLEFT)
- lrectwrite(x, y-(h-1), w-1, y, raster-x-(h-1)*w);
+ lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
else
- lrectwrite(x, y, w-1, y+h-1, raster);
+ lrectwrite(0, y, w-1, y+h-1, raster);
}
}
@@ -938,6 +943,7 @@ setupColormapSupport(TIFFRGBAImage* img)
} else if (img->isContig) {
switch (img->photometric) {
case PHOTOMETRIC_RGB:
+ case PHOTOMETRIC_LOGLUV:
switch (bitspersample) {
case 8: img->put.contig = putcontig8bittile; break;
case 16: img->put.contig = putcontig16bittile; break;
diff --git a/tools/sgisv.c b/tools/sgisv.c
index 3b14ff11..3fd937eb 100644
--- a/tools/sgisv.c
+++ b/tools/sgisv.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/sgisv.c,v 1.25 1996/01/10 19:35:33 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/sgisv.c,v 1.26 1997/08/29 21:46:50 sam Exp $ */
/*
- * Copyright (c) 1990-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/thumbnail.c b/tools/thumbnail.c
index a5f72cdb..d55c5f1b 100644
--- a/tools/thumbnail.c
+++ b/tools/thumbnail.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/thumbnail.c,v 1.11 1996/01/10 19:35:33 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/thumbnail.c,v 1.12 1997/08/29 21:46:50 sam Exp $ */
/*
- * Copyright (c) 1994-1996 Sam Leffler
- * Copyright (c) 1994-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1994-1997 Sam Leffler
+ * Copyright (c) 1994-1997 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
diff --git a/tools/tiff2bw.c b/tools/tiff2bw.c
index c0f0945c..3455f5c8 100644
--- a/tools/tiff2bw.c
+++ b/tools/tiff2bw.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiff2bw.c,v 1.21 1996/01/10 19:35:34 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiff2bw.c,v 1.22 1997/08/29 21:46:50 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c
index 2ceab788..b0f0d032 100644
--- a/tools/tiff2ps.c
+++ b/tools/tiff2ps.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiff2ps.c,v 1.51 1997/02/20 20:15:03 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiff2ps.c,v 1.53 1997/08/29 21:46:51 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -174,15 +174,6 @@ static int alpha;
static int
checkImage(TIFF* tif)
{
- switch (bitspersample) {
- case 1: case 2:
- case 4: case 8:
- break;
- default:
- TIFFError(filename, "Can not handle %d-bit/sample image",
- bitspersample);
- return (0);
- }
switch (photometric) {
case PHOTOMETRIC_YCBCR:
if (compression == COMPRESSION_JPEG &&
@@ -212,6 +203,23 @@ checkImage(TIFF* tif)
case PHOTOMETRIC_MINISBLACK:
case PHOTOMETRIC_MINISWHITE:
break;
+ case PHOTOMETRIC_LOGL:
+ case PHOTOMETRIC_LOGLUV:
+ if (compression != COMPRESSION_SGILOG &&
+ compression != COMPRESSION_SGILOG24) {
+ TIFFError(filename,
+ "Can not handle %s data with compression other than SGILog",
+ (photometric == PHOTOMETRIC_LOGL) ?
+ "LogL" : "LogLuv"
+ );
+ return (0);
+ }
+ /* rely on library to convert to RGB/greyscale */
+ TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT);
+ photometric = (photometric == PHOTOMETRIC_LOGL) ?
+ PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB;
+ bitspersample = 8;
+ break;
case PHOTOMETRIC_CIELAB:
/* fall thru... */
default:
@@ -220,6 +228,15 @@ checkImage(TIFF* tif)
photometric);
return (0);
}
+ switch (bitspersample) {
+ case 1: case 2:
+ case 4: case 8:
+ break;
+ default:
+ TIFFError(filename, "Can not handle %d-bit/sample image",
+ bitspersample);
+ return (0);
+ }
if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0)
TIFFWarning(filename, "Ignoring extra samples");
return (1);
@@ -336,7 +353,6 @@ TIFF2PS(FILE* fd, TIFF* tif, float pw, float ph)
setupPageState(tif, &w, &h, &prw, &prh);
if (!npages)
PSHead(fd, tif, w, h, prw, prh, ox, oy);
- tf_bytesperrow = TIFFScanlineSize(tif);
TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE,
&bitspersample);
TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL,
@@ -362,6 +378,7 @@ TIFF2PS(FILE* fd, TIFF* tif, float pw, float ph)
}
}
if (checkImage(tif)) {
+ tf_bytesperrow = TIFFScanlineSize(tif);
npages++;
fprintf(fd, "%%%%Page: %d %d\n", npages, npages);
fprintf(fd, "gsave\n");
@@ -688,7 +705,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
use_rawdata = TRUE;
switch (compression) {
- case COMPRESSION_NONE: /* 1: uncompressed */
+ case COMPRESSION_NONE: /* 1: uncompressed */
break;
case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */
case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */
@@ -746,12 +763,12 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
}
fputs(" /LZWDecode filter", fd);
break;
- case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */
+ case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */
fputs(" /RunLengthDecode filter", fd);
use_rawdata = TRUE;
break;
- case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */
- case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */
+ case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */
+ case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */
#ifdef notdef
/*
* Code not tested yet
@@ -769,6 +786,10 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
case COMPRESSION_JBIG: /* 34661: ISO JBIG */
use_rawdata = FALSE;
break;
+ case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */
+ case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */
+ use_rawdata = FALSE;
+ break;
default:
/*
* ERROR...
diff --git a/tools/tiffcmp.c b/tools/tiffcmp.c
index 570611ab..81b84e3d 100644
--- a/tools/tiffcmp.c
+++ b/tools/tiffcmp.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffcmp.c,v 1.29 1996/01/10 19:35:36 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffcmp.c,v 1.30 1997/08/29 21:46:51 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index ef155698..fc9ea4b8 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffcp.c,v 1.51 1996/12/13 05:22:37 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffcp.c,v 1.54 1997/09/01 03:22:05 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -205,11 +205,11 @@ processG3Options(char* cp)
static int
processCompressOptions(char* opt)
{
- if (streq(opt, "none"))
+ if (streq(opt, "none")) {
defcompression = COMPRESSION_NONE;
- else if (streq(opt, "packbits"))
+ } else if (streq(opt, "packbits")) {
defcompression = COMPRESSION_PACKBITS;
- else if (strneq(opt, "jpeg", 4)) {
+ } else if (strneq(opt, "jpeg", 4)) {
char* cp = strchr(opt, ':');
if (cp && isdigit(cp[1]))
quality = atoi(cp+1);
@@ -219,9 +219,9 @@ processCompressOptions(char* opt)
} else if (strneq(opt, "g3", 2)) {
processG3Options(opt);
defcompression = COMPRESSION_CCITTFAX3;
- } else if (streq(opt, "g4"))
+ } else if (streq(opt, "g4")) {
defcompression = COMPRESSION_CCITTFAX4;
- else if (strneq(opt, "lzw", 3)) {
+ } else if (strneq(opt, "lzw", 3)) {
char* cp = strchr(opt, ':');
if (cp)
defpredictor = atoi(cp+1);
@@ -410,6 +410,7 @@ static struct cpTag {
{ TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT },
{ TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE },
{ TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE },
+ { TIFFTAG_STONITS, 1, TIFF_DOUBLE },
};
#define NTAGS (sizeof (tags) / sizeof (tags[0]))
@@ -430,19 +431,23 @@ tiffcp(TIFF* in, TIFF* out)
CopyField(TIFFTAG_IMAGEWIDTH, w);
CopyField(TIFFTAG_IMAGELENGTH, l);
CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample);
+ CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
if (compression != (uint16)-1)
TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
else
CopyField(TIFFTAG_COMPRESSION, compression);
if (compression == COMPRESSION_JPEG && jpegcolormode == JPEGCOLORMODE_RGB)
TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);
+ else if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24)
+ TIFFSetField(out, TIFFTAG_PHOTOMETRIC,
+ samplesperpixel == 1 ?
+ PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV);
else
CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT);
if (fillorder != 0)
TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
else
CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT);
- CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
/*
* Choose tiles/strip for the output image according to
* the command line arguments (-tiles, -strips) and the
@@ -882,35 +887,44 @@ done:
DECLAREwriteFunc(writeBufferToContigStrips)
{
- tsize_t scanline = TIFFScanlineSize(out);
- uint32 row;
+ uint32 row, rowsperstrip;
+ tstrip_t strip = 0;
(void) imagewidth; (void) spp;
- for (row = 0; row < imagelength; row++) {
- if (TIFFWriteScanline(out, buf, row, 0) < 0)
+ (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
+ for (row = 0; row < imagelength; row += rowsperstrip) {
+ uint32 nrows = (row+rowsperstrip > imagelength) ?
+ imagelength-row : rowsperstrip;
+ tsize_t stripsize = TIFFVStripSize(out, nrows);
+ if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0)
return (FALSE);
- buf += scanline;
+ row += rowsperstrip, buf += stripsize;
}
return (TRUE);
}
DECLAREwriteFunc(writeBufferToSeparateStrips)
{
- tdata_t obuf = _TIFFmalloc(TIFFScanlineSize(out));
+ uint32 rowsize = imagewidth * spp;
+ uint32 rowsperstrip;
+ tdata_t obuf = _TIFFmalloc(TIFFStripSize(out));
+ tstrip_t strip = 0;
tsample_t s;
if (obuf == NULL)
return (0);
+ (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
for (s = 0; s < spp; s++) {
uint32 row;
- for (row = 0; row < imagelength; row++) {
- uint8* inp = ((uint8*) buf) + s;
- uint8* outp = (uint8*) obuf;
- uint32 n = imagewidth;
-
- while (n-- > 0)
- *outp++ = *inp, inp += spp;
- if (TIFFWriteScanline(out, obuf, row, s) < 0) {
+ for (row = 0; row < imagelength; row += rowsperstrip) {
+ uint32 nrows = (row+rowsperstrip > imagelength) ?
+ imagelength-row : rowsperstrip;
+ tsize_t stripsize = TIFFVStripSize(out, nrows);
+
+ cpContigBufToSeparateBuf(
+ obuf, (uint8*) buf + row*rowsize + s,
+ nrows, imagewidth, 0, 0, spp);
+ if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) {
_TIFFfree(obuf);
return (FALSE);
}
@@ -970,7 +984,8 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
{
uint32 imagew = TIFFScanlineSize(out);
tsize_t tilew = TIFFTileRowSize(out);
- int iskew = imagew - tilew;
+ uint32 iimagew = TIFFRasterScanlineSize(out);
+ int iskew = iimagew - tilew*spp;
tdata_t obuf = _TIFFmalloc(TIFFTileSize(out));
uint8* bufp = (uint8*) buf;
uint32 tl, tw;
@@ -997,12 +1012,12 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
int oskew = tilew - width;
cpContigBufToSeparateBuf(obuf,
- bufp + colb + s,
+ bufp + (colb*spp) + s,
nrow, width,
- oskew/spp, oskew + imagew, spp);
+ oskew, (oskew*spp)+iskew, spp);
} else
cpContigBufToSeparateBuf(obuf,
- bufp + colb + s,
+ bufp + (colb*spp) + s,
nrow, tilewidth,
0, iskew, spp);
if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) {
@@ -1012,7 +1027,7 @@ DECLAREwriteFunc(writeBufferToSeparateTiles)
}
colb += tilew;
}
- bufp += nrow * imagew;
+ bufp += nrow * iimagew;
}
_TIFFfree(obuf);
return (TRUE);
diff --git a/tools/tiffdither.c b/tools/tiffdither.c
index cf1e671f..524de264 100644
--- a/tools/tiffdither.c
+++ b/tools/tiffdither.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffdither.c,v 1.26 1996/01/10 19:35:37 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffdither.c,v 1.27 1997/08/29 21:46:52 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/tiffdump.c b/tools/tiffdump.c
index 883d87d9..3ff9f595 100644
--- a/tools/tiffdump.c
+++ b/tools/tiffdump.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffdump.c,v 1.51 1996/12/13 04:47:56 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffdump.c,v 1.53 1997/08/29 21:46:53 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
@@ -318,6 +318,7 @@ ReadDirectory(int fd, unsigned ix, uint32 off)
space = dp->tdir_count * datawidth[dp->tdir_type];
if (space <= 4) {
switch (dp->tdir_type) {
+ case TIFF_FLOAT:
case TIFF_UNDEFINED:
case TIFF_ASCII: {
unsigned char data[4];
@@ -464,6 +465,7 @@ static struct tagname {
{ TIFFTAG_COPYRIGHT, "Copyright" },
{ TIFFTAG_ICCPROFILE, "ICC Profile" },
{ TIFFTAG_JBIGOPTIONS, "JBIG Options" },
+ { TIFFTAG_STONITS, "StoNits" },
};
#define NTAGS (sizeof (tagnames) / sizeof (tagnames[0]))
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c
index 3a30909e..01e66d83 100644
--- a/tools/tiffinfo.c
+++ b/tools/tiffinfo.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffinfo.c,v 1.27 1997/01/27 22:54:52 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffinfo.c,v 1.28 1997/08/29 21:46:54 sam Exp $ */
/*
- * Copyright (c) 1988-1996 Sam Leffler
- * Copyright (c) 1991-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1988-1997 Sam Leffler
+ * Copyright (c) 1991-1997 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
diff --git a/tools/tiffmedian.c b/tools/tiffmedian.c
index 967bb185..31eaca47 100644
--- a/tools/tiffmedian.c
+++ b/tools/tiffmedian.c
@@ -1,4 +1,4 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffmedian.c,v 1.18 1995/10/10 00:35:22 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffmedian.c,v 1.19 1997/08/29 22:35:33 sam Exp $ */
/*
* Apply median cut on an image.
@@ -806,10 +806,11 @@ quant_fsdither(TIFF* in, TIFF* out)
outline = (unsigned char *) _TIFFmalloc(TIFFScanlineSize(out));
GetInputLine(in, 0, goto bad); /* get first line */
- for (i = 1; i < imagelength; ++i) {
+ for (i = 1; i <= imagelength; ++i) {
SWAP(short *, thisline, nextline);
- lastline = (i == imax);
- GetInputLine(in, i, break);
+ lastline = (i >= imax);
+ if (i <= imax)
+ GetInputLine(in, i, break);
thisptr = thisline;
nextptr = nextline;
outptr = outline;
diff --git a/tools/tiffsplit.c b/tools/tiffsplit.c
index 48baf8ec..6bdd5215 100644
--- a/tools/tiffsplit.c
+++ b/tools/tiffsplit.c
@@ -1,8 +1,8 @@
-/* $Header: /usr/people/sam/tiff/tools/RCS/tiffsplit.c,v 1.13 1996/01/10 19:35:40 sam Exp $ */
+/* $Header: /d1/sam/tiff/tools/RCS/tiffsplit.c,v 1.14 1997/08/29 21:46:55 sam Exp $ */
/*
- * Copyright (c) 1992-1996 Sam Leffler
- * Copyright (c) 1992-1996 Silicon Graphics, Inc.
+ * Copyright (c) 1992-1997 Sam Leffler
+ * Copyright (c) 1992-1997 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