tiff-v3.4beta018/configure000555 004341 000024 00000112047 06003062723 015263 0ustar00samuser000000 000000 #!/bin/sh # $Header: /usr/people/sam/tiff/RCS/configure,v 1.15 1995/07/17 14:57:08 sam Exp $ # # Tag Image File Format (TIFF) Software # # Copyright (c) 1988-1995 Sam Leffler # Copyright (c) 1991-1995 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. # # Configuration script for the TIFF Software # # Shell script to setup machine-dependent files in # preparation for building TIFF source. # # # Setup general configuration parameters. # DIR_BIN=/usr/local/bin DIR_LIB=/usr/local/lib DIR_INC=/usr/local/include DIR_HTML=/var/httpd/htdocs/tiff DIR_CGI=/var/httpd/cgi-bin DIR_JPEG=. DIR_LIBGZ=. HTMLPATH=/tiff CGIPATH=/cgi-bin DSO=auto HTML=no JPEG=no ZIP=no PORT=auto LIBGL=auto LIBIMAGE=auto MACHDEPLIBS=-lm : ${MAKE=make} # make to use # screws up the test of `-f -' unset MAKEFLAGS RM="rm -f" POSIXLY_CORRECT=1; export POSIXLY_CORRECT # disable GNU extensions # # Error diagnostics that should go to the terminal are # done with this interface (or cat). # bitch() { echo "configure: $@" 1>&2 } # # This is the preferred interface for # configure to terminate abnormally. # boom() { bitch "" bitch "Unrecoverable error! Once you've corrected the problem rerun this script." kill -1 $$ # use kill so trap handler is called } usage() { cat<<'EOF' Usage: configure [options] [host] Options: [defaults in brackets after descriptions] --help print this message --quiet do not print `Using ...' messages --verbose opposite of --quiet --version print the version of autoconf that created configure --target=TARGET configure for TARGET [TARGET=HOST] --srcdir=DIR find the sources in DIR [configure dir or ..] --with-PARAM[=ARG] set configuration PARAM [ARG=yes] EOF } QUIET=no SITE= TARGET= SRCDIR= # # Crack command line arguments. We purposely # use syntax and options that are compatible # with GNU autoconf. # ac_prev= for ac_option do if [ -n "$ac_prev" ]; then # assign the argument to previous option eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in # collect optional argument -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'`;; *) ac_optarg=;; esac case "$ac_option" in -with-*|--with-*) ac_with=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if [ -n "`echo $ac_with| sed 's/[-_a-zA-Z0-9]//g'`" ]; then bitch "configure: $ac_with: invalid parameter name." kill -1 $$ fi ac_with=`echo $ac_with| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes;; esac eval "${ac_with}='$ac_optarg'" ;; -quiet|--quiet) QUIET=yes;; -verbose|--verbose) QUIET=no;; -site|--site) ac_prev=SITE;; -site=*|--site=*) SITE="$ac_optarg";; -srcdir|--srcdir) ac_prev=SRCDIR;; -srcdir=*|--srcdir=*) SRCDIR="$ac_optarg";; -target|--target) ac_prev=TARGET;; -target=*|--target=*) TARGET="$ac_optarg" ;; -version|--version) echo "This is TIFF configure $Revision: 1.15 $" exit 0 ;; -help|--help) usage; exit 0;; -*) bitch "configure: $ac_option: invalid option; use -help for usage." kill -1 $$ ;; *) if [ x"$TARGET" != x ]; then bitch "configure: Can only configure for one target at a time." kill -1 $$ fi TARGET="$ac_option" ;; esac done if [ -n "$ac_prev" ]; then bitch "configure: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" kill -1 $$ fi # # Locate source directory by looking for the VERSION file. # The directory must either be specified through the # environment or be located in the current directory or a # parent of the current directory. # test "$SRCDIR" || { configure=$0 # NB: don't use dirname since it may not exist SRCDIR=`echo $configure | sed 's;/[^/][^/]*$;;'` if [ @"$SRCDIR" = @"$configure" ]; then SRCDIR=. fi while [ ! -r $SRCDIR/VERSION ]; do # strip last directory from pathname newdir=`echo $SRCDIR | sed 's;/[^/]*$;;'` if [ -z "$newdir" ] || [ "$newdir" = $SRCDIR ]; then break; fi SRCDIR=$newdir done } if [ ! -r $SRCDIR/VERSION ]; then bitch "Can not locate sources in $SRCDIR." kill -1 $$ fi SRCDIR=`echo "$SRCDIR" | sed 's;\([^/]\)/*$;\1;'` # # Descriptor usage: # 1: ??? # 2: errors that should be seen even if we're in the background. # 3: [stdout from test runs] # 4: verbose-style messages (Using ...) # 5: compiler stderr when running tests # if [ $QUIET = yes ]; then exec 4>/dev/null # chuck messages else exec 4>&1 # messages got to stdout fi exec 5>./config.log # compiler messages and the like VERSION="v`cat $SRCDIR/VERSION``awk '{print $3}' $SRCDIR/dist/tiff.alpha`" DATE=`date` Note() { echo "$@" 1>&4 } Note "" Note "Configuring TIFF Software $VERSION." Note "" # # Read site and local configuration parameters. # if [ -f $SITE/config.site ]; then Note "Reading site-wide parameters from $SITE/config.site." . $SITE/config.site elif [ -f $SRCDIR/config.site ]; then Note "Reading site-wide parameters from $SRCDIR/config.site." . $SRCDIR/config.site fi if [ -f config.local ]; then Note "Reading local parameters from config.local." . ./config.local elif [ -f $SRCDIR/config.local ]; then Note "Reading local parameters from $SRCDIR/config.local." . $SRCDIR/config.local fi identifyTarget() { random=`date | awk '{print $4}' | sed -e 's/.*://'` 2>/dev/null case "$random" in 1*) Note "Wow, you've got a $1 system!";; 2*) Note "Hmm, looks like a $1 system.";; 3*) Note "Oh no, not another $1 system...";; 4*) Note "Well I'll be, a $1 system.";; 5*) Note "Fee, fie, foe, this smells like a $1 system.";; *) Note "Gosh, aren't you lucky to have a $1 system!";; esac } # # If no target is specified, try to deduce the system. # We use the GNU scripts for guessing and canonicalizing # the system identification, if available. # if [ -z "$TARGET" ]; then test -f $SRCDIR/config.guess && TARGET=`sh $SRCDIR/config.guess` 2>/dev/null if [ -z "$TARGET" ]; then bitch "Sorry, no target specified on the command line and I don't seem" bitch "to have the GNU config.guess script that is used to deduce your" bitch "system type." kill -1 $$ fi identifyTarget $TARGET elif [ -f $SRCDIR/config.sub ]; then TARGET=`sh $SRCDIR/config.sub "$TARGET"` else Note "Warning, I don't seem to have the GNU config.sub script to canonicalize" Note "your target specification; this may cause problems later on..." fi cat 1>&5 <xgnu.c<&5 | egrep yes >/dev/null 2>&1 } # # NB: use ANSI C prototype to weed out non-ANSI compilers. # cat>dummy.c</dev/null 2>&5 && { CC=$i; CCOMPILER=`findApp $i $PATH` if [ -z "$ENVOPTS" ]; then ENVOPTS="$C_ANSI" fi break; } done if [ -z "$CCOMPILER" ]; then cat<&5 2>&5 || return 1 fi return 0 } if [ -z "$GCOPTS" ]; then $CCOMPILER $ENVOPTS -g -c dummy.c >/dev/null 2>&5 && { Note "Looks like $CCOMPILER supports the -g option." if $CCOMPILER $ENVOPTS $GCOPTS -c -g -O dummy.c >t 2>&1 && CheckForGandO t; then GCOPTS="$GCOPTS -g" else Note "... but not together with the -O option, not using it." fi } fi if [ "$GCOPTS" ]; then Note "Using \"$GCOPTS\" for C compiler options." fi # # Verify that $MAKE is accessible # PATHMAKE=`findApp ${MAKE} $PATH` if [ "$PATHMAKE" ]; then Note "Using $PATHMAKE to configure the software." (echo 'all:') | ${MAKE} -f - all >/dev/null 2>&5 || { cat<&5` if [ "$M" ]; then SETMAKE= else Note "Looks like $MAKE does not setup MAKE in Makefiles, will compensate." SETMAKE="MAKE = ${MAKE}" fi fi test "$AR" || AR=`findApp ar $PATH` if [ -z "$AR" ]; then Note "*** Warning, could not locate a suitable ar command; using a default." AR=ar fi test "$AROPTS" || AROPTS=rc test "$RANLIB" || RANLIB=`findApp ranlib $PATH` if [ -z "$RANLIB" ]; then Note "Warning, no ranlib, assuming it's not needed." RANLIB=":" $RM dummy.a if $AR rcs dummy.a; then AROPTS=crs Note "Looks like ar has an s option to build symbol tables." fi fi # # runMake target rules ... # runMake() { target="$1"; shift $RM $target (for i in "$@"; do echo "$i"; done) | ${MAKE} -f - $target 2>&5 } # # Look for a library using a known (unique) function. # CheckForLibrary() { f=$1; shift libs="$@"; cat>t.c</dev/null } # # Look for an include file. # CheckForIncludeFile() { (for i do echo "#include \"$i\"" done)>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" >/dev/null } # # Figure out if certain system-specific interfaces are # supported. We craft a port.h file that has external # declarations for missing routines that are required by # the system and modify defs to reflect which optional # interfaces are supported. # EmitCPlusPlusPrologue() { echo '/*' echo ' * Warning, this file was automatically created by the TIFF configure script' echo ' * VERSION: ' $VERSION echo ' * DATE: ' $DATE echo ' * TARGET: ' $TARGET if [ $ISGCC = yes ]; then echo ' * CCOMPILER: ' ${CCOMPILER}-${GCCversion} else echo ' * CCOMPILER: ' $CCOMPILER fi echo ' */' echo "#ifndef $1" echo "#define $1 1" echo '#ifdef __cplusplus' echo 'extern "C" {' echo '#endif' } EmitCPlusPlusEpilogue() { echo '#ifdef __cplusplus' echo '}' echo '#endif' echo '#endif' } # # Look for a function in one of the standard libraries # or one of the machine-dependent libraries selected above. # CheckForFunc() { echo "extern int $1(); main(){$1();exit(0);}" >t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c ${MACHDEPLIBS}" >/dev/null } # # Look for a function declaration in system include files. # AddFuncDecl() { echo "$2"; Note "... add function prototype for $1" } CheckForFuncDecl() { f=$1; shift (for i do echo "#include \"$i\"" done)>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" |\ awk '{while($0~/[,(][ \t]*$/){printf"%s",$0;getline}print}' |\ grep "$f[ ]*(.*)" >/dev/null return } CheckFuncDecl() { f=$1; shift decl=$1; shift CheckForFuncDecl "$f" "$@" || AddFuncDecl "$f" "$decl" } # # Look for a variable declaration in system include files. # CheckForVarDecl() { v="$1"; shift (for i do echo "#include \"$i\"" done)>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep "$v" >/dev/null return } CheckVarDecl() { v="$1"; shift decl="$1"; shift CheckForVarDecl "$v" "$@" || \ (echo "$decl"; Note "... add declaration $decl") } # # Look for a #define in system include files. # AddDefine() { echo '#ifndef' $1 echo '#define' "$2" echo '#endif' Note '... add #define for' "$1" } CheckForDefine() { def=$1; shift (for i do echo "#include \"$i\"" done echo "#ifdef $def" echo "FOUND" echo "#endif" )>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} -E t.c" | grep FOUND >/dev/null } CheckDefine() { def=$1; shift decl=$1; shift CheckForDefine "$def" "$@" || AddDefine "$def" "$decl" } CheckForMMAP() { if CheckForFunc getpagesize; then cat>t.c<<'EOF' /* this was lifted from GNU autoconf */ /* Thanks to Mike Haertel and Jim Avera for this test. */ #include #include #include EOF else cat>t.c<<'EOF' /* this was lifted from GNU autoconf */ /* Thanks to Mike Haertel and Jim Avera for this test. */ #include #include #include #ifdef BSD # ifndef BSD4_1 # define HAVE_GETPAGESIZE # endif #endif #ifndef HAVE_GETPAGESIZE # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE # else # ifdef NBPG # define getpagesize() NBPG * CLSIZE # ifndef CLSIZE # define CLSIZE 1 # endif # else # ifdef NBPC # define getpagesize() NBPC # else # define getpagesize() PAGESIZE /* SVR4 */ # endif # endif # endif #endif EOF fi cat>>t.c<<'EOF' #if defined(__osf__) || defined(_AIX) # define valloc malloc #endif char *valloc(), *malloc(); int main() { char *buf1, *buf2, *buf3; int i = getpagesize(), j; int i2 = getpagesize()*2; int fd; buf1 = (char *)valloc(i2); buf2 = (char *)valloc(i); buf3 = (char *)malloc(i2); for (j = 0; j < i2; ++j) *(buf1 + j) = rand(); fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); write(fd, buf1, i2); mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); for (j = 0; j < i; ++j) if (*(buf1 + j) != *(buf2 + j)) exit(1); lseek(fd, (long)i, 0); read(fd, buf2, i); /* read into mapped memory -- file should not change */ /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */ lseek(fd, (long)0, 0); read(fd, buf3, i2); for (j = 0; j < i2; ++j) if (*(buf1 + j) != *(buf3 + j)) exit(1); exit(0); } EOF runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c" >/dev/null } CheckForBigEndian() { echo 'main() { int one = 1; char* cp = (char*)&one; exit(*cp!=0); }'>t.c runMake t "t:; ${CCOMPILER} ${ENVOPTS} t.c" >/dev/null } # # Check an existing port.h to see if it was created # for the target and compiler we are using. # CheckPortDotH() { getConfigTag() { param=`grep "$1:" $2 | sed -e 's/.*:[ ]*\([^ ]*\).*/\1/'` } getConfigTag TARGET port.h; target="$param" getConfigTag CCOMPILER port.h; ccompiler="$param" CCOMP=$CCOMPILER if [ $ISGCC = yes ]; then getGCCVersion() { eval `$1 -v 2>&1 | \ sed -n -e '/version/s/.* \([0-9]*\)\.\([0-9]*\).\([0-9]*\)/GCCdist=\1;GCCmajor=\2;GCCminor=\3/p'` GCCversion="${GCCdist}.${GCCmajor}.${GCCminor}" } getGCCVersion $CCOMPILER CCOMP="${CCOMP}-${GCCversion}" fi test "$target" = "$TARGET" && test "$ccompiler" = "$CCOMP" } # # Built port.h based on the system and compiler setup. # BuildPortDotH() { Note "" Note "Creating port.h with necessary definitions." (EmitCPlusPlusPrologue _PORT_ CheckForIncludeFile sys/types.h && echo '#include ' CheckVarDecl mode_t 'typedef int mode_t;' sys/types.h stdlib.h CheckVarDecl off_t 'typedef long off_t;' sys/types.h stdlib.h CheckVarDecl size_t 'typedef unsigned size_t;' sys/types.h stdlib.h CheckVarDecl u_char 'typedef unsigned char u_char;' sys/types.h CheckVarDecl u_short 'typedef unsigned short u_short;' sys/types.h CheckVarDecl u_int 'typedef unsigned int u_int;' sys/types.h CheckVarDecl u_long 'typedef unsigned long u_long;' sys/types.h if [ -z "$FILLORDER" ]; then # # Host bit order within a word. # case $TARGET in mips-dec-*) FILLORDER=LSB2MSB;; i[345]86-*) FILLORDER=LSB2MSB;; *) FILLORDER=MSB2LSB;; esac fi echo "#define HOST_FILLORDER FILLORDER_${FILLORDER}" CPU=`echo $TARGET | sed 's/-.*//'` Note "... using $FILLORDER bit order for your $CPU cpu" if CheckForBigEndian; then echo "#define HOST_BIGENDIAN 1" Note "... using big-endian byte order for your $CPU cpu" else echo "#define HOST_BIGENDIAN 0" Note "... using little-endian byte order for your $CPU cpu" fi CheckForMMAP && { echo '#define HAVE_MMAP 1' Note "... configure use of mmap for memory-mapped files" CheckFuncDecl mmap \ 'extern void* mmap(void*, size_t, int, int, int, off_t);' sys/mman.h } CheckForIncludeFile stdio.h && echo '#include ' CheckForIncludeFile unistd.h && echo '#include ' CheckForIncludeFile string.h && echo '#include ' CheckForIncludeFile stdlib.h && echo '#include ' if CheckForDefine O_RDONLY fcntl.h; then echo '#include ' Note "... O_RDONLY is in " elif CheckForDefine O_RDONLY sys/file.h; then echo '#include ' Note "... O_RDONLY is in " else AddDefine O_RDONLY "O_RDONLY 0" AddDefine O_WRONLY "O_WRONLY 1" AddDefine O_RDWR "O_RDWR 2" fi echo 'typedef double dblparam_t;' Note "... using double for promoted floating point parameters" if [ -z "$INLINE" ]; then if [ $ISGCC = yes ]; then echo '#ifdef __STRICT_ANSI__' echo '#define INLINE __inline__' echo '#else' echo '#define INLINE inline' echo '#endif' Note "... enabling use of inline functions" else echo '#define INLINE' Note "... disabling use of inline functions" fi else echo "#define INLINE $INLINE" Note "... using \"$INLINE\" to control inline function usage" fi echo '#define GLOBALDATA(TYPE,NAME) extern TYPE NAME' CheckFuncDecl strcasecmp \ 'extern int strcasecmp(const char*, const char*);' string.h CheckFuncDecl memset 'extern void* memset(void*, int, size_t);' string.h CheckFuncDecl floor 'extern double floor(double);' math.h CheckFuncDecl ceil 'extern double ceil(double);' math.h CheckFuncDecl exp 'extern double exp(double);' math.h CheckFuncDecl pow 'extern double pow(double);' math.h CheckFuncDecl unlink 'extern int unlink(const char*);' unistd.h CheckFuncDecl read 'extern int read(int, const void*, unsigned int);' unistd.h CheckFuncDecl malloc 'extern void* malloc(size_t);' stdlib.h CheckFuncDecl realloc 'extern void* realloc(void*, size_t);' stdlib.h CheckFuncDecl free 'extern void free(void*);' stdlib.h CheckFuncDecl strtoul \ 'extern unsigned long strtoul(const char*, char**, int);' stdlib.h # # unistd.h is for sco3.2v4.[0-2] and GNU libc (yech!) # CheckFuncDecl getopt \ 'extern int getopt(int, char* const*, const char*);' stdlib.h unistd.h CheckVarDecl 'char.*optarg' 'extern char* optarg;' stdlib.h unistd.h CheckVarDecl 'int.*opterr' 'extern int opterr;' stdlib.h unistd.h CheckVarDecl 'int.*optind' 'extern int optind;' stdlib.h unistd.h EmitCPlusPlusEpilogue )>xport.h mv xport.h port.h; chmod 444 port.h Note "Done creating port.h." } if test -f port.h && CheckPortDotH; then Note "" Note "Using previously created port.h." else $RM xport.h t.c a.out port.h BuildPortDotH fi Note "" Note "Checking system libraries for functionality to emulate." FUNCS=" strcasecmp strtoul getopt " for i in $FUNCS; do CheckForFunc $i || { Note "... emulate $i" PORTFUNCS="$PORTFUNCS $i.c" } done if [ "$PORTFUNCS" ]; then LIBPORT='${PORT}/libport.a' PORT=yes else PORT=no fi Note "Done checking system libraries." Note "" Note "Checking for Dynamic Shared Object (DSO) support." if [ "$DSO" = auto ]; then case $TARGET in *-irix*) if (findApp rld /lib:/usr/lib:$PATH) >/dev/null 2>&1; then DSOSUF=so DSOOPTS='-shared -rdata_shared -check_registry ${SRCDIR}/${PORT}/irix/so_locations -quickstart_info' fi ;; *) DSO=no;; esac fi if [ "$DSO" != no ]; then JUNK="$JUNK t.${DSOSUF}" # # Check to make sure the compilers process # the DSO options in the expected way. # CheckCCDSO() { $RM t.c t.o t.${DSOSUF} cat>t.c</dev/null } if CheckCCDSO; then Note "Looks like your system supports SVR4-style DSOs." DSO=yes else cat 1>&4 <t.c if mv -f t.c t.o; then Note "Looks like mv supports the -f option to force a move." MV_F=-f else Note "Warning, looks like mv has no -f option to force move operations;" Note "... this may cause problems during installation." MV_F= fi fi # # Check if ln -s creates a symbolic link. # if [ -z "$LN_S" ]; then $RM t.c; $LN -s foo t.c && LN_S=-s fi if [ -n "$LN_S" ]; then Note "Looks like $LN supports the -s option to create a symbolic link." else Note "Warning, looks like $LN has no -s option to create symbolic links;" Note "... this may cause problems during installation." fi # # Pick install mechanism. # if [ -z "$INSTALL" ]; then case $TARGET in *-irix*) INSTALL=`findApp install /sbin:$PATH`;; *) INSTALL='${SHELL} ${PORT}/install.sh';; esac fi Note "Done selecting programs." # # User-changable configuration parameters section. # Anything selected here is presented to the user # and may be interactively changed. # Note "" Note "Selecting default TIFF configuration parameters." Note "" # # Fill in any other configuration parameters not # setup in the site and local files. # bitchExecutable() { echo "" echo "Warning, $1 does not seem to be an executable program;" echo "you'll need to correct this before starting up the fax server." echo "" } # # Setup manual page-related stuff. # # Manual pages are processed according to: # 1. Section organization (BSD or System V) # 2. Pre-formatted (w/ nroff) or source. # 3. Compressed (compress, gzip, pack) or uncompressed. # 4. Whether or not the FlexFAX ``F'' suffix must be # stripped for pages to be found (only for 4F pages). # if [ -z "$DIR_MAN" ]; then MANPATH=" $MANPATH /usr/local/man /usr/contrib/man /usr/catman/local " DIR_MAN= for i in $MANPATH; do test -d $i && { DIR_MAN=$i; break; } done test -z "$DIR_MAN" && DIR_MAN=/usr/local/man fi Note "Looks like manual pages go in $DIR_MAN." if [ -z "$MANSCHEME" ]; then case $TARGET in *-bsdi*|*-netbsd*) MANSCHEME=bsd-nroff-gzip-0.gz;; *-freebsd*) MANSCHEME=bsd-source-cat;; *-linux*) MANSCHEME=bsd-source-cat;; *-ultrix*) MANSCHEME=bsd-source-cat;; *-sunos*) MANSCHEME=bsd-source-cat-strip;; *-sysv[234]*) MANSCHEME=sysv-source-cat-strip;; *-hpux*) MANSCHEME=sysv-source-cat-strip;; *-solaris*) MANSCHEME=sysv-source-cat-strip;; *-aix*) MANSCHEME=sysv-source-strip;; *-isc*|*-sco*) MANSCHEME=sysv-source-cat;; *-irix*) MANSCHEME=sysv-nroff-compress-Z;; *) # # Try to deduce the setup from existing manual pages. # XXX needs more work XXX # MANSCHEME=sysv-source-cat if [ -d /usr/share/man ]; then if [ -d /usr/share/man/u_man ]; then MANSCHEME=sysv-source-cat elif [ -d /usr/share/man/man8 ]; then MANSCHEME=bsd-source-cat fi elif [ -d /usr/share/catman ]; then if [ -d /usr/share/catman/u_man ]; then MANSCHEME=sysv-nroff-cat elif [ -d /usr/share/catman/man8 ]; then MANSCHEME=bsd-nroff-cat fi fi ;; esac fi Note "Looks like manual pages should be installed with $MANSCHEME." # # Figure out which brand of echo we have and define # prompt and print shell functions accordingly. # if [ `echo foo\\\c`@ = "foo@" ]; then prompt() { echo "$* \\c" } elif [ "`echo -n foo`@" = "foo@" ]; then prompt() { echo -n "$* " } else prompt() { echo "$*" } fi # # Prompt the user for a string that can not be null. # promptForNonNullStringParameter() { x="" val="$1" desc="$2" while [ -z "$x" ]; do prompt "$desc [$val]?"; read x if [ "$x" ]; then # strip leading and trailing white space x=`echo "$x" | sed -e 's/^[ ]*//' -e 's/[ ]*$//'` else x="$val" fi done param="$x" } promptForManPageScheme() { x="" while [ -z "$x" ]; do prompt "Manual page installation scheme [$MANSCHEME]?"; read x if [ "$x" ]; then # strip leading and trailing white space x=`echo "$x" | sed -e 's/^[ ]*//' -e 's/[ ]*$//'` # XXX do a better job of validating... case "$x" in bsd-nroff-cat*|sysv-nroff-cat*) ;; bsd-nroff-gzip*|sysv-nroff-gzip*) ;; bsd-nroff-comp*|sysv-nroff-comp*) ;; bsd-nroff-pack*|sysv-nroff-pack*) ;; bsd-source-cat*|sysv-source-cat*) ;; bsd-source-gzip*|sysv-source-gzip*) ;; bsd-source-comp*|sysv-source-comp*) ;; bsd-source-pack*|sysv-source-pack*) ;; *) cat <--[-] where: is either "bsd" for BSD-style section organization (e.g. file formats in section 5) or "sysv" for System V-style organization (e.g. file formats in section 4). is either "nroff" to force installation of formatted materials (using nroff) or "source" to get the nroff source installed. is either the name of a program to compress the manual pages (gipz, compress, pack) or "cat" for uncompressed data. is either the file suffix to convert installed pages to (e.g. 0.gz for gzip-compressed pages under BSD) or "strip" to force the normal ".4f" suffix to be converted to ".4" (or ".5" if using the BSD organization). If no - is specified then filenames are not converted when they are installed. Common schemes are: bsd-nroff-gzip-0.gz compressed formatted pages for BSD bsd-source-cat nroff source w/ BSD organization sysv-source-cat-strip nroff source for SysV w/o .4f suffix sysv-source-cat nroff source for SysV as-is EOF x="";; esac else x="$MANSCHEME" fi done MANSCHEME="$x" } printConfig() { cat< accepts the displayed parameters." echo "A number lets you change the numbered parameter." echo "" ;; esac ok=skip if [ "${JPEG}" = yes ]; then test -d "${DIR_JPEG}" || { cat<>confsed< $F.new $RM confx; $SED '/DATE:/d' $F.new >confx $RM confy; $SED '/DATE:/d' $F >confy 2>/dev/null if cmp -s confx confy >/dev/null 2>&1; then $RM $F.new else Note "Creating $F from $SRCDIR/$F.in" $RM $F; mv $F.new $F; $CHMOD 444 $F fi else Note "Creating $F from $SRCDIR/$F.in" if $SED -f confsed $SRCDIR/$F.in >$F.new; then $RM $F; mv $F.new $F; $CHMOD 444 $F else cat 1>&2 <$F.new failed. Aborting without cleaning up files so you can take a look... EOF exit 1 fi fi done } # # port/install.sh is the SGI install program emulator script. # CONF_FILES=" Makefile libtiff/Makefile man/Makefile tools/Makefile port/install.sh " SedConfigFiles $CONF_FILES test $PORT = yes && SedConfigFiles port/Makefile test $HTML = yes && SedConfigFiles html/Makefile # # NB: the dist directory is needed only when building SGI inst images. # test -d dist || mkdir dist Note "Done." $RM $JUNK exit 0 up files so you can take a look... EOF exit 1 fi fi done } # # port/install.sh is the SGI install program emulator script. # CONF_FILES=" Makefile libtiff/Makefile man/Makefile tools/Makefile port/install.sh " SedConfigFiles $CONF_FILES test $PORT = yes && SedConfigFiles port/Makefile test $HTML = yes && SedConfigFiles html/Makefile # # NB: the dist directory is needed only when building SGI inst images. # test -d dist || mkditiff-v3.4beta018/config.guess000555 004341 000024 00000031620 06003062724 015672 0ustar00samuser000000 000000 #!/bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # The master version of this file is at the FSF in /home/gd/gnu/lib. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit system type (host/target name). # # Only a few systems have been added to this list; please add others # (but try to keep the structure clean). # # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in alpha:OSF1:V*:*) # After 1.2, OSF1 uses "V1.3" for uname -r. echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` exit 0 ;; alpha:OSF1:*:*) # 1.2 uses "1.2" for uname -r. echo alpha-dec-osf${UNAME_RELEASE} exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; Pyramid*:OSx*:*:*) if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; sun4*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; mips:*:5*:RISCos) echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix${UNAME_RELEASE} exit 0 ;; i[34]86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:4) if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if grep bos410 /usr/include/stdio.h >/dev/null 2>&1; then IBM_REV=4.1 elif grep bos411 /usr/include/stdio.h >/dev/null 2>&1; then IBM_REV=4.1.1 else IBM_REV=4.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[3478]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/7?? | 9000/8?7 ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?7:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; hp7??:OSF1:*:* | hp8?7:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:UNICOS:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:UNICOS:*:*) echo ymp-cray-unicos exit 0 ;; CRAY-2:UNICOS:*:*) echo cray2-cray-unicos exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; i[34]86:BSD/386:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; i[34]86:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux exit 0 ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. i[34]86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; i[34]86:*:3.2:*) if /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL elif test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M680[234]0:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0) uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3 && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m680[234]0:LynxOS:2.2*:*) echo m68k-lynx-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i[34]86:LynxOS:2.2*:*) echo i386-lynx-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.2*:*) echo sparc-lynx-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.2*:*) echo rs6000-lynx-lynxos${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c </dev/null`; printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3"); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-unknown-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) printf ("vax-dec-bsd\n"); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi #echo '(Unable to guess system type)' 1>&2 exit 1 { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -xtiff-v3.4beta018/config.sub000555 004341 000024 00000037676 06003062724 015356 0ustar00samuser000000 000000 #!/bin/sh # Configuration validation subroutine script, version 1.1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # It is wrong to echo any other type of specification. # First pass through any local machine types. case $1 in *local*) echo $1 exit 0 ;; *) ;; esac # Separate what the user gave into CPU-COMPANY and OS (if any). basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp ) os= basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'` ;; -lynx) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. tahoe | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm | pyramid \ | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \ | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \ | powerpc | sparc64 | 1750a | dsp16xx | mips64 | mipsel \ | pdp11 | mips64el | mips64orion | mips64orionel ) basic_machine=$basic_machine-unknown ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. vax-* | tahoe-* | i[345]86-* | i860-* | m68k-* | m68000-* | m88k-* \ | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ | pdp11-* | sh-* | powerpc-* | sparc64-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* ) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-cbm ;; amigados) basic_machine=m68k-cbm os=-amigados ;; amigaunix | amix) basic_machine=m68k-cbm os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; i370-ibm* | ibm*) basic_machine=i370-ibm os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i[345]86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv32 ;; i[345]86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv4 ;; i[345]86v) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-sysv ;; i[345]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'` os=-solaris2 ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; miniframe) basic_machine=m68000-convergent ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; np1) basic_machine=np1-gould ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium-*) # We will change tis to say i586 once there has been # time for various packages to start to recognize that. basic_machine=i486-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; ps2) basic_machine=i386-ibm ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; symmetry) basic_machine=i386-sequent os=-dynix ;; tower | tower-32) basic_machine=m68k-ncr ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. mips) basic_machine=mips-mips ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sparc) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative must end in a *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[345]* \ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigados* | -msdos* | -newsos* | -unicos* | -aos* \ | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \ | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -winnt*) ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -ctix* | -uts*) os=-sysv ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -xenix) os=-xenix ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-ibm) os=-aix ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigados ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-masscomp) os=-rtu ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -lynxos*) vendor=lynx ;; -aix*) vendor=ibm ;; -hpux*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs*) vendor=ibm ;; -ptx*) vendor=sequent ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os riscix*) vendor=acorn ;; -sunos*) vendor=sun ;;tiff-v3.4beta018/config.site000444 004341 000024 00000012273 06003062725 015511 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/RCS/config.site,v 1.5 1995/07/17 14:53:35 sam Exp $ # # TIFF Software # # Copyright (c) 1990-1995 Sam Leffler # Copyright (c) 1991-1995 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 file holds site-specific configuration parameters. # # Nothing is defined in here by default, the definitions # commented out below serve as documentation for what you # can set in this file or a config.local file. # # Note that you do not need to set anything here unless you # want to override the auto-configuration behaviour and/or # interactive prompting done by the configure script. # # # Package controls. # #DSO="auto" # yes|no|auto configure DSO support #HTML="no" # yes|no configure HTML documentation #JPEG="no" # yes|no configure JPEG support #ZIP="no" # yes|no configure Deflate support #LIBGL="auto" # yes|no|auto configure IRIS GL-based tools #LIBIMAGE="auto" # yes|no|auto configure SGI RGB image tools # # Directory parameters. # #DIR_BIN="/usr/local/bin" # directory for tools #DIR_LIB="/usr/local/lib" # directory for libraries #DIR_INC="/usr/local/include" # directory for include files #DIR_MAN="/usr/local/man" # directory for manual pages # # JPEG-specific parameters; used when JPEG support is enabled. # # NB: JPEG support requires release 5 or later of the IJG code, # which you can find on the Internet at ftp.uu.net:/graphics/jpeg/. # #DIR_JPEG="../jpeg" # directory for JPEG include files #LIBJPEG="-L \${JPEGDIR} -ljpeg" # JPEG library to load # # Deflate-specific parameters; used when Deflate support is enabled. # # NB: Deflate support requires version 0.92 or later of the libgz # library written by Jean-loup Gailly and Mark Adler. The library # was last found at ftp://ftp.uu.net/graphics/png/code/zlib-0.93.tar.gz. # #DIR_LIBGZ="../zlib" # directory for libgz include files #LIBGZ="-L \${ZIPDIR} -lgz" # libgz library to load # # HTML-specific parameters; only used when the # HTML package is configured for installation. # # Note that ``PATH''s are the virtual pathnames used # in forming URLs; they are not directory pathnames # in the filesystem. # #DIR_HTML="/var/httpd/htdocs/tiff" # directory for HTML documentation #DIR_CGI="/var/httpd/cgi-bin" # directory for CGI scripts #HTMLPATH="/tiff" # virtual path to HTML materials #CGIPATH="/cgi-bin" # virtual path to CGI scripts # # Miscellaneous parameters. # #FILLORDER="MS2LSB" # bit order of cpu (MSB2LSB/LSB2MSB) #MANSCHEME="sysv-source-cat-strip" # manual page installation scheme # # Parameters used when building the software. # # Note that configure has several ENVOPTS built into it that are # set according to the target. This is done to help naive folks. # # Beware of changing the INSTALL definition; you *must* have an # install script that emulates the Silicon Graphics install program! # #AR="/bin/ar" # pathname of suitable ar program #AROPTS="rc" # options to ar for creating archive #CC="gcc" # name/pathname of C compiler #ENVOPTS="-Aa" # options for getting ANSI C #GCOPTS="-g" # options to pass C compiler #LIBPORT='${PORT}/libport.a' # library with emulation code #MACHDEPLIBS="" # extra libraries for linking #PORTFUNCS="" # non-standard functions to emulate #RANLIB=":" # pathname of suitable ranlib program # # Dynamic Shared Object (DSO) support. # # Beware that adding new support for DSOs may require some # modifications to the */Makefile.dso files. # #DSOSUF="so" # DSO filename suffix #DSOOPTS="-shared -rdata_shared" # options for building DSOs # # Makefile construction parameters. # # These should not normally be set; configure will # deduce the appropriate syntax to use for includes. # #SETMAKE='MAKE = ${MAKE}' # define if make does not setup $MAKE # # General system stuff used by the distribution. # #CHMOD="/etc/chmod" # pathname of suitable chmod program #INSTALL='${SHELL} ${PORT}/install.sh' # SGI install program/emulator #LN="/bin/ln" # pathname of suitable ln program #LN_S="-s" # option to ${LN} to create symlink #MV_F="-f" # option to ${MV} to force operation #SED="/bin/sed" # pathname of suitable sed program #STRIP="/bin/strip" # strip program used by install.sh #SETMAKE='MAKE = ${MAKE}' # define if make does not setup $MAKE # # General system stuff used by the distribution. # #CHMOD="/etc/chmod" # pathname of suitable chmod program #INSTALL='${SHELL} ${PORT}/install.sh' # SGI install program/emulator #LN="/bin/ln" # pathname of suitable ln program #LN_S="-s" # option totiff-v3.4beta018/Makefile.in000444 004341 000024 00000026440 06003062725 015424 0ustar00samuser000000 000000 #! smake # $Header: /usr/people/sam/tiff/RCS/Makefile.in,v 1.25 1995/07/19 01:53:48 sam Exp $ # # @WARNING@ # # Tag Image File Format Library # # Copyright (c) 1988-1995 Sam Leffler # Copyright (c) 1991-1995 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. # DEPTH = . SRCDIR = ${DEPTH}/@SRCDIR@ # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # CXXCOMPILER: @CXXCOMPILER@ # @SETMAKE@ SHELL = /bin/sh NULL = ECHO = echo all default: @if [ "@PORT@" = yes ]; then \ ${ECHO} "= "port; cd port; ${MAKE}; \ fi @${ECHO} "= "libtiff; cd libtiff; ${MAKE} @${ECHO} "= "tools; cd tools; ${MAKE} @${ECHO} "= "man; cd man; ${MAKE} @if [ "@HTML@" = yes ]; then \ ${ECHO} "= "html; cd html; ${MAKE}; \ fi install: @${ECHO} "= "libtiff; cd libtiff; ${MAKE} install @${ECHO} "= "tools; cd tools; ${MAKE} install @${ECHO} "= "man; cd man; ${MAKE} install @if [ "@HTML@" = yes ]; then \ ${ECHO} "= "html; cd html; ${MAKE} install; \ fi clean: @if [ "@PORT@" = yes ]; then \ ${ECHO} "= "port; cd port; ${MAKE} clean; \ fi @${ECHO} "= "libtiff; cd libtiff; ${MAKE} clean @${ECHO} "= "tools; cd tools; ${MAKE} clean @${ECHO} "= "man; cd man; ${MAKE} clean @if [ "@HTML@" = yes ]; then \ ${ECHO} "= "html; cd html; ${MAKE} clean; \ fi # -cd contrib/dbs; ${MAKE} clean # -cd contrib/dbs/xtiff; ${MAKE} clean clobber distclean: clean rm -f Makefile port.h config.log rm -f libtiff/Makefile rm -f tools/Makefile rm -f man/Makefile rm -f port/Makefile port/install.sh # # The folllowing rule creates a binary distribution for IRIX. # product:: rm -f dist/rawidb SRC=`pwd` RAWIDB=`pwd`/dist/rawidb ${MAKE} install rm -f dist/idb sort -u +4 dist/rawidb > dist/idb gendist -v -dist dist -idb dist/idb -sbase `pwd` -spec ${SRCDIR}/dist/tiff.spec # # These rules are used to create the source distribution images # HOST = sgi COMPRESS= gzip ZIPSUF = gz TIFFFILES=\ configure \ config.guess \ config.sub \ config.site \ Makefile.in \ README \ VERSION \ COPYRIGHT \ TODO \ dist/tiff.spec \ dist/newalpha \ dist/newversion \ libtiff/Makefile.in \ libtiff/Makefile.lcc \ libtiff/Makefile.msc \ libtiff/t4.h \ libtiff/tiff.h \ libtiff/tiffcomp.h \ libtiff/tiffconf.h \ libtiff/tiffio.h \ libtiff/tiffiop.h \ libtiff/mkg3states.c \ libtiff/mkspans.c \ libtiff/tif_apple.c \ libtiff/tif_atari.c \ libtiff/tif_aux.c \ libtiff/tif_close.c \ libtiff/tif_codec.c \ libtiff/tif_compress.c \ libtiff/tif_dir.h \ libtiff/tif_dir.c \ libtiff/tif_dirinfo.c \ libtiff/tif_dirread.c \ libtiff/tif_dirwrite.c \ libtiff/tif_dumpmode.c \ libtiff/tif_error.c \ libtiff/tif_fax3.c \ libtiff/tif_fax3.h \ libtiff/tif_flush.c \ libtiff/tif_getimage.c \ libtiff/tif_jpeg.c \ libtiff/tif_lzw.c \ libtiff/tif_msdos.c \ libtiff/tif_next.c \ libtiff/tif_open.c \ libtiff/tif_packbits.c \ libtiff/tif_predict.h \ libtiff/tif_predict.c \ libtiff/tif_print.c \ libtiff/tif_read.c \ libtiff/tif_strip.c \ libtiff/tif_swab.c \ libtiff/tif_thunder.c \ libtiff/tif_tile.c \ libtiff/tif_unix.c \ libtiff/tif_version.c \ libtiff/tif_vms.c \ libtiff/tif_warning.c \ libtiff/tif_win3.c \ libtiff/tif_write.c \ libtiff/tif_zip.c \ port/Makefile.in \ port/getopt.c \ port/install.sh.in \ port/irix/so_locations \ port/strcasecmp.c \ port/strtoul.c \ tools/Makefile.in \ tools/Makefile.lcc \ tools/fax2tiff.c \ tools/fax2ps.c \ tools/gif2tiff.c \ tools/pal2rgb.c \ tools/ppm2tiff.c \ tools/ras2tiff.c \ tools/rasterfile.h \ tools/rgb2ycbcr.c \ tools/sgi2tiff.c \ tools/sgigt.c \ tools/sgisv.c \ tools/thumbnail.c \ tools/tiff2bw.c \ tools/tiff2ps.c \ tools/tiffcmp.c \ tools/tiffcp.c \ tools/tiffdither.c \ tools/tiffdump.c \ tools/tiffinfo.c \ tools/tiffmedian.c \ tools/tiffsplit.c \ tools/ycbcr.c \ man/Makefile.in \ man/fax2tiff.1 \ man/fax2ps.1 \ man/gif2tiff.1 \ man/pal2rgb.1 \ man/ppm2tiff.1 \ man/ras2tiff.1 \ man/rgb2ycbcr.1 \ man/sgi2tiff.1 \ man/thumbnail.1 \ man/tiff2bw.1 \ man/tiff2ps.1 \ man/tiffcmp.1 \ man/tiffcp.1 \ man/tiffdither.1 \ man/tiffdump.1 \ man/tiffgt.1 \ man/tiffinfo.1 \ man/tiffmedian.1 \ man/tiffsplit.1 \ man/tiffsv.1 \ man/TIFFClose.3t \ man/TIFFError.3t \ man/TIFFFlush.3t \ man/TIFFGetField.3t \ man/TIFFOpen.3t \ man/TIFFPrintDirectory.3t \ man/TIFFReadDirectory.3t \ man/TIFFReadEncodedStrip.3t \ man/TIFFReadEncodedTile.3t \ man/TIFFReadRGBAImage.3t \ man/TIFFReadRawStrip.3t \ man/TIFFReadRawTile.3t \ man/TIFFReadScanline.3t \ man/TIFFReadTile.3t \ man/TIFFSetDirectory.3t \ man/TIFFSetField.3t \ man/TIFFWarning.3t \ man/TIFFWriteDirectory.3t \ man/TIFFWriteEncodedStrip.3t \ man/TIFFWriteEncodedTile.3t \ man/TIFFWriteRawStrip.3t \ man/TIFFWriteRawTile.3t \ man/TIFFWriteScanline.3t \ man/intro.3t \ man/query.3t \ man/size.3t \ man/strip.3t \ man/swab.3t \ man/tile.3t \ html/Makefile.in \ html/bugs.html \ html/build.html \ html/contrib.html \ html/document.html \ html/images.html \ html/index.html \ html/internals.html \ html/intro.html \ html/libtiff.html \ html/misc.html \ html/support.html \ html/tools.html \ html/v3.4beta018.html \ html/v3.4beta016.html \ html/v3.4beta007.html \ ${NULL} OTHERFILES=\ html/images/back.gif \ html/images/bali.jpg \ html/images/cat.gif \ html/images/cover.jpg \ html/images/cramps.gif \ html/images/dave.gif \ html/images/info.gif \ html/images/jello.jpg \ html/images/jim.gif \ html/images/note.gif \ html/images/oxford.gif \ html/images/quad.jpg \ html/images/ring.gif \ html/images/smallliz.jpg \ html/images/strike.gif \ html/images/warning.gif \ ${NULL} CONTRIBFILES=\ contrib/dbs/README \ contrib/dbs/Imakefile \ contrib/dbs/tiff-bi.c \ contrib/dbs/tiff-grayscale.c \ contrib/dbs/tiff-palette.c \ contrib/dbs/tiff-rgb.c \ contrib/dbs/xtiff/README \ contrib/dbs/xtiff/Imakefile \ contrib/dbs/xtiff/patchlevel.h \ contrib/dbs/xtiff/xtiff.c \ contrib/dbs/xtiff/xtifficon.h \ 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 \ ${NULL} DISTFILES=\ ${TIFFFILES} \ dist/tiff.alpha \ dist/tiff.version \ ${OTHERFILES} \ ${CONTRIBFILES} \ ${NULL} CONFIG=\ -with-CC=ncc \ -with-GCOPTS=" " \ -with-JPEG=yes \ -with-DIR_JPEG=../src/jpeg-5a \ -with-ZIP=yes \ -with-DIR_LIBGZ=../src/zlib \ -with-HTML \ ${NULL} rcsclean: rcsclean ${TIFFFILES} && co ${TIFFFILES} alpha: (cd ${SRCDIR}/dist; sh newalpha; sh newversion) -${MAKE} clean ${MAKE} alpha.stamp ${SRCDIR}/configure ${CONFIG} ${MAKE} product ${MAKE} alpha.tar # stamp relevant files according to current alpha alpha.stamp: VERSION=`awk '{print "Alpha" $$3}' ${SRCDIR}/dist/tiff.alpha`;\ NOW=`date`; \ for i in ${TIFFFILES}; do \ REV=`rlog -h -d"$$NOW" ${SRCDIR}/$$i|fgrep 'head:'|awk '{print $$2}'`;\ rcs "-N$$VERSION:$$REV" "-sExp:$$REV" ${SRCDIR}/$$i && co -sExp ${SRCDIR}/$$i; \ done purge-old-alphas: VERSIONS=`awk '{for (i=1; i<=$$3; i++) printf " -nAlpha%03d",i}'\ ${SRCDIR}/dist/tiff.alpha`; \ for i in ${TIFFFILES}; do \ echo rcs $$VERSIONS ${SRCDIR}/$$i; \ rcs $$VERSIONS ${SRCDIR}/$$i && co ${SRCDIR}/$$i; \ done alphadiff: -@for i in ${TIFFFILES}; do \ rcsdiff -r${ALPHA} ${SRCDIR}/$$i; \ done # create alpha distribution archive alpha.tar: VERSION="v`cat ${SRCDIR}/VERSION``awk '{print $$3}' ${SRCDIR}/dist/tiff.alpha`"; \ rm -f tiff-$$VERSION $$VERSION $$VERSION-tar; \ ln -s ${SRCDIR} tiff-$$VERSION; \ (for i in ${DISTFILES}; do \ echo $$i; \ done) | sed "s;.*;tiff-$$VERSION/&;" >$$VERSION; \ tar cvf $$VERSION-tar `cat $$VERSION`; \ rm -f tiff-$$VERSION-tar.${ZIPSUF}; \ cat $$VERSION-tar | ${COMPRESS} >tiff-$$VERSION-tar.${ZIPSUF}; \ rm -f tiff-$$VERSION $$VERSION $$VERSION-tar; release: (cd ${SRCDIR}/dist; sh newversion) -${MAKE} clean ${MAKE} release.stamp ${SRCDIR}/configure ${CONFIG} ${MAKE} product ${MAKE} release.tar release.stamp: VERSION="Release`sed 's/\./_/g' ${SRCDIR}/VERSION`"; \ NOW=`date`; \ for i in ${TIFFFILES}; do \ REV=`rlog -h -d"$$NOW" ${SRCDIR}/$$i|fgrep 'head:'|awk '{print $$2}'`;\ rcs "-N$$VERSION:$$REV" "-sRel:$$REV" ${SRCDIR}/$$i && co -sRel ${SRCDIR}/$$i; \ done # create release distribution archive release.tar: VERSION=v`cat ${SRCDIR}/VERSION`; \ rm -f tiff-$$VERSION $$VERSION $$VERSION-tar; \ ln -s ${SRCDIR} tiff-$$VERSION; \ (for i in ${DISTFILES}; do \ echo $$i; \ done) | sed "s;.*;tiff-$$VERSION/&;" >$$VERSION; \ tar cvf $$VERSION-tar `cat $$VERSION`; \ rm -f tiff-$$VERSION-tar.${ZIPSUF}; \ cat $$VERSION-tar | ${COMPRESS} >tiff-$$VERSION-tar.${ZIPSUF}; \ rm -f tiff-$$VERSION $$VERSION $$VERSION-tar; # # Create a package of the test images. # PICS=\ pics/README \ pics/cramps.tif \ pics/cramps-tile.tif \ pics/fax2d.tif \ pics/g3test.tif \ pics/jello.tif \ pics/jim___cg.tif \ pics/jim___dg.tif \ pics/jim___gg.tif \ pics/jim___ah.tif \ pics/strike.tif \ pics/oxford.tif \ pics/quad-lzw.tif \ pics/quad-tile.tif \ pics/text.tif \ pics/ycbcr-cat.tif \ pics/smallliz.tif \ pics/zackthecat.tif \ pics/fax2d.g3 \ pics/g3test.g3 \ ${NULL} pics.tar: tar cvf - ${PICS} | ${COMPRESS} > tiffpics.tar.${ZIPSUF} he test images. # PICS=\ pics/README \ pics/cramps.tif \ pics/cramps-tile.tif \ pics/fax2d.tif \ pics/g3test.tif \ pics/jello.tif \ pics/jim___cg.tif \ pics/jim___dg.tif \ pics/jim___gg.tif \ pics/jim___ah.tiff-v3.4beta018/README000444 004341 000024 00000004455 06003062726 014242 0ustar00samuser000000 000000 $Header: /usr/people/sam/tiff/RCS/README,v 1.26 1995/07/01 00:57:02 sam Exp $ TIFF Software Distribution -------------------------- This file is just a placeholder; all the documentation is now in HTML in the html directory. To view the documentation point your favorite WWW viewer at html/index.html; e.g. netscape html/index.html If you don't have an HTML viewer then you can read the HTML source or fetch a PostScript version of this documentation from the directory ftp://ftp.sgi.com/graphics/tiff/doc If you can't hack either of these options then basically what you want to do is: % ./configure % make % su # make install If that doesn't do what you want, or something isn't clear then sorry, but you're SOL. Sam Leffler (sam@engr.sgi.com) Use and Copyright ----------------- 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. The legal way of saying that is: Copyright (c) 1988-1995 Sam Leffler Copyright (c) 1991-1995 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. IND, 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 SPEtiff-v3.4beta018/VERSION000444 004341 000024 00000000010 06003062726 014411 0ustar00samuser000000 000000 3.4beta CIDENTAL, 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 THOFTWARE. INDµ¢0@«TSS, EÛˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆ†Æ ˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø ÚžNO E SHALL SAM LEFFLER Oÿ°Ÿÿ°¯/ÿ¬,›p@<àABLE FOR ANY SPEtiff-v3.4beta018/COPYRIGHT000444 004341 000024 00000002172 06003062726 014647 0ustar00samuser000000 000000 Copyright (c) 1988-1995 Sam Leffler Copyright (c) 1991-1995 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. IND, 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 Otiff-v3.4beta018/TODO000444 004341 000024 00000000565 06003062727 014051 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/RCS/TODO,v 1.2 1995/07/03 18:42:38 sam Exp $ o update manual pages o tiffcmp read data by strip/tile instead of scanline o YCbCr sampling support o html manual pages o extracate colorspace conversion support o look at isolating all codecs from TIFF library o tiffcp problem with JPEG-encoded image o JPEG colormode order dependency problem +Pˆ²¸ˆM|ˆB,ˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø ÚžOF UDATA OR PROFITS, WHEÿ°Óÿ°ã/ÿ¬4›p@<àHE POSSIBILITY Otiff-v3.4beta018/dist/tiff.spec000444 004341 000024 00000004357 06003062727 016133 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/dist/RCS/tiff.spec,v 1.2 1995/06/28 04:59:00 sam Exp $ # # TIFF Software # # Copyright (c) 1994 Sam Leffler # Copyright (c) 1994 Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. # # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. # # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # define CUR_MAJ_VERS 1006 # Major Version number define CUR_MIN_VERS 001 # Minor Version number define CUR_VERS ${CUR_MAJ_VERS}${CUR_MIN_VERS}${ALPHA} define TIFF_NAME "TIFF" include tiff.version include tiff.alpha product tiff id "${TIFF_NAME} Tools, Version ${TIFF_VNUM}" inplace image sw id "${TIFF_NAME} Software" version "${CUR_VERS}" subsys tools default id "${TIFF_NAME} Tools" exp "tiff.sw.tools" endsubsys subsys dev id "${TIFF_NAME} Library" exp "tiff.sw.dev" endsubsys endimage image man id "${TIFF_NAME} Documentation" version "${CUR_VERS}" subsys tools default id "${TIFF_NAME} Tools Manual Pages" exp "tiff.man.tools" endsubsys subsys dev id "${TIFF_NAME} Library Manual Pages" exp "tiff.man.dev" endsubsys endimage image html id "${TIFF_NAME} HTML Materials" version "${CUR_VERS}" subsys sw id "${TIFF_NAME} Software Distribution" exp "tiff.html.sw" endsubsys endimage endproduct exp "tiff.sw.dev" endsubsys endimage image man id "${TIFF_NAME} Documentation" version "${CUR_VERS}" subsys tools default id "${TIFF_NAME} Tools Manual Pages" exp "tiff.man.tools" endsubsys subsys dev id "${TIFF_NAME} Library Manual Pagetiff-v3.4beta018/dist/newalpha000555 004341 000024 00000000447 06003062730 016042 0ustar00samuser000000 000000 #! /bin/sh # $Header: /usr/people/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 else echo "define ALPHA 001" >tiff.alpha fi ge man iµ¢0@«TF_NAE߈!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|‰P·tˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úžls" subsys subsys dev ÿ± ÿ±/ÿ¬<›p@<àrary Manual Pagetiff-v3.4beta018/dist/newversion000444 004341 000024 00000002703 06003062730 016434 0ustar00samuser000000 000000 #! /bin/sh # $Header: /usr/people/sam/tiff/dist/RCS/newversion,v 1.1 1994/12/17 18:27:58 sam Exp $ # # TIFF Software # # Copyright (c) 1994, 1995 Sam Leffler # Copyright (c) 1994, 1995 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. # rm -f tiff.version awk ' $1 ~ /.*beta/ { print "define TIFF_VNUM " $0 } $1 !~ /.*beta/{ print "define TIFF_VNUM \"" $0 " (release)\"" } ' ../VERSION > tiff.version ICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIREtiff-v3.4beta018/libtiff/Makefile.in000444 004341 000024 00000020302 06003062730 017026 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.in,v 1.20 1995/07/17 19:26:25 sam Exp $ # # Tag Image File Format Library # # Copyright (c) 1988-1995 Sam Leffler # Copyright (c) 1991-1995 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. # DEPTH = .. SRCDIR = ${DEPTH}/@SRCDIR@/libtiff JPEGDIR = ${DEPTH}/@DIR_JPEG@ ZIPDIR = ${DEPTH}/@DIR_LIBGZ@ PORT = ${DEPTH}/port # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = CC = @CCOMPILER@ AR = @AR@ AROPTS = @AROPTS@ RANLIB = @RANLIB@ INSTALL = @INSTALL@ # # If JPEG support is to be included and the Independent JPEG # Software distribution is not installed then INC_JPEG will # refer to the directory where the include files reside. # IPATH = -I. -I${DEPTH} -I${SRCDIR} -I${JPEGDIR} -I${ZIPDIR} # # To enable JPEG support (with the default configuration), include # -DJPEG_SUPPORT here, setup the include search path above, and # configure the tools to locate the appropriate libjpeg. Otherwise, # consult tiffconf.h for information on controlling the configuration # of optional library support. # CONF_LIBRARY=\ @CONF_JPEG@ \ @CONF_ZIP@ \ ${NULL} COPTS = @GCOPTS@ OPTIMIZER=-O CFLAGS = @ENVOPTS@ ${COPTS} ${OPTIMIZER} ${IPATH} ${CONF_LIBRARY} # 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_fax3.c \ tif_fax3sm.c \ tif_getimage.c \ tif_jpeg.c \ tif_flush.c \ tif_lzw.c \ tif_next.c \ tif_open.c \ tif_packbits.c \ tif_predict.c \ tif_print.c \ tif_read.c \ tif_swab.c \ tif_strip.c \ tif_thunder.c \ tif_tile.c \ tif_unix.c \ tif_version.c \ tif_warning.c \ tif_write.c \ tif_zip.c \ ${NULL} OBJS = \ tif_aux.o \ tif_close.o \ tif_codec.o \ tif_compress.o \ tif_dir.o \ tif_dirinfo.o \ tif_dirread.o \ tif_dirwrite.o \ tif_dumpmode.o \ tif_error.o \ tif_fax3.o \ tif_fax3sm.o \ tif_getimage.o \ tif_jpeg.o \ tif_flush.o \ tif_lzw.o \ tif_next.o \ tif_open.o \ tif_packbits.o \ tif_predict.o \ tif_print.o \ tif_read.o \ tif_swab.o \ tif_strip.o \ tif_thunder.o \ tif_tile.o \ tif_unix.o \ tif_version.o \ tif_warning.o \ tif_write.o \ tif_zip.o \ ${NULL} TARGETS = libtiff.a all: ${TARGETS} if [ "@DSO@" = yes ]; then \ ${MAKE} dso; \ fi libtiff.a: ${OBJS} ${AR} ${AROPTS} libtiff.a $? ${RANLIB} libtiff.a dso: ${OBJS} ${CC} -o libtiff.@DSOSUF@ -shared -rdata_shared ${OBJS} \ @LIBJPEG@ @LIBGZ@ touch dso ${OBJS}: ${SRCDIR}/tiffio.h ${SRCDIR}/tiff.h ${SRCDIR}/tif_dir.h ${OBJS}: ${SRCDIR}/tiffcomp.h ${SRCDIR}/tiffiop.h ${SRCDIR}/tiffconf.h tif_fax3.o: ${SRCDIR}/t4.h ${SRCDIR}/tif_fax3.h # # NB: can't use these since the software may not be configure # for use with JPEG support. Really need dynamic include # file dependency support; but that's too much effort. # #tif_jpeg.o: ${JPEGDIR}/jpeglib.h ${JPEGDIR}/jerror.h tif_lzw.o: ${SRCDIR}/tif_predict.h tif_predict.o: ${SRCDIR}/tif_predict.h tif_zip.o: ${SRCDIR}/tif_predict.h # # NB: can't use these since the software may not be configure # for use with Deflate support. # #tif_zip.o: ${ZIPDIR}/zlib.h ${ZIPDIR}/zutil.h ALPHA = ${DEPTH}/@SRCDIR@/dist/tiff.alpha VERSION = ${DEPTH}/@SRCDIR@/VERSION version.h: ${VERSION} ${ALPHA} VERSION=`cat ${VERSION}`; \ VERSION="$${VERSION}`awk '{print $$3}' ${ALPHA}`"; \ rm -f version.h; \ echo '#define VERSION "LIBTIFF, Version' $$VERSION '\\nCopyright (c) 1988-1995 Sam Leffler\\nCopyright (c) 1991-1995 Silicon Graphics, Inc."' >version.h tif_version.o: version.h # # The finite state machine tables used by the G3/G4 decoders # are generated by the mkg3states program. On systems without # make these rules have to be manually carried out. # tif_fax3sm.c: ${SRCDIR}/mkg3states.c ${SRCDIR}/tif_fax3.h ${CC} -o mkg3states ${CFLAGS} ${SRCDIR}/mkg3states.c rm -f tif_fax3sm.c; ./mkg3states -c const tif_fax3sm.c tif_aux.o: ${SRCDIR}/tif_aux.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_aux.c tif_close.o: ${SRCDIR}/tif_close.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_close.c tif_codec.o: ${SRCDIR}/tif_codec.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_codec.c tif_compress.o: ${SRCDIR}/tif_compress.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_compress.c tif_dir.o: ${SRCDIR}/tif_dir.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dir.c tif_dirinfo.o: ${SRCDIR}/tif_dirinfo.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirinfo.c tif_dirread.o: ${SRCDIR}/tif_dirread.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirread.c tif_dirwrite.o: ${SRCDIR}/tif_dirwrite.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dirwrite.c tif_dumpmode.o: ${SRCDIR}/tif_dumpmode.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_dumpmode.c tif_error.o: ${SRCDIR}/tif_error.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_error.c tif_fax3.o: ${SRCDIR}/tif_fax3.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_fax3.c tif_getimage.o: ${SRCDIR}/tif_getimage.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_getimage.c tif_jpeg.o: ${SRCDIR}/tif_jpeg.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_jpeg.c tif_flush.o: ${SRCDIR}/tif_flush.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_flush.c tif_lzw.o: ${SRCDIR}/tif_lzw.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_lzw.c tif_next.o: ${SRCDIR}/tif_next.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_next.c tif_open.o: ${SRCDIR}/tif_open.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_open.c tif_packbits.o: ${SRCDIR}/tif_packbits.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_packbits.c tif_predict.o: ${SRCDIR}/tif_predict.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_predict.c tif_print.o: ${SRCDIR}/tif_print.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_print.c tif_read.o: ${SRCDIR}/tif_read.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_read.c tif_swab.o: ${SRCDIR}/tif_swab.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_swab.c tif_strip.o: ${SRCDIR}/tif_strip.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_strip.c tif_thunder.o: ${SRCDIR}/tif_thunder.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_thunder.c tif_tile.o: ${SRCDIR}/tif_tile.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_tile.c tif_unix.o: ${SRCDIR}/tif_unix.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_unix.c tif_version.o: ${SRCDIR}/tif_version.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_version.c tif_warning.o: ${SRCDIR}/tif_warning.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_warning.c tif_write.o: ${SRCDIR}/tif_write.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_write.c tif_zip.o: ${SRCDIR}/tif_zip.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_zip.c tif_apple.o: ${SRCDIR}/tif_apple.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_apple.c tif_atari.o: ${SRCDIR}/tif_atari.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_atari.c tif_msdos.o: ${SRCDIR}/tif_msdos.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_msdos.c tif_vms.o: ${SRCDIR}/tif_vms.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_vms.c tif_win3.o: ${SRCDIR}/tif_win3.c ${CC} -c ${CFLAGS} ${SRCDIR}/tif_win3.c INCS = ${SRCDIR}/tiff.h ${SRCDIR}/tiffio.h installHdrs: ${INCS} ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_INC@ for i in ${INCS}; do \ f=`basename $$i`; \ ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_INC@ \ -src $$i -O $$f; \ done installDSO: dso ${INSTALL} -idb tiff.sw.tools -m 444 -F @DIR_LIB@ -O libtiff.@DSOSUF@ install: all installHdrs ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_LIB@ ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_LIB@ -O libtiff.a if [ "@DSO@" = yes ]; then \ ${MAKE} installDSO; \ fi clean: rm -f ${TARGETS} ${OBJS} core a.out mkg3states tif_fax3sm.c version.h \ libtiff.@DSOSUF@ dso INCS}; do \ f=`basename $$i`; \ ${INSTALL} -idb tiff.sw.dev -m 444 -F @DIR_INC@ \ -src $$i -O $$f; \ done installDSO: dso ${INSTALL} -idb tiff.sw.tools -m 444 -F @DIR_LIB@ -O libtiff.@DSOSUF@ install: all installHdrs ${INSTALL} -idb tiff.sw.dev -m 755 -dir @DIR_LIB@ ${INSTALL} -idb tiff.sw.dev -m 444 tiff-v3.4beta018/libtiff/Makefile.lcc000444 004341 000024 00000006063 06003062731 017172 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.lcc,v 1.2 1994/11/28 06:13:31 sam Exp $ # # 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 Stanford 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. # DESTDIR=. # INSTALL=install NULL= IPATH= -I. -I../jpeg CONF_LIBRARY=\ ${NULL} COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY} # INCS= tiff.h tiffio.h SRCS= tif_fax3.c \ tif_fax4.c \ tif_aux.c \ tif_atari.c \ tif_ccittrle.c \ tif_close.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_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 \ ${NULL} OBJS= tif_fax3.o \ tif_fax4.o \ tif_aux.o \ tif_atari.o \ tif_ccittrle.o \ tif_close.o \ tif_compress.o \ tif_dir.o \ tif_dirinfo.o \ tif_dirread.o \ tif_dirwrite.o \ tif_dumpmode.o \ tif_error.o \ tif_getimage.o \ tif_jpeg.o \ tif_flush.o \ tif_lzw.o \ tif_next.o \ tif_open.o \ tif_packbits.o \ tif_print.o \ tif_read.o \ tif_swab.o \ tif_strip.o \ tif_thunder.o \ tif_tile.o \ tif_version.o \ tif_warning.o \ tif_write.o \ ${NULL} ALL= tiffrnb.lib all: ${ALL} ${ALL}: ${OBJS} ${AR} ${ARFLAGS} $@ r $< ${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h tif_fax3.o: tif_fax3.c g3states.h t4.h tif_fax3.h g3states.h: mkg3states.c t4.h ${CC} -o mkg3states.ttp ${CFLAGS} mkg3states.c ./mkg3states -c > g3states.h install: all installh -for i in ${ALL}; do \ ${INSTALL} -c -m 644 $$i ${DESTDIR}/lib/$$i; \ done installh: ${INCS} -for i in ${INCS}; do \ h=`basename $$i`; \ cmp -s $$i ${DESTDIR}/include/$$h || \ ${INSTALL} -c -m 444 $$i ${DESTDIR}/include/$$h; \ done clean: rm -f ${ALL} ${OBJS} mkg3states.ttp mkg3states.o g3states.h tags: ${SRCS} ${CTAGS} ${SRCS} x3.c g3states.h t4.h tif_fax3.h g3states.h: mkg3states.c t4.h ${CC} -o mkg3states.ttp ${CFLAGS} mkg3states.c ./mkg3states -c > g3states.h install: all installh -for i in ${ALL}; do \ ${INSTALL} -c -m 644 $$i ${DESTDIR}/lib/$$i; \ done installh: ${INCS} -for i in ${INCS}; do \ h=`basename $$i`; \ cmp -s $$i ${DESTDIR}/include/$$h || \ ${INSTALL} -c -m 444 $$i ${DESTDIR}/include/$$h; \ done clean: rm -f ${ALL} ${OBJS} mkg3states.ttp mkg3sttiff-v3.4beta018/libtiff/Makefile.msc000444 004341 000024 00000010402 06003062731 017203 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/libtiff/RCS/Makefile.msc,v 1.2 1994/11/28 06:13:31 sam Exp $ # # 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 msc (7.0) using dmake. # DESTDIR=. # IPATH= -I. -I../jpeg CONF_LIBRARY=\ ${NULL} COPTS= -Oxaz -AL -DBSDTYPES -Zi -Zd CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY} # INCS= tiff.h tiffio.h SRCS= tif_fax3.c \ tif_fax4.c \ tif_aux.c \ tif_ccit.c \ tif_clos.c \ tif_comp.c \ tif_dir.c \ tif_diri.c \ tif_dirr.c \ tif_dirw.c \ tif_dump.c \ tif_erro.c \ tif_geti.c \ tif_jpeg.c \ tif_flus.c \ tif_lzw.c \ tif_next.c \ tif_open.c \ tif_pack.c \ tif_prin.c \ tif_read.c \ tif_swab.c \ tif_stri.c \ tif_thun.c \ tif_tile.c \ tif_unix.c \ tif_vers.c \ tif_warn.c \ tif_writ.c \ ${NULL} OBJS= tif_fax3.obj \ tif_fax4.obj \ tif_aux.obj \ tif_ccit.obj \ tif_clos.obj \ tif_comp.obj \ tif_dir.obj \ tif_diri.obj \ tif_dirr.obj \ tif_dirw.obj \ tif_dump.obj \ tif_erro.obj \ tif_geti.obj \ tif_jpeg.obj \ tif_flus.obj \ tif_lzw.obj \ tif_msdo.obj \ tif_next.obj \ tif_open.obj \ tif_pack.obj \ tif_prin.obj \ tif_read.obj \ tif_stri.obj \ tif_swab.obj \ tif_thun.obj \ tif_tile.obj \ tif_vers.obj \ tif_warn.obj \ tif_writ.obj \ ${NULL} ALL= libtiff.lib all: ${ALL} %.obj : %.c $(CC) $(CFLAGS) -c $*.c #.INCLUDE .IGNORE : depend ${ALL}: ${OBJS} lib libtiff /NOIGNO /NOLOGO -+tif_fax3.obj; lib libtiff /NOIGNO /NOLOGO -+tif_fax4.obj; lib libtiff /NOIGNO /NOLOGO -+tif_aux.obj; lib libtiff /NOIGNO /NOLOGO -+tif_ccit.obj; lib libtiff /NOIGNO /NOLOGO -+tif_clos.obj; lib libtiff /NOIGNO /NOLOGO -+tif_comp.obj; lib libtiff /NOIGNO /NOLOGO -+tif_dir.obj; lib libtiff /NOIGNO /NOLOGO -+tif_diri.obj; lib libtiff /NOIGNO /NOLOGO -+tif_dirr.obj; lib libtiff /NOIGNO /NOLOGO -+tif_dirw.obj; lib libtiff /NOIGNO /NOLOGO -+tif_dump.obj; lib libtiff /NOIGNO /NOLOGO -+tif_erro.obj; lib libtiff /NOIGNO /NOLOGO -+tif_geti.obj; lib libtiff /NOIGNO /NOLOGO -+tif_jpeg.obj; lib libtiff /NOIGNO /NOLOGO -+tif_flus.obj; lib libtiff /NOIGNO /NOLOGO -+tif_lzw.obj; lib libtiff /NOIGNO /NOLOGO -+tif_msdo.obj; lib libtiff /NOIGNO /NOLOGO -+tif_next.obj; lib libtiff /NOIGNO /NOLOGO -+tif_open.obj; lib libtiff /NOIGNO /NOLOGO -+tif_pack.obj; lib libtiff /NOIGNO /NOLOGO -+tif_prin.obj; lib libtiff /NOIGNO /NOLOGO -+tif_read.obj; lib libtiff /NOIGNO /NOLOGO -+tif_stri.obj; lib libtiff /NOIGNO /NOLOGO -+tif_swab.obj; lib libtiff /NOIGNO /NOLOGO -+tif_thun.obj; lib libtiff /NOIGNO /NOLOGO -+tif_tile.obj; lib libtiff /NOIGNO /NOLOGO -+tif_vers.obj; lib libtiff /NOIGNO /NOLOGO -+tif_warn.obj; lib libtiff /NOIGNO /NOLOGO -+tif_writ.obj; ${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.c t4.h ${CC} ${CFLAGS} mkg3states.c mkg3states -c > g3states.h clean: del *.obj del mkg3stat del g3states.h tags: ${SRCS} ${CTAGS} ${SRCS} hun.obj; lib libtiff /NOIGNO /NOLOGO -+tif_tile.obj; lib libtiff /NOIGNO /NOLOGO -+tif_vers.obj; lib libtiff /NOIGNO /NOLOGO -+tif_warn.obj; lib libtiff /NOIGNO /NOLOGO -+tif_writ.obj; ${OBJS}: tiffio.h tiff.h tiffcomp.h tiff-v3.4beta018/libtiff/t4.h000444 004341 000024 00000026072 06003062732 015475 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/t4.h,v 1.14 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _T4_ #define _T4_ /* * CCITT T.4 1D Huffman runlength codes and * related definitions. Given the small sizes * of these tables it does not seem * worthwhile to make code & length 8 bits. */ typedef struct tableentry { unsigned short length; /* bit length of g3 code */ unsigned short code; /* g3 code */ short runlen; /* run length in bits */ } tableentry; #define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ /* status values returned instead of a run length */ #define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ #define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ #define G3CODE_EOF -3 /* end of input data */ #define G3CODE_INCOMP -4 /* incomplete run code */ /* * Note that these tables are ordered such that the * index into the table is known to be either the * run length, or (run length / 64) + a fixed offset. * * NB: The G3CODE_INVALID entries are only used * during state generation (see mkg3states.c). */ #ifdef G3CODES const tableentry TIFFFaxWhiteCodes[] = { { 8, 0x35, 0 }, /* 0011 0101 */ { 6, 0x7, 1 }, /* 0001 11 */ { 4, 0x7, 2 }, /* 0111 */ { 4, 0x8, 3 }, /* 1000 */ { 4, 0xB, 4 }, /* 1011 */ { 4, 0xC, 5 }, /* 1100 */ { 4, 0xE, 6 }, /* 1110 */ { 4, 0xF, 7 }, /* 1111 */ { 5, 0x13, 8 }, /* 1001 1 */ { 5, 0x14, 9 }, /* 1010 0 */ { 5, 0x7, 10 }, /* 0011 1 */ { 5, 0x8, 11 }, /* 0100 0 */ { 6, 0x8, 12 }, /* 0010 00 */ { 6, 0x3, 13 }, /* 0000 11 */ { 6, 0x34, 14 }, /* 1101 00 */ { 6, 0x35, 15 }, /* 1101 01 */ { 6, 0x2A, 16 }, /* 1010 10 */ { 6, 0x2B, 17 }, /* 1010 11 */ { 7, 0x27, 18 }, /* 0100 111 */ { 7, 0xC, 19 }, /* 0001 100 */ { 7, 0x8, 20 }, /* 0001 000 */ { 7, 0x17, 21 }, /* 0010 111 */ { 7, 0x3, 22 }, /* 0000 011 */ { 7, 0x4, 23 }, /* 0000 100 */ { 7, 0x28, 24 }, /* 0101 000 */ { 7, 0x2B, 25 }, /* 0101 011 */ { 7, 0x13, 26 }, /* 0010 011 */ { 7, 0x24, 27 }, /* 0100 100 */ { 7, 0x18, 28 }, /* 0011 000 */ { 8, 0x2, 29 }, /* 0000 0010 */ { 8, 0x3, 30 }, /* 0000 0011 */ { 8, 0x1A, 31 }, /* 0001 1010 */ { 8, 0x1B, 32 }, /* 0001 1011 */ { 8, 0x12, 33 }, /* 0001 0010 */ { 8, 0x13, 34 }, /* 0001 0011 */ { 8, 0x14, 35 }, /* 0001 0100 */ { 8, 0x15, 36 }, /* 0001 0101 */ { 8, 0x16, 37 }, /* 0001 0110 */ { 8, 0x17, 38 }, /* 0001 0111 */ { 8, 0x28, 39 }, /* 0010 1000 */ { 8, 0x29, 40 }, /* 0010 1001 */ { 8, 0x2A, 41 }, /* 0010 1010 */ { 8, 0x2B, 42 }, /* 0010 1011 */ { 8, 0x2C, 43 }, /* 0010 1100 */ { 8, 0x2D, 44 }, /* 0010 1101 */ { 8, 0x4, 45 }, /* 0000 0100 */ { 8, 0x5, 46 }, /* 0000 0101 */ { 8, 0xA, 47 }, /* 0000 1010 */ { 8, 0xB, 48 }, /* 0000 1011 */ { 8, 0x52, 49 }, /* 0101 0010 */ { 8, 0x53, 50 }, /* 0101 0011 */ { 8, 0x54, 51 }, /* 0101 0100 */ { 8, 0x55, 52 }, /* 0101 0101 */ { 8, 0x24, 53 }, /* 0010 0100 */ { 8, 0x25, 54 }, /* 0010 0101 */ { 8, 0x58, 55 }, /* 0101 1000 */ { 8, 0x59, 56 }, /* 0101 1001 */ { 8, 0x5A, 57 }, /* 0101 1010 */ { 8, 0x5B, 58 }, /* 0101 1011 */ { 8, 0x4A, 59 }, /* 0100 1010 */ { 8, 0x4B, 60 }, /* 0100 1011 */ { 8, 0x32, 61 }, /* 0011 0010 */ { 8, 0x33, 62 }, /* 0011 0011 */ { 8, 0x34, 63 }, /* 0011 0100 */ { 5, 0x1B, 64 }, /* 1101 1 */ { 5, 0x12, 128 }, /* 1001 0 */ { 6, 0x17, 192 }, /* 0101 11 */ { 7, 0x37, 256 }, /* 0110 111 */ { 8, 0x36, 320 }, /* 0011 0110 */ { 8, 0x37, 384 }, /* 0011 0111 */ { 8, 0x64, 448 }, /* 0110 0100 */ { 8, 0x65, 512 }, /* 0110 0101 */ { 8, 0x68, 576 }, /* 0110 1000 */ { 8, 0x67, 640 }, /* 0110 0111 */ { 9, 0xCC, 704 }, /* 0110 0110 0 */ { 9, 0xCD, 768 }, /* 0110 0110 1 */ { 9, 0xD2, 832 }, /* 0110 1001 0 */ { 9, 0xD3, 896 }, /* 0110 1001 1 */ { 9, 0xD4, 960 }, /* 0110 1010 0 */ { 9, 0xD5, 1024 }, /* 0110 1010 1 */ { 9, 0xD6, 1088 }, /* 0110 1011 0 */ { 9, 0xD7, 1152 }, /* 0110 1011 1 */ { 9, 0xD8, 1216 }, /* 0110 1100 0 */ { 9, 0xD9, 1280 }, /* 0110 1100 1 */ { 9, 0xDA, 1344 }, /* 0110 1101 0 */ { 9, 0xDB, 1408 }, /* 0110 1101 1 */ { 9, 0x98, 1472 }, /* 0100 1100 0 */ { 9, 0x99, 1536 }, /* 0100 1100 1 */ { 9, 0x9A, 1600 }, /* 0100 1101 0 */ { 6, 0x18, 1664 }, /* 0110 00 */ { 9, 0x9B, 1728 }, /* 0100 1101 1 */ { 11, 0x8, 1792 }, /* 0000 0001 000 */ { 11, 0xC, 1856 }, /* 0000 0001 100 */ { 11, 0xD, 1920 }, /* 0000 0001 101 */ { 12, 0x12, 1984 }, /* 0000 0001 0010 */ { 12, 0x13, 2048 }, /* 0000 0001 0011 */ { 12, 0x14, 2112 }, /* 0000 0001 0100 */ { 12, 0x15, 2176 }, /* 0000 0001 0101 */ { 12, 0x16, 2240 }, /* 0000 0001 0110 */ { 12, 0x17, 2304 }, /* 0000 0001 0111 */ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; const tableentry TIFFFaxBlackCodes[] = { { 10, 0x37, 0 }, /* 0000 1101 11 */ { 3, 0x2, 1 }, /* 010 */ { 2, 0x3, 2 }, /* 11 */ { 2, 0x2, 3 }, /* 10 */ { 3, 0x3, 4 }, /* 011 */ { 4, 0x3, 5 }, /* 0011 */ { 4, 0x2, 6 }, /* 0010 */ { 5, 0x3, 7 }, /* 0001 1 */ { 6, 0x5, 8 }, /* 0001 01 */ { 6, 0x4, 9 }, /* 0001 00 */ { 7, 0x4, 10 }, /* 0000 100 */ { 7, 0x5, 11 }, /* 0000 101 */ { 7, 0x7, 12 }, /* 0000 111 */ { 8, 0x4, 13 }, /* 0000 0100 */ { 8, 0x7, 14 }, /* 0000 0111 */ { 9, 0x18, 15 }, /* 0000 1100 0 */ { 10, 0x17, 16 }, /* 0000 0101 11 */ { 10, 0x18, 17 }, /* 0000 0110 00 */ { 10, 0x8, 18 }, /* 0000 0010 00 */ { 11, 0x67, 19 }, /* 0000 1100 111 */ { 11, 0x68, 20 }, /* 0000 1101 000 */ { 11, 0x6C, 21 }, /* 0000 1101 100 */ { 11, 0x37, 22 }, /* 0000 0110 111 */ { 11, 0x28, 23 }, /* 0000 0101 000 */ { 11, 0x17, 24 }, /* 0000 0010 111 */ { 11, 0x18, 25 }, /* 0000 0011 000 */ { 12, 0xCA, 26 }, /* 0000 1100 1010 */ { 12, 0xCB, 27 }, /* 0000 1100 1011 */ { 12, 0xCC, 28 }, /* 0000 1100 1100 */ { 12, 0xCD, 29 }, /* 0000 1100 1101 */ { 12, 0x68, 30 }, /* 0000 0110 1000 */ { 12, 0x69, 31 }, /* 0000 0110 1001 */ { 12, 0x6A, 32 }, /* 0000 0110 1010 */ { 12, 0x6B, 33 }, /* 0000 0110 1011 */ { 12, 0xD2, 34 }, /* 0000 1101 0010 */ { 12, 0xD3, 35 }, /* 0000 1101 0011 */ { 12, 0xD4, 36 }, /* 0000 1101 0100 */ { 12, 0xD5, 37 }, /* 0000 1101 0101 */ { 12, 0xD6, 38 }, /* 0000 1101 0110 */ { 12, 0xD7, 39 }, /* 0000 1101 0111 */ { 12, 0x6C, 40 }, /* 0000 0110 1100 */ { 12, 0x6D, 41 }, /* 0000 0110 1101 */ { 12, 0xDA, 42 }, /* 0000 1101 1010 */ { 12, 0xDB, 43 }, /* 0000 1101 1011 */ { 12, 0x54, 44 }, /* 0000 0101 0100 */ { 12, 0x55, 45 }, /* 0000 0101 0101 */ { 12, 0x56, 46 }, /* 0000 0101 0110 */ { 12, 0x57, 47 }, /* 0000 0101 0111 */ { 12, 0x64, 48 }, /* 0000 0110 0100 */ { 12, 0x65, 49 }, /* 0000 0110 0101 */ { 12, 0x52, 50 }, /* 0000 0101 0010 */ { 12, 0x53, 51 }, /* 0000 0101 0011 */ { 12, 0x24, 52 }, /* 0000 0010 0100 */ { 12, 0x37, 53 }, /* 0000 0011 0111 */ { 12, 0x38, 54 }, /* 0000 0011 1000 */ { 12, 0x27, 55 }, /* 0000 0010 0111 */ { 12, 0x28, 56 }, /* 0000 0010 1000 */ { 12, 0x58, 57 }, /* 0000 0101 1000 */ { 12, 0x59, 58 }, /* 0000 0101 1001 */ { 12, 0x2B, 59 }, /* 0000 0010 1011 */ { 12, 0x2C, 60 }, /* 0000 0010 1100 */ { 12, 0x5A, 61 }, /* 0000 0101 1010 */ { 12, 0x66, 62 }, /* 0000 0110 0110 */ { 12, 0x67, 63 }, /* 0000 0110 0111 */ { 10, 0xF, 64 }, /* 0000 0011 11 */ { 12, 0xC8, 128 }, /* 0000 1100 1000 */ { 12, 0xC9, 192 }, /* 0000 1100 1001 */ { 12, 0x5B, 256 }, /* 0000 0101 1011 */ { 12, 0x33, 320 }, /* 0000 0011 0011 */ { 12, 0x34, 384 }, /* 0000 0011 0100 */ { 12, 0x35, 448 }, /* 0000 0011 0101 */ { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ { 11, 0x8, 1792 }, /* 0000 0001 000 */ { 11, 0xC, 1856 }, /* 0000 0001 100 */ { 11, 0xD, 1920 }, /* 0000 0001 101 */ { 12, 0x12, 1984 }, /* 0000 0001 0010 */ { 12, 0x13, 2048 }, /* 0000 0001 0011 */ { 12, 0x14, 2112 }, /* 0000 0001 0100 */ { 12, 0x15, 2176 }, /* 0000 0001 0101 */ { 12, 0x16, 2240 }, /* 0000 0001 0110 */ { 12, 0x17, 2304 }, /* 0000 0001 0111 */ { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #else extern const tableentry TIFFFaxWhiteCodes[]; extern const tableentry TIFFFaxBlackCodes[]; #endif #endif /* _T4_ */ 12, 0x1D, 2432 }, /* 0000 0001 1101 */ { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #else extern const tableentry TIFFFaxWhiteCodes[]; extern consttiff-v3.4beta018/libtiff/tiff.h000444 004341 000024 00000040421 06003062732 016070 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiff.h,v 1.58 1995/06/30 21:08:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _TIFF_ #define _TIFF_ /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 */ #define TIFF_VERSION 42 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 /* * Intrinsic data types required by the file format: * * 8-bit quantities char/unsigned char * 16-bit quantities int16/uint16 * 32-bit quantities int32/uint32 * strings unsigned char* */ typedef short int16; typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ #if defined(__alpha) || _MIPS_SZLONG == 64 typedef int int32; typedef unsigned int uint32; /* sizeof (uint32) must == 4 */ #else typedef long int32; typedef unsigned long uint32; /* sizeof (uint32) must == 4 */ #endif typedef struct { uint16 tiff_magic; /* magic number (defines byte order) */ uint16 tiff_version; /* TIFF version number */ uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeader; /* * TIFF Image File Directories are comprised of * a table of field descriptors of the form shown * below. The table is sorted in ascending order * by tag. The values associated with each entry * are disjoint and may appear anywhere in the file * (so long as they are placed on a word boundary). * * If the value is 4 bytes or less, then it is placed * in the offset field to save space. If the value * is less than 4 bytes, it is left-justified in the * offset field. */ typedef struct { uint16 tdir_tag; /* see below */ uint16 tdir_type; /* data type; see below */ uint32 tdir_count; /* number of items; length in spec */ uint32 tdir_offset; /* byte offset to field data */ } TIFFDirEntry; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* compression codes 32908-32911 are reserved for Pixar */ #define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */ #define COMPRESSION_DEFLATE 32946 /* Deflate compression */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !rows/data tile */ #define TIFFTAG_TILELENGTH 323 /* !cols/data tile */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ /* * Tags 512-521 are obsoleted by Technical Note #2 * which specifies a revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* tag 34750 is a private tag registered to Pixel Magic */ #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ /* * The following are ``pseudo tags'' that can be * used to control codec-specific functionality. * These tags are not written to file. Note that * these values start at 0xffff+1 so that they'll * never collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' * (i.e. added to this file), send mail to sam@sgi.com * with the appropriate C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #endif /* _TIFF_ */ RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPtiff-v3.4beta018/libtiff/tiffcomp.h000444 004341 000024 00000010252 06003062733 016747 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.44 1995/06/06 17:00:43 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _COMPAT_ #define _COMPAT_ /* * This file contains a hodgepodge of definitions and * declarations that are needed to provide compatibility * between the native system and the base implementation * that the library assumes. * * NB: This file is a mess. */ /* * Setup basic type definitions and function declaratations. */ #if defined(__MWERKS__) || defined(THINK_C) #include #include #endif #include #ifdef applec #include #else #if !defined(__MWERKS__) && !defined(THINK_C) #include #endif #endif #ifdef VMS #include #include #else #include #endif #if defined(__MWERKS__) || defined(THINK_C) || defined(applec) #include #define BSDTYPES #endif #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) #define BSDTYPES #endif #if defined(OS2_16) || defined(OS2_32) #define BSDTYPES #endif /* * The library uses the ANSI C/POSIX SEEK_* * definitions that should be defined in unistd.h * (except on VMS or the Mac, where they are in stdio.h and * there is no unistd.h). */ #ifndef SEEK_SET #if !defined(VMS) && !defined (applec) && !defined(THINK_C) && !defined(__MWERKS__) #include #endif #endif /* * The library uses memset, memcpy, and memcmp. * ANSI C and System V define these in string.h. */ #include /* * The BSD typedefs are used throughout the library. * If your system doesn't have them in , * then define BSDTYPES in your Makefile. */ #ifdef BSDTYPES typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; #endif /* * dblparam_t is the type that a double precision * floating point value will have on the parameter * stack (when coerced by the compiler). */ #ifdef applec typedef extended dblparam_t; #else typedef double dblparam_t; #endif /* * If your compiler supports inline functions, then * set INLINE appropriately to get the known hotspots * in the library expanded inline. */ #ifdef __GNUC__ #ifdef __STRICT_ANSI__ #define INLINE __inline__ #else #define INLINE inline #endif #else /* !__GNUC__ */ #define INLINE #endif /* * GLOBALDATA is a macro that is used to define global variables * private to the library. We use this indirection to hide * brain-damage in VAXC (and GCC) under VAX/VMS. In these * environments the macro places the variable in a non-shareable * program section, which ought to be done by default (sigh!) * * Apparently DEC are aware of the problem as this behaviour is the * default under VMS on AXP. * * The GNU C variant is untested. */ #if defined(VAX) && defined(VMS) #ifdef VAXC #define GLOBALDATA(TYPE,NAME) extern noshare TYPE NAME #endif #ifdef __GNUC__ #define GLOBALDATA(TYPE,NAME) extern TYPE NAME \ asm("_$$PsectAttributes_NOSHR$$" #NAME) #endif #else /* !VAX/VMS */ #define GLOBALDATA(TYPE,NAME) extern TYPE NAME #endif #endif /* _COMPAT_ */ am section, which ought to be done by default (sigh!) * * Apparently DEC are aware of the problem as this behaviour is the * default under VMS on AXP. * * The GNU C variant is untested. */ #if defined(VAX) && defined(VMS) #ifdef VAXC #define GLOBALDATA(TYPE,NAME) extern noshare TYPE NAME #endif #ifdef __GNUC__ #define GLOBALDATA(TYPE,tiff-v3.4beta018/libtiff/tiffconf.h000444 004341 000024 00000011004 06003062733 016732 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffconf.h,v 1.11 1995/06/30 15:29:02 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _TIFFCONF_ #define _TIFFCONF_ /* * Library Configuration Definitions. * * This file defines the default configuration for the library. * If the target system does not have make or a way to specify * #defines on the command line, this file can be edited to * configure the library. Otherwise, one can override portability * and configuration-related definitions from a Makefile or command * line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below). */ /* * General portability-related defines: * * HAVE_IEEEFP define as 0 or 1 according to the floating point * format suported by the machine * BSDTYPES define this if your system does NOT define the * usual 4BSD typedefs u_int et. al. * HAVE_MMAP enable support for memory mapping read-only files; * this is typically deduced by the configure script * HOST_FILLORDER native cpu bit order: one of FILLORDER_MSB2LSB * or FILLODER_LSB2MSB; this is typically set by the * configure script * HOST_BIGENDIAN native cpu byte order: 1 if big-endian (Motorola) * or 0 if little-endian (Intel); this may be used * in codecs to optimize code */ #ifndef HAVE_IEEEFP #define HAVE_IEEEFP 1 #endif #ifndef HOST_FILLORDER #define HOST_FILLORDER FILLORDER_MSB2LSB #endif #ifndef HOST_BIGENDIAN #define HOST_BIGENDIAN 1 #endif #ifndef FEATURE_SUPPORT /* * Feature support definitions: * * COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags * YCBCR_SUPPORT enable support for 6.0 YCbCr tags * CMYK_SUPPORT enable support for 6.0 CMYK tags */ #define COLORIMETRY_SUPPORT #define YCBCR_SUPPORT #define CMYK_SUPPORT #endif /* FEATURE_SUPPORT */ #ifndef COMPRESSION_SUPPORT /* * Compression support defines: * * CCITT_SUPPORT enable support for CCITT Group 3 & 4 algorithms * PACKBITS_SUPPORT enable support for Macintosh PackBits algorithm * LZW_SUPPORT enable support for LZW algorithm * THUNDER_SUPPORT enable support for ThunderScan 4-bit RLE algorithm * NEXT_SUPPORT enable support for NeXT 2-bit RLE algorithm * OJPEG_SUPPORT enable support for 6.0-style JPEG DCT algorithms * (no builtin support, only a codec hook) * JPEG_SUPPORT enable support for post-6.0-style JPEG DCT algorithms * (requires freely available IJG software, see tif_jpeg.c) * ZIP_SUPPORT enable support for Deflate algorithm * (requires freely available zlib software, see tif_zip.c) */ #define CCITT_SUPPORT #define PACKBITS_SUPPORT #define LZW_SUPPORT #define THUNDER_SUPPORT #define NEXT_SUPPORT #endif /* COMPRESSION_SUPPORT */ /* * If JPEG compression is enabled then we must also include * support for the colorimetry and YCbCr-related tags. */ #ifdef JPEG_SUPPORT #ifndef YCBCR_SUPPORT #define YCBCR_SUPPORT #endif #ifndef COLORIMETRY_SUPPORT #define COLORIMETRY_SUPPORT #endif #endif /* JPEG_SUPPORT */ /* * ``Orthogonal Features'' * * STRIPCHOP_SUPPORT automatically convert single-strip uncompressed images * to mutiple strips of ~8Kb (for reducing memory use) * SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such) */ #ifndef STRIPCHOP_SUPPORT #define STRIPCHOP_SUPPORT 1 /* enable strip chopping */ #endif #ifndef SUBIFD_SUPPORT #define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */ #endif #endif /* _TIFFCONF_ */ RT #define COLORIMETRY_SUPPORT #endif #endif /* JPEG_SUPPORT */ /* * ``Orthogonal Features'' * * STRIPCHOP_SUPPORT automatically convert single-strip uncompressed images * to mutiple strips of ~8Kb (for reducing memory use) * SUBIFD_SUPPORT enable support for SubIFD tag (thumbnails and such) */ #ifndef STRIPCHOP_SUPPORT #define STRIPCHOP_SUPPORT 1 /* enable strip chopping */ #endif #ifndef SUBIFD_SUPPORT #define SUBIFD_SUPPORT 1 /* enable SubIFD tag (330) support */ #endif #endif /* _TIFFCONF_tiff-v3.4beta018/libtiff/tiffio.h000444 004341 000024 00000027176 06003062734 016436 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffio.h,v 1.90 1995/06/27 00:54:10 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is int32 and not uint32 because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets being the most important */ typedef unsigned int ttag_t; /* directory tag */ typedef uint16 tdir_t; /* directory index */ typedef uint16 tsample_t; /* sample number */ typedef uint32 tstrip_t; /* strip number */ typedef uint32 ttile_t; /* tile number */ typedef int32 tsize_t; /* i/o size in bytes */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) #include typedef HFILE thandle_t; /* client data handle */ #else typedef void* thandle_t; /* client data handle */ #endif typedef void* tdata_t; /* image data ref */ typedef int32 toff_t; /* file offset */ #ifndef NULL #define NULL 0 #endif /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * RGBA-style image support. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32* Cr_g_tab; int32* Cb_g_tab; float coeffs[3]; /* cached for repeated use */ } TIFFYCbCrToRGB; struct _TIFFRGBAImage { 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)(TIFFRGBAImage*, uint32*, uint32, uint32); union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; /* put decoded strip/tile */ TIFFRGBValue* Map; /* sample mapping array */ uint32** BWmap; /* black&white map */ uint32** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16 scheme; TIFFInitMethod init; } TIFFCodec; #include #include #if defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*); typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16); extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern tdata_t _TIFFmalloc(tsize_t); extern tdata_t _TIFFrealloc(tdata_t, tsize_t); extern void _TIFFmemset(tdata_t, int, tsize_t); extern void _TIFFmemcpy(tdata_t, const tdata_t, tsize_t); extern int _TIFFmemcmp(const tdata_t, const tdata_t, tsize_t); extern void _TIFFfree(tdata_t); extern void TIFFClose(TIFF*); extern int TIFFFlush(TIFF*); extern int TIFFFlushData(TIFF*); extern int TIFFGetField(TIFF*, ttag_t, ...); extern int TIFFVGetField(TIFF*, ttag_t, va_list); extern int TIFFGetFieldDefaulted(TIFF*, ttag_t, ...); extern int TIFFVGetFieldDefaulted(TIFF*, ttag_t, va_list); extern int TIFFReadDirectory(TIFF*); extern tsize_t TIFFScanlineSize(TIFF*); extern tsize_t TIFFRasterScanlineSize(TIFF*); extern tsize_t TIFFStripSize(TIFF*); extern tsize_t TIFFVStripSize(TIFF*, uint32); extern tsize_t TIFFTileRowSize(TIFF*); extern tsize_t TIFFTileSize(TIFF*); extern tsize_t TIFFVTileSize(TIFF*, uint32); extern uint32 TIFFDefaultStripSize(TIFF*, uint32); extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern int TIFFFileno(TIFF*); extern int TIFFGetMode(TIFF*); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern uint32 TIFFCurrentRow(TIFF*); extern tdir_t TIFFCurrentDirectory(TIFF*); extern uint32 TIFFCurrentDirOffset(TIFF*); extern tstrip_t TIFFCurrentStrip(TIFF*); extern ttile_t TIFFCurrentTile(TIFF*); extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, tdir_t); extern int TIFFSetSubDirectory(TIFF*, uint32); extern int TIFFUnlinkDirectory(TIFF*, tdir_t); extern int TIFFSetField(TIFF*, ttag_t, ...); extern int TIFFVSetField(TIFF*, ttag_t, va_list); extern int TIFFWriteDirectory(TIFF *); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); #endif extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern void TIFFError(const char*, const char*, ...); extern void TIFFWarning(const char*, const char*, ...); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); extern ttile_t TIFFNumberOfTiles(TIFF*); extern tsize_t TIFFReadTile(TIFF*, tdata_t, uint32, uint32, uint32, tsample_t); extern tsize_t TIFFWriteTile(TIFF*, tdata_t, uint32, uint32, uint32, tsample_t); extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); extern tstrip_t TIFFNumberOfStrips(TIFF*); extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); extern void TIFFSetWriteOffset(TIFF*, toff_t); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16*, unsigned long); extern void TIFFSwabArrayOfLong(uint32*, unsigned long); extern void TIFFSwabArrayOfDouble(double*, unsigned long); extern void TIFFReverseBits(unsigned char *, unsigned long); extern const unsigned char* TIFFGetBitRevTable(int); #if defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ t, tsize_t); extern void TIFFSetWriteOffset(TIFF*, toff_t); extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16*, unsigned long); extern void TIFFSwabArrayOfLong(uint32*, unsigned long); extern void TIFFSwabArrayOfDouble(double*, unsigned long); extern void TIFFReverseBits(unsigned char *,tiff-v3.4beta018/libtiff/tiffiop.h000444 004341 000024 00000025537 06003062734 016615 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffiop.h,v 1.73 1995/07/07 02:30:23 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _TIFFIOP_ #define _TIFFIOP_ /* * ``Library-private'' definitions. */ /* * UNIX systems should run the configure script to generate * a port.h file that reflects the system capabilities. * Doing this obviates all the dreck done in tiffcomp.h. */ #if defined(unix) || defined(__unix) #include "port.h" #include "tiffconf.h" #else #include "tiffconf.h" #include "tiffcomp.h" #endif #include "tiffio.h" #include "tif_dir.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* * Typedefs for ``method pointers'' used internally. */ typedef unsigned char tidataval_t; /* internal image data value type */ typedef tidataval_t* tidata_t; /* reference to internal image data */ typedef void (*TIFFVoidMethod)(TIFF*); typedef int (*TIFFBoolMethod)(TIFF*); typedef int (*TIFFPreMethod)(TIFF*, tsample_t); typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); typedef int (*TIFFSeekMethod)(TIFF*, uint32); typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); struct tiff { char* tif_name; /* name of open file */ int tif_fd; /* open file descriptor */ int tif_mode; /* open mode (O_*) */ uint32 tif_flags; #define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ #define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ #define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ #define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ #define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ #define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ #define TIFF_SWAB 0x0080 /* byte swap file information */ #define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ #define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ #define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ #define TIFF_MAPPED 0x0800 /* file is mapped into memory */ #define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ #define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ #define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ toff_t tif_diroff; /* file offset of current directory */ toff_t tif_nextdiroff; /* file offset of following directory */ TIFFDirectory tif_dir; /* internal rep of current directory */ TIFFHeader tif_header; /* file's header block */ tidata_t tif_clientdir; /* client TIFF directory */ const int* tif_typeshift; /* data type shift counts */ const long* tif_typemask; /* data type masks */ uint32 tif_row; /* current scanline */ tdir_t tif_curdir; /* current directory (index) */ tstrip_t tif_curstrip; /* current strip for read/write */ toff_t tif_curoff; /* current offset for read/write */ toff_t tif_dataoff; /* current offset for writing dir */ #if SUBIFD_SUPPORT uint16 tif_nsubifd; /* remaining subifds to write */ toff_t tif_subifdoff; /* offset for patching SubIFD link */ #endif /* tiling support */ uint32 tif_col; /* current column (offset by row too) */ ttile_t tif_curtile; /* current tile for read/write */ tsize_t tif_tilesize; /* # of bytes in a tile */ /* compression scheme hooks */ TIFFBoolMethod tif_setupdecode;/* called once before predecode */ TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ TIFFBoolMethod tif_setupencode;/* called once before preencode */ TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ TIFFCodeMethod tif_decodetile; /* tile decoding routine */ TIFFCodeMethod tif_encodetile; /* tile encoding routine */ TIFFVoidMethod tif_close; /* cleanup-on-close routine */ TIFFSeekMethod tif_seek; /* position within a strip routine */ TIFFVoidMethod tif_cleanup; /* cleanup state routine */ TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ tidata_t tif_data; /* compression scheme private data */ /* input/output buffering */ tsize_t tif_scanlinesize;/* # of bytes in a scanline */ tsize_t tif_scanlineskew;/* scanline skew for reading strips */ tidata_t tif_rawdata; /* raw data buffer */ tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ tidata_t tif_rawcp; /* current spot in raw buffer */ tsize_t tif_rawcc; /* bytes unread from raw buffer */ /* memory-mapped file support */ tidata_t tif_base; /* base of mapped file */ toff_t tif_size; /* size of mapped file region (bytes) */ TIFFMapFileProc tif_mapproc; /* map file method */ TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ /* input/output callback methods */ thandle_t tif_clientdata; /* callback parameter */ TIFFReadWriteProc tif_readproc; /* read method */ TIFFReadWriteProc tif_writeproc;/* write method */ TIFFSeekProc tif_seekproc; /* lseek method */ TIFFCloseProc tif_closeproc; /* close method */ TIFFSizeProc tif_sizeproc; /* filesize method */ /* post-decoding support */ TIFFPostMethod tif_postdecode; /* post decoding routine */ /* tag support */ TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ int tif_nfields; /* # entries in registered tag table */ TIFFVSetMethod tif_vsetfield; /* tag set routine */ TIFFVGetMethod tif_vgetfield; /* tag get routine */ TIFFPrintMethod tif_printdir; /* directory print routine */ }; #define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) #define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) #define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) #define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) #define TIFFReadFile(tif, buf, size) \ ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) #define TIFFWriteFile(tif, buf, size) \ ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) #define TIFFSeekFile(tif, off, whence) \ ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) #define TIFFCloseFile(tif) \ ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) #define TIFFGetFileSize(tif) \ ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) #define TIFFMapFileContents(tif, paddr, psize) \ ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) #define TIFFUnmapFileContents(tif, addr, size) \ ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) /* * Default Read/Seek/Write definitions. */ #ifndef ReadOK #define ReadOK(tif, buf, size) \ (TIFFReadFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) #endif #ifndef SeekOK #define SeekOK(tif, off) \ (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) #endif #ifndef WriteOK #define WriteOK(tif, buf, size) \ (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) #endif /* NB: the uint32 casts are to silence certain ANSI-C compilers */ #define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) #define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y))) #if defined(__cplusplus) extern "C" { #endif extern int _TIFFgetMode(const char*, const char*); extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); extern int _TIFFNoSeek(TIFF*, uint32); extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); extern int TIFFFlushData1(TIFF*); extern void TIFFFreeDirectory(TIFF*); extern int TIFFDefaultDirectory(TIFF*); extern int TIFFSetCompressionScheme(TIFF*, int); extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); extern void _TIFFsetByteArray(void**, void*, long); extern void _TIFFsetString(char**, char*); extern void _TIFFsetShortArray(uint16**, uint16*, long); extern void _TIFFsetLongArray(uint32**, uint32*, long); extern void _TIFFsetFloatArray(float**, float*, long); extern void _TIFFsetDoubleArray(double**, double*, long); extern void _TIFFprintAscii(FILE*, const char*); extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler); GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler); extern int TIFFInitDumpMode(TIFF*, int); #ifdef PACKBITS_SUPPORT extern int TIFFInitPackBits(TIFF*, int); #endif #ifdef CCITT_SUPPORT extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); #endif #ifdef THUNDER_SUPPORT extern int TIFFInitThunderScan(TIFF*, int); #endif #ifdef NEXT_SUPPORT extern int TIFFInitNeXT(TIFF*, int); #endif #ifdef LZW_SUPPORT extern int TIFFInitLZW(TIFF*, int); #endif #ifdef OJPEG_SUPPORT extern int TIFFInitOJPEG(TIFF*, int); #endif #ifdef JPEG_SUPPORT extern int TIFFInitJPEG(TIFF*, int); #endif #ifdef JBIG_SUPPORT extern int TIFFInitJBIG(TIFF*, int); #endif #ifdef ZIP_SUPPORT extern int TIFFInitZIP(TIFF*, int); #endif extern TIFFCodec _TIFFBuiltinCODECS[]; #if defined(__cplusplus) } #endif #endif /* _TIFFIOP_ */ tThunderScan(TIFF*, int); #endif #ifdef NEXT_SUPPORT extern int TIFFInitNeXT(TIFF*, int); #endif #ifdef LZW_SUPPORT extern int TIFFInitLZW(TIFF*, int); #endif #itiff-v3.4beta018/libtiff/mkg3states.c000444 004341 000024 00000021716 06003062734 017230 0ustar00samuser000000 000000 /* "$Header: /usr/people/sam/tiff/libtiff/RCS/mkg3states.c,v 1.31 1995/07/17 01:27:30 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ /* Initialise fax decoder tables * Decoder support is derived, with permission, from the code * in Frank Cringle's viewfax program; * Copyright (C) 1990, 1995 Frank D. Cringle. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tif_fax3.h" #define streq(a,b) (strcmp(a,b) == 0) /* NB: can't use names in tif_fax3.h 'cuz they are declared const */ TIFFFaxTabEnt MainTable[128]; TIFFFaxTabEnt WhiteTable[4096]; TIFFFaxTabEnt BlackTable[8192]; struct proto { uint16 code; /* right justified, lsb-first, zero filled */ uint16 val; /* (pixel count)<<4 + code width */ }; static struct proto Pass[] = { { 0x0008, 4 }, { 0, 0 } }; static struct proto Horiz[] = { { 0x0004, 3 }, { 0, 0 } }; static struct proto V0[] = { { 0x0001, 1 }, { 0, 0 } }; static struct proto VR[] = { { 0x0006, (1<<4)+3 }, { 0x0030, (2<<4)+6 }, { 0x0060, (3<<4)+7 }, { 0, 0 } }; static struct proto VL[] = { { 0x0002, (1<<4)+3 }, { 0x0010, (2<<4)+6 }, { 0x0020, (3<<4)+7 }, { 0, 0 } }; static struct proto Ext[] = { { 0x0040, 7 }, { 0, 0 } }; static struct proto EOLV[] = { { 0x0000, 7 }, { 0, 0 } }; static struct proto MakeUpW[] = { { 0x001b, 1029 }, { 0x0009, 2053 }, { 0x003a, 3078 }, { 0x0076, 4103 }, { 0x006c, 5128 }, { 0x00ec, 6152 }, { 0x0026, 7176 }, { 0x00a6, 8200 }, { 0x0016, 9224 }, { 0x00e6, 10248 }, { 0x0066, 11273 }, { 0x0166, 12297 }, { 0x0096, 13321 }, { 0x0196, 14345 }, { 0x0056, 15369 }, { 0x0156, 16393 }, { 0x00d6, 17417 }, { 0x01d6, 18441 }, { 0x0036, 19465 }, { 0x0136, 20489 }, { 0x00b6, 21513 }, { 0x01b6, 22537 }, { 0x0032, 23561 }, { 0x0132, 24585 }, { 0x00b2, 25609 }, { 0x0006, 26630 }, { 0x01b2, 27657 }, { 0, 0 } }; static struct proto MakeUpB[] = { { 0x03c0, 1034 }, { 0x0130, 2060 }, { 0x0930, 3084 }, { 0x0da0, 4108 }, { 0x0cc0, 5132 }, { 0x02c0, 6156 }, { 0x0ac0, 7180 }, { 0x06c0, 8205 }, { 0x16c0, 9229 }, { 0x0a40, 10253 }, { 0x1a40, 11277 }, { 0x0640, 12301 }, { 0x1640, 13325 }, { 0x09c0, 14349 }, { 0x19c0, 15373 }, { 0x05c0, 16397 }, { 0x15c0, 17421 }, { 0x0dc0, 18445 }, { 0x1dc0, 19469 }, { 0x0940, 20493 }, { 0x1940, 21517 }, { 0x0540, 22541 }, { 0x1540, 23565 }, { 0x0b40, 24589 }, { 0x1b40, 25613 }, { 0x04c0, 26637 }, { 0x14c0, 27661 }, { 0, 0 } }; static struct proto MakeUp[] = { { 0x0080, 28683 }, { 0x0180, 29707 }, { 0x0580, 30731 }, { 0x0480, 31756 }, { 0x0c80, 32780 }, { 0x0280, 33804 }, { 0x0a80, 34828 }, { 0x0680, 35852 }, { 0x0e80, 36876 }, { 0x0380, 37900 }, { 0x0b80, 38924 }, { 0x0780, 39948 }, { 0x0f80, 40972 }, { 0, 0 } }; static struct proto TermW[] = { { 0x00ac, 8 }, { 0x0038, 22 }, { 0x000e, 36 }, { 0x0001, 52 }, { 0x000d, 68 }, { 0x0003, 84 }, { 0x0007, 100 }, { 0x000f, 116 }, { 0x0019, 133 }, { 0x0005, 149 }, { 0x001c, 165 }, { 0x0002, 181 }, { 0x0004, 198 }, { 0x0030, 214 }, { 0x000b, 230 }, { 0x002b, 246 }, { 0x0015, 262 }, { 0x0035, 278 }, { 0x0072, 295 }, { 0x0018, 311 }, { 0x0008, 327 }, { 0x0074, 343 }, { 0x0060, 359 }, { 0x0010, 375 }, { 0x000a, 391 }, { 0x006a, 407 }, { 0x0064, 423 }, { 0x0012, 439 }, { 0x000c, 455 }, { 0x0040, 472 }, { 0x00c0, 488 }, { 0x0058, 504 }, { 0x00d8, 520 }, { 0x0048, 536 }, { 0x00c8, 552 }, { 0x0028, 568 }, { 0x00a8, 584 }, { 0x0068, 600 }, { 0x00e8, 616 }, { 0x0014, 632 }, { 0x0094, 648 }, { 0x0054, 664 }, { 0x00d4, 680 }, { 0x0034, 696 }, { 0x00b4, 712 }, { 0x0020, 728 }, { 0x00a0, 744 }, { 0x0050, 760 }, { 0x00d0, 776 }, { 0x004a, 792 }, { 0x00ca, 808 }, { 0x002a, 824 }, { 0x00aa, 840 }, { 0x0024, 856 }, { 0x00a4, 872 }, { 0x001a, 888 }, { 0x009a, 904 }, { 0x005a, 920 }, { 0x00da, 936 }, { 0x0052, 952 }, { 0x00d2, 968 }, { 0x004c, 984 }, { 0x00cc, 1000 }, { 0x002c, 1016 }, { 0, 0 } }; static struct proto TermB[] = { { 0x03b0, 10 }, { 0x0002, 19 }, { 0x0003, 34 }, { 0x0001, 50 }, { 0x0006, 67 }, { 0x000c, 84 }, { 0x0004, 100 }, { 0x0018, 117 }, { 0x0028, 134 }, { 0x0008, 150 }, { 0x0010, 167 }, { 0x0050, 183 }, { 0x0070, 199 }, { 0x0020, 216 }, { 0x00e0, 232 }, { 0x0030, 249 }, { 0x03a0, 266 }, { 0x0060, 282 }, { 0x0040, 298 }, { 0x0730, 315 }, { 0x00b0, 331 }, { 0x01b0, 347 }, { 0x0760, 363 }, { 0x00a0, 379 }, { 0x0740, 395 }, { 0x00c0, 411 }, { 0x0530, 428 }, { 0x0d30, 444 }, { 0x0330, 460 }, { 0x0b30, 476 }, { 0x0160, 492 }, { 0x0960, 508 }, { 0x0560, 524 }, { 0x0d60, 540 }, { 0x04b0, 556 }, { 0x0cb0, 572 }, { 0x02b0, 588 }, { 0x0ab0, 604 }, { 0x06b0, 620 }, { 0x0eb0, 636 }, { 0x0360, 652 }, { 0x0b60, 668 }, { 0x05b0, 684 }, { 0x0db0, 700 }, { 0x02a0, 716 }, { 0x0aa0, 732 }, { 0x06a0, 748 }, { 0x0ea0, 764 }, { 0x0260, 780 }, { 0x0a60, 796 }, { 0x04a0, 812 }, { 0x0ca0, 828 }, { 0x0240, 844 }, { 0x0ec0, 860 }, { 0x01c0, 876 }, { 0x0e40, 892 }, { 0x0140, 908 }, { 0x01a0, 924 }, { 0x09a0, 940 }, { 0x0d40, 956 }, { 0x0340, 972 }, { 0x05a0, 988 }, { 0x0660, 1004 }, { 0x0e60, 1020 }, { 0, 0 } }; static struct proto EOLH[] = { { 0x0000, 11 }, { 0, 0 } }; static void FillTable(TIFFFaxTabEnt *T, int Size, struct proto *P, int State) { int limit = 1 << Size; while (P->val) { int width = P->val & 15; int param = P->val >> 4; int incr = 1 << width; int code; for (code = P->code; code < limit; code += incr) { TIFFFaxTabEnt *E = T+code; E->State = State; E->Width = width; E->Param = param; } P++; } } static char* storage_class = ""; static char* const_class = ""; static int packoutput = 1; WriteTable(FILE* fd, const TIFFFaxTabEnt* T, int Size, const char* name) { int i; char* sep; fprintf(fd, "%s %s TIFFFaxTabEnt %s[%d] = {", storage_class, const_class, name, Size); if (packoutput) { sep = "\n"; for (i = 0; i < Size; i++) { fprintf(fd, "%s%d,%d,%d", sep, T->State, T->Width, T->Param); if (((i+1) % 12) == 0) sep = ",\n"; else sep = ","; T++; } } else { sep = "\n "; for (i = 0; i < Size; i++) { fprintf(fd, "%s%3d,%3d,%4d", sep, T->State, T->Width, T->Param); if (((i+1) % 6) == 0) sep = ",\n "; else sep = ","; T++; } } fprintf(fd, "\n};\n"); } /* initialise the huffman code tables */ main(int argc, char* argv[]) { FILE* fd; char* outputfile; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:s:p")) != -1) switch (c) { case 'c': const_class = optarg; break; case 's': storage_class = optarg; break; case 'p': packoutput = 0; break; case '?': fprintf(stderr, "usage: %s [-c const] [-s storage] [-p] file\n", argv[0]); exit(-1); } outputfile = optind < argc ? argv[optind] : "g3states.h"; fd = fopen(outputfile, "w"); if (fd == NULL) { fprintf(stderr, "%s: %s: Cannot create output file.\n", argv[0], outputfile); exit(-2); } FillTable(MainTable, 7, Pass, S_Pass); FillTable(MainTable, 7, Horiz, S_Horiz); FillTable(MainTable, 7, V0, S_V0); FillTable(MainTable, 7, VR, S_VR); FillTable(MainTable, 7, VL, S_VL); FillTable(MainTable, 7, Ext, S_Ext); FillTable(MainTable, 7, EOLV, S_EOL); FillTable(WhiteTable, 12, MakeUpW, S_MakeUpW); FillTable(WhiteTable, 12, MakeUp, S_MakeUp); FillTable(WhiteTable, 12, TermW, S_TermW); FillTable(WhiteTable, 12, EOLH, S_EOL); FillTable(BlackTable, 13, MakeUpB, S_MakeUpB); FillTable(BlackTable, 13, MakeUp, S_MakeUp); FillTable(BlackTable, 13, TermB, S_TermB); FillTable(BlackTable, 13, EOLH, S_EOL); fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); fprintf(fd, " mkg3states program */\n"); fprintf(fd, "#include \"tiff.h\"\n"); fprintf(fd, "#include \"tif_fax3.h\"\n"); WriteTable(fd, MainTable, 128, "TIFFFaxMainTable"); WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable"); WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable"); fclose(fd); exit(0); } FillTable(BlackTable, 13, TermB, S_TermB); tiff-v3.4beta018/libtiff/mkspans.c000444 004341 000024 00000004315 06003062735 016614 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/mkspans.c,v 1.9 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffcomp.h" /* * Hack program to construct tables used to find * runs of zeros and ones in Group 3 Fax encoding. */ dumparray(name, runs) char *name; unsigned char runs[256]; { register int i; register char *sep; printf("static u_char %s[256] = {\n", name); sep = " "; for (i = 0; i < 256; i++) { printf("%s%d", sep, runs[i]); if (((i + 1) % 16) == 0) { printf(", /* 0x%02x - 0x%02x */\n", i-15, i); sep = " "; } else sep = ", "; } printf("\n};\n"); } main() { unsigned char runs[2][256]; memset(runs[0], 0, 256*sizeof (char)); memset(runs[1], 0, 256*sizeof (char)); { register int run, runlen, i; runlen = 1; for (run = 0x80; run != 0xff; run = (run>>1)|0x80) { for (i = run-1; i >= 0; i--) { runs[1][run|i] = runlen; runs[0][(~(run|i)) & 0xff] = runlen; } runlen++; } runs[1][0xff] = runs[0][0] = 8; } dumparray("bruns", runs[0]); dumparray("wruns", runs[1]); } ; sep = " "; } else sep = ", "; } printf("\n};\n"); } main() { unsigned char runs[2][256]; memset(runs[0], 0, 256*sizeof (char)); memset(runs[1], 0, 256*sizeof (char)); { register int run, runlen, i; runlen = 1; for (run = 0x80; run != 0xff; run = (run>>1)|0x80) { for (i = run-1;tiff-v3.4beta018/libtiff/tif_apple.c000444 004341 000024 00000014057 06003062735 017107 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_apple.c,v 1.19 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 Macintosh-specific routines. * * These routines use only Toolbox and high-level File Manager traps. * They make no calls to the THINK C "unix" compatibility library. Also, * malloc is not used directly but it is still referenced internally by * the ANSI library in rare cases. Heap fragmentation by the malloc ring * buffer is therefore minimized. * * O_RDONLY and O_RDWR are treated identically here. The tif_mode flag is * checked in TIFFWriteCheck(). * * Create below fills in a blank creator signature and sets the file type * to 'TIFF'. It is much better for the application to do this by Create'ing * the file first and TIFFOpen'ing it later. */ #include "tiffiop.h" #include #include #include #ifdef applec #define CtoPstr c2pstr #endif static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { return (FSRead((short) fd, (long*) &size, (char*) buf) == noErr ? size : (tsize_t) -1); } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return (FSWrite((short) fd, (long*) &size, (char*) buf) == noErr ? size : (tsize_t) -1); } static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { long fpos, size; if (GetEOF((short) fd, &size) != noErr) return EOF; (void) GetFPos((short) fd, &fpos); switch (whence) { case SEEK_CUR: if (off + fpos > size) SetEOF((short) fd, off + fpos); if (SetFPos((short) fd, fsFromMark, off) != noErr) return EOF; break; case SEEK_END: if (off > 0) SetEOF((short) fd, off + size); if (SetFPos((short) fd, fsFromStart, off + size) != noErr) return EOF; break; case SEEK_SET: if (off > size) SetEOF((short) fd, off); if (SetFPos((short) fd, fsFromStart, off) != noErr) return EOF; break; } return (toff_t)(GetFPos((short) fd, &fpos) == noErr ? fpos : EOF); } static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { } static int _tiffCloseProc(thandle_t fd) { return (FSClose((short) fd)); } static toff_t _tiffSizeProc(thandle_t fd) { long size; if (GetEOF((short) fd, &size) != noErr) { TIFFError("_tiffSizeProc", "%s: Cannot get file size"); return (-1L); } return ((toff_t) size); } /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (thandle_t) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; Str255 pname; FInfo finfo; short fref; OSErr err; strcpy((char*) pname, name); CtoPstr((char*) pname); switch (_TIFFgetMode(mode, module)) { default: return ((TIFF*) 0); case O_RDWR | O_CREAT | O_TRUNC: if (GetFInfo(pname, 0, &finfo) == noErr) FSDelete(pname, 0); /* fall through */ case O_RDWR | O_CREAT: if ((err = GetFInfo(pname, 0, &finfo)) == fnfErr) { if (Create(pname, 0, ' ', 'TIFF') != noErr) goto badCreate; if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; } else if (err == noErr) { if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; } else goto badOpen; break; case O_RDONLY: case O_RDWR: if (FSOpen(pname, 0, &fref) != noErr) goto badOpen; break; } return (TIFFFdOpen((int) fref, name, mode)); badCreate: TIFFError(module, "%s: Cannot create", name); return ((TIFF*) 0); badOpen: TIFFError(module, "%s: Cannot open", name); return ((TIFF*) 0); } void _TIFFmemset(tdata_t p, int v, tsize_t c) { memset(p, v, (size_t) c); } void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) { memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { return (memcmp(p1, p2, (size_t) c)); } tdata_t _TIFFmalloc(tsize_t s) { return (NewPtr((size_t) s)); } void _TIFFfree(tdata_t p) { DisposePtr(p); } tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { Ptr n = p; SetPtrSize(p, (size_t) s); if (MemError() && (n = NewPtr((size_t) s)) != NULL) { BlockMove(p, n, GetPtrSize(p)); DisposePtr(p); } return ((tdata_t) n); } static void appleWarningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler; static void appleErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler; ngHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = appleWarningHandler; static void appleErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrortiff-v3.4beta018/libtiff/tif_atari.c000444 004341 000024 00000012167 06003062736 017107 0ustar00samuser000000 000000 /* "$Header: /usr/people/sam/tiff/libtiff/RCS/tif_atari.c,v 1.4 1995/06/06 23:49:31 sam Exp $" */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 ATARI-specific Routines. */ #include "tiffiop.h" #if defined(__TURBOC__) #include #include #else #include #include #endif #ifndef O_ACCMODE #define O_ACCMODE 3 #endif #include #define AEFILNF -33 static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { long r; r = Fread((int) fd, size, buf); if (r < 0) { errno = (int)-r; r = -1; } return r; } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { long r; r = Fwrite((int) fd, size, buf); if (r < 0) { errno = (int)-r; r = -1; } return r; } static toff_t _tiffSeekProc(thandle_t fd, off_t off, int whence) { char buf[256]; long current_off, expected_off, new_off; if (whence == SEEK_END || off <= 0) return Fseek(off, (int) fd, whence); current_off = Fseek(0, (int) fd, SEEK_CUR); /* find out where we are */ if (whence == SEEK_SET) expected_off = off; else expected_off = off + current_off; new_off = Fseek(off, (int) fd, whence); if (new_off == expected_off) return new_off; /* otherwise extend file -- zero filling the hole */ if (new_off < 0) /* error? */ new_off = Fseek(0, (int) fd, SEEK_END); /* go to eof */ _TIFFmemset(buf, 0, sizeof(buf)); while (expected_off > new_off) { off = expected_off - new_off; if (off > sizeof(buf)) off = sizeof(buf); if ((current_off = Fwrite((int) fd, off, buf)) != off) return (current_off > 0) ? new_off + current_off : new_off; new_off += off; } return new_off; } static int _tiffCloseProc(thandle_t fd) { long r; r = Fclose((int) fd); if (r < 0) { errno = (int)-r; r = -1; } return (int)r; } static toff_t _tiffSizeProc(thandle_t fd) { long pos, eof; pos = Fseek(0, (int) fd, SEEK_CUR); eof = Fseek(0, (int) fd, SEEK_END); Fseek(pos, (int) fd, SEEK_SET); return eof; } static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { } /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (thandle_t) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m; long fd; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); if (m & O_TRUNC) { fd = Fcreate(name, 0); } else { fd = Fopen(name, m & O_ACCMODE); if (fd == AEFILNF && m & O_CREAT) fd = Fcreate(name, 0); } if (fd < 0) errno = (int)fd; if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF*)0); } return (TIFFFdOpen(fd, name, mode)); } #include tdata_t _TIFFmalloc(tsize_t s) { return (malloc((size_t) s)); } void _TIFFfree(tdata_t p) { free(p); } tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { return (realloc(p, (size_t) s)); } void _TIFFmemset(tdata_t p, int v, size_t c) { memset(p, v, (size_t) c); } void _TIFFmemcpy(tdata_t d, const tdata_t s, size_t c) { memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { return (memcmp(p1, p2, (size_t) c)); } static void atariWarningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = atariWarningHandler; static void atariErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = atariErrorHandler; ngHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = atariWarningHandler; static void atariErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", mtiff-v3.4beta018/libtiff/tif_aux.c000444 004341 000024 00000013542 06003062736 016602 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_aux.c,v 1.31 1995/07/18 23:13:19 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Auxiliary Support Routines. */ #include "tiffiop.h" #ifdef COLORIMETRY_SUPPORT #include static void TIFFDefaultTransferFunction(TIFFDirectory* td) { uint16 **tf = td->td_transferfunction; long i, n = 1<td_bitspersample; tf[0] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); tf[0][0] = 0; for (i = 1; i < n; i++) { double t = (double)i/((double) n-1.); tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); } if (td->td_samplesperpixel - td->td_extrasamples > 1) { tf[1] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); _TIFFmemcpy(tf[1], tf[0], n * sizeof (uint16)); tf[2] = (uint16 *)_TIFFmalloc(n * sizeof (uint16)); _TIFFmemcpy(tf[2], tf[0], n * sizeof (uint16)); } } static void TIFFDefaultRefBlackWhite(TIFFDirectory* td) { int i; td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)); for (i = 0; i < 3; i++) { td->td_refblackwhite[2*i+0] = 0; td->td_refblackwhite[2*i+1] = (float)((1L<td_bitspersample)-1L); } } #endif /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. * * NB: We use the value in the directory, rather than * explcit values so that defaults exist only one * place in the library -- in TIFFDefaultDirectory. */ int TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) { TIFFDirectory *td = &tif->tif_dir; if (TIFFVGetField(tif, tag, ap)) return (1); switch (tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, uint32 *) = td->td_subfiletype; return (1); case TIFFTAG_BITSPERSAMPLE: *va_arg(ap, uint16 *) = td->td_bitspersample; return (1); case TIFFTAG_THRESHHOLDING: *va_arg(ap, uint16 *) = td->td_threshholding; return (1); case TIFFTAG_FILLORDER: *va_arg(ap, uint16 *) = td->td_fillorder; return (1); case TIFFTAG_ORIENTATION: *va_arg(ap, uint16 *) = td->td_orientation; return (1); case TIFFTAG_SAMPLESPERPIXEL: *va_arg(ap, uint16 *) = td->td_samplesperpixel; return (1); case TIFFTAG_ROWSPERSTRIP: *va_arg(ap, uint32 *) = td->td_rowsperstrip; return (1); case TIFFTAG_MINSAMPLEVALUE: *va_arg(ap, uint16 *) = td->td_minsamplevalue; return (1); case TIFFTAG_MAXSAMPLEVALUE: *va_arg(ap, uint16 *) = td->td_maxsamplevalue; return (1); case TIFFTAG_PLANARCONFIG: *va_arg(ap, uint16 *) = td->td_planarconfig; return (1); case TIFFTAG_RESOLUTIONUNIT: *va_arg(ap, uint16 *) = td->td_resolutionunit; return (1); #ifdef CMYK_SUPPORT case TIFFTAG_DOTRANGE: *va_arg(ap, uint16 *) = 0; *va_arg(ap, uint16 *) = (1<td_bitspersample)-1; return (1); case TIFFTAG_INKSET: *va_arg(ap, uint16 *) = td->td_inkset; return (1); #endif case TIFFTAG_EXTRASAMPLES: *va_arg(ap, uint16 *) = td->td_extrasamples; *va_arg(ap, uint16 **) = td->td_sampleinfo; return (1); case TIFFTAG_MATTEING: *va_arg(ap, uint16 *) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); return (1); case TIFFTAG_TILEDEPTH: *va_arg(ap, uint32 *) = td->td_tiledepth; return (1); case TIFFTAG_DATATYPE: *va_arg(ap, uint16 *) = td->td_sampleformat-1; return (1); case TIFFTAG_IMAGEDEPTH: *va_arg(ap, uint32 *) = td->td_imagedepth; return (1); #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: if (!td->td_ycbcrcoeffs) { td->td_ycbcrcoeffs = (float *) _TIFFmalloc(3*sizeof (float)); /* defaults are from CCIR Recommendation 601-1 */ td->td_ycbcrcoeffs[0] = 0.299f; td->td_ycbcrcoeffs[1] = 0.587f; td->td_ycbcrcoeffs[2] = 0.114f; } *va_arg(ap, float **) = td->td_ycbcrcoeffs; return (1); case TIFFTAG_YCBCRSUBSAMPLING: *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; return (1); case TIFFTAG_YCBCRPOSITIONING: *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; return (1); #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_TRANSFERFUNCTION: if (!td->td_transferfunction[0]) TIFFDefaultTransferFunction(td); *va_arg(ap, uint16 **) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { *va_arg(ap, uint16 **) = td->td_transferfunction[1]; *va_arg(ap, uint16 **) = td->td_transferfunction[2]; } return (1); case TIFFTAG_REFERENCEBLACKWHITE: if (!td->td_refblackwhite) TIFFDefaultRefBlackWhite(td); *va_arg(ap, float **) = td->td_refblackwhite; return (1); #endif } return (0); } /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. */ int TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) { int ok; va_list ap; va_start(ap, tag); ok = TIFFVGetFieldDefaulted(tif, tag, ap); va_end(ap); return (ok); } = td->td_transferfunction[2]; } return (1); case TIFFTAG_REFERENCEBLACKWHITE: if (!td->td_refblackwhite) TIFFDefaultRefBlackWhite(td); *va_arg(aptiff-v3.4beta018/libtiff/tif_close.c000444 004341 000024 00000003471 06003062737 017113 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_close.c,v 1.29 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" void TIFFClose(TIFF* tif) { if (tif->tif_mode != O_RDONLY) /* * Flush buffered data and directory (if dirty). */ TIFFFlush(tif); if (tif->tif_cleanup) (*tif->tif_cleanup)(tif); TIFFFreeDirectory(tif); if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) _TIFFfree(tif->tif_rawdata); if (isMapped(tif)) TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size); (void) TIFFCloseFile(tif); if (tif->tif_fieldinfo) _TIFFfree(tif->tif_fieldinfo); _TIFFfree(tif); } #include "tiffiop.h" void TIFFClose(TIFF* tif) { if (tif->tif_mode != O_RDONLY) /* * Flush buffered data and directory (if dirty). */ TIFFFlush(tif); if (tif->tif_cleanup) (*tif->tif_tiff-v3.4beta018/libtiff/tif_codec.c000444 004341 000024 00000006237 06003062737 017066 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_codec.c,v 1.4 1995/06/30 00:58:51 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 * * Builtin Compression Scheme Configuration Support. */ #include "tiffiop.h" static int NotConfigured(TIFF*, int); #ifndef LZW_SUPPORT #define TIFFInitLZW NotConfigured #endif #ifndef PACKBITS_SUPPORT #define TIFFInitPackbits NotConfigured #endif #ifndef THUNDER_SUPPORT #define TIFFInitThunderScan NotConfigured #endif #ifndef NEXT_SUPPORT #define TIFFInitNeXT NotConfigured #endif #ifndef JPEG_SUPPORT #define TIFFInitJPEG NotConfigured #endif #ifndef OJPEG_SUPPORT #define TIFFInitOJPEG NotConfigured #endif #ifndef CCITT_SUPPORT #define TIFFInitCCITTRLE NotConfigured #define TIFFInitCCITTRLEW NotConfigured #define TIFFInitCCITTFax3 NotConfigured #define TIFFInitCCITTFax4 NotConfigured #endif #ifndef JBIG_SUPPORT #define TIFFInitJBIG NotConfigured #endif #ifndef ZIP_SUPPORT #define TIFFInitZIP NotConfigured #endif /* * Compression schemes statically built into the library. */ TIFFCodec _TIFFBuiltinCODECS[] = { { "Null", COMPRESSION_NONE, TIFFInitDumpMode }, { "LZW", COMPRESSION_LZW, TIFFInitLZW }, { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, { "CCITT Group3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, { "CCITT Group4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, { NULL }, }; static int NotConfigured(TIFF* tif, int scheme) { const TIFFCodec* c = TIFFFindCODEC(scheme); TIFFError(tif->tif_name, "%s compression support is not configured", c->name); return (0); } "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, { "CCITT Group3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, { "CCITT Group4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, { NULL }, }; static int NotConfigured(TIFF* tif, intiff-v3.4beta018/libtiff/tif_compress.c000444 004341 000024 00000012625 06003062740 017634 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_compress.c,v 1.48 1995/07/07 02:30:16 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 * * Compression Scheme Configuration Support. */ #include "tiffiop.h" static int TIFFNoEncode(TIFF* tif, char* method) { const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); TIFFError(tif->tif_name, "%s %s encoding is not implemented", c->name, method); return (-1); } int _TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "scanline")); } int _TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "strip")); } int _TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "tile")); } static int TIFFNoDecode(TIFF* tif, char* method) { const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); TIFFError(tif->tif_name, "%s %s decoding is not implemented", c->name, method); return (-1); } int _TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "scanline")); } int _TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "strip")); } int _TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "tile")); } int _TIFFNoSeek(TIFF* tif, uint32 off) { (void) off; TIFFError(tif->tif_name, "Compression algorithm does not support random access"); return (0); } int _TIFFNoPreCode(TIFF* tif, tsample_t s) { (void) tif; (void) s; return (1); } static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); } static void _TIFFvoid(TIFF* tif) { (void) tif; } int TIFFSetCompressionScheme(TIFF* tif, int scheme) { const TIFFCodec *c = TIFFFindCODEC(scheme); if (!c) { TIFFError(tif->tif_name, "Unknown data compression algorithm %u (0x%x)", scheme, scheme); return (0); } tif->tif_setupdecode = _TIFFtrue; tif->tif_predecode = _TIFFNoPreCode; tif->tif_decoderow = _TIFFNoRowDecode; tif->tif_decodestrip = _TIFFNoStripDecode; tif->tif_decodetile = _TIFFNoTileDecode; tif->tif_setupencode = _TIFFtrue; tif->tif_preencode = _TIFFNoPreCode; tif->tif_postencode = _TIFFtrue; tif->tif_encoderow = _TIFFNoRowEncode; tif->tif_encodestrip = _TIFFNoStripEncode; tif->tif_encodetile = _TIFFNoTileEncode; tif->tif_close = _TIFFvoid; tif->tif_seek = _TIFFNoSeek; tif->tif_cleanup = _TIFFvoid; tif->tif_defstripsize = _TIFFDefaultStripSize; tif->tif_deftilesize = _TIFFDefaultTileSize; tif->tif_flags &= ~TIFF_NOBITREV; return ((*c->init)(tif, scheme)); } /* * Other compression schemes may be registered. Registered * schemes can also override the builtin versions provided * by this library. */ typedef struct _codec { struct _codec* next; TIFFCodec* info; } codec_t; static codec_t* registeredCODECS = NULL; const TIFFCodec* TIFFFindCODEC(uint16 scheme) { const TIFFCodec* c; codec_t* cd; for (cd = registeredCODECS; cd; cd = cd->next) if (cd->info->scheme == scheme) return ((const TIFFCodec*) cd->info); for (c = _TIFFBuiltinCODECS; c->name; c++) if (c->scheme == scheme) return (c); return ((const TIFFCodec*) 0); } TIFFCodec* TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) { codec_t* cd = (codec_t*) _TIFFmalloc(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1); if (cd != NULL) { cd->info = (TIFFCodec*) ((tidata_t) cd + sizeof (codec_t)); cd->info->name = (char*) ((tidata_t) cd->info + sizeof (TIFFCodec)); strcpy(cd->info->name, name); cd->info->scheme = scheme; cd->info->init = init; cd->next = registeredCODECS; registeredCODECS = cd; } else TIFFError("TIFFRegisterCODEC", "No space to registere compression scheme %s", name); return (cd->info); } void TIFFUnRegisterCODEC(TIFFCodec* c) { codec_t* cd; codec_t** pcd; for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next) if (cd->info == c) { *pcd = cd->next; _TIFFfree(cd); return; } TIFFError("TIFFUnRegisterCODEC", "Cannot remove compression scheme %s; not registered", c->name); } fo->init = init; cd->next = registeredCODECS; registeredCODECS = cd; } else TIFFError("TIFFRegisterCtiff-v3.4beta018/libtiff/tif_dir.h000444 004341 000024 00000016160 06003062740 016562 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.h,v 1.2 1995/06/30 05:46:47 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _TIFFDIR_ #define _TIFFDIR_ /* * ``Library-private'' Directory-related Definitions. */ /* * Internal format of a TIFF directory entry. */ typedef struct { #define FIELD_SETLONGS 3 /* bit vector of fields that are set */ u_long td_fieldsset[FIELD_SETLONGS]; uint32 td_imagewidth, td_imagelength, td_imagedepth; uint32 td_tilewidth, td_tilelength, td_tiledepth; uint32 td_subfiletype; uint16 td_bitspersample; uint16 td_sampleformat; uint16 td_compression; uint16 td_photometric; uint16 td_threshholding; uint16 td_fillorder; uint16 td_orientation; uint16 td_samplesperpixel; uint32 td_rowsperstrip; uint16 td_minsamplevalue, td_maxsamplevalue; double td_sminsamplevalue, td_smaxsamplevalue; float td_xresolution, td_yresolution; uint16 td_resolutionunit; uint16 td_planarconfig; float td_xposition, td_yposition; uint16 td_pagenumber[2]; uint16* td_colormap[3]; uint16 td_halftonehints[2]; uint16 td_extrasamples; uint16* td_sampleinfo; char* td_documentname; char* td_artist; char* td_datetime; char* td_hostcomputer; char* td_imagedescription; char* td_make; char* td_model; char* td_software; char* td_pagename; tstrip_t td_stripsperimage; tstrip_t td_nstrips; /* size of offset & bytecount arrays */ uint32* td_stripoffset; uint32* td_stripbytecount; #if SUBIFD_SUPPORT uint16 td_nsubifd; uint32* td_subifd; #endif #ifdef YCBCR_SUPPORT float* td_ycbcrcoeffs; uint16 td_ycbcrsubsampling[2]; uint16 td_ycbcrpositioning; #endif #ifdef COLORIMETRY_SUPPORT float* td_whitepoint; float* td_primarychromas; float* td_refblackwhite; uint16* td_transferfunction[3]; #endif #ifdef CMYK_SUPPORT uint16 td_inkset; uint16 td_dotrange[2]; char* td_inknames; char* td_targetprinter; #endif } TIFFDirectory; /* * Field flags used to indicate fields that have * been set in a directory, and to reference fields * when manipulating a directory. */ /* * FIELD_IGNORE is used to signify tags that are to * be processed but otherwise ignored. This permits * antiquated tags to be quietly read and discarded. * Note that a bit *is* allocated for ignored tags; * this is understood by the directory reading logic * which uses this fact to avoid special-case handling */ #define FIELD_IGNORE 0 /* multi-item fields */ #define FIELD_IMAGEDIMENSIONS 1 #define FIELD_TILEDIMENSIONS 2 #define FIELD_RESOLUTION 3 #define FIELD_POSITION 4 /* single-item fields */ #define FIELD_SUBFILETYPE 5 #define FIELD_BITSPERSAMPLE 6 #define FIELD_COMPRESSION 7 #define FIELD_PHOTOMETRIC 8 #define FIELD_THRESHHOLDING 9 #define FIELD_FILLORDER 10 #define FIELD_DOCUMENTNAME 11 #define FIELD_IMAGEDESCRIPTION 12 #define FIELD_MAKE 13 #define FIELD_MODEL 14 #define FIELD_ORIENTATION 15 #define FIELD_SAMPLESPERPIXEL 16 #define FIELD_ROWSPERSTRIP 17 #define FIELD_MINSAMPLEVALUE 18 #define FIELD_MAXSAMPLEVALUE 19 #define FIELD_PLANARCONFIG 20 #define FIELD_PAGENAME 21 #define FIELD_RESOLUTIONUNIT 22 #define FIELD_PAGENUMBER 23 #define FIELD_STRIPBYTECOUNTS 24 #define FIELD_STRIPOFFSETS 25 #define FIELD_COLORMAP 26 #define FIELD_ARTIST 27 #define FIELD_DATETIME 28 #define FIELD_HOSTCOMPUTER 29 #define FIELD_SOFTWARE 30 #define FIELD_EXTRASAMPLES 31 #define FIELD_SAMPLEFORMAT 32 #define FIELD_SMINSAMPLEVALUE 33 #define FIELD_SMAXSAMPLEVALUE 34 #define FIELD_IMAGEDEPTH 35 #define FIELD_TILEDEPTH 36 #define FIELD_HALFTONEHINTS 37 #define FIELD_YCBCRCOEFFICIENTS 38 #define FIELD_YCBCRSUBSAMPLING 39 #define FIELD_YCBCRPOSITIONING 40 #define FIELD_REFBLACKWHITE 41 #define FIELD_WHITEPOINT 42 #define FIELD_PRIMARYCHROMAS 43 #define FIELD_TRANSFERFUNCTION 44 #define FIELD_INKSET 45 #define FIELD_INKNAMES 46 #define FIELD_DOTRANGE 47 #define FIELD_TARGETPRINTER 48 #define FIELD_SUBIFD 49 #define FIELD_CODEC 50 /* base of codec-private tags */ #define FIELD_LAST (32*FIELD_SETLONGS-1) #define TIFFExtractData(tif, type, v) \ ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \ (v) & (tif)->tif_typemask[type])) #define TIFFInsertData(tif, type, v) \ ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \ ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \ (v) & (tif)->tif_typemask[type])) typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count (-1 for unknown) */ short field_writecount; /* write count (-1 for unknown) */ TIFFDataType field_type; /* type of associated data */ u_short field_bit; /* bit in fieldsset bit vector */ u_char field_oktochange; /* if true, can change while writing */ u_char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ extern const int tiffDataWidth[]; /* table of tag datatype widths */ #define BITn(n) (((u_long)1L)<<((n)&0x1f)) #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) #define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) #if defined(__cplusplus) extern "C" { #endif extern void _TIFFSetupFieldInfo(TIFF*); extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); extern void _TIFFPrintFieldInfo(TIFF*, FILE*); extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttag_t); extern TIFFDataType _TIFFSampleToTagType(TIFF*); #if defined(__cplusplus) } #endif #endif /* _TIFFDIR_ */ f)) #define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) #if defined(__cplusplus) extern "C" { #endif extern void _TIFFSetupFieldInfo(TIFF*); extern void _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int); extern void _TIFFPrintFieldInfo(TIFF*, FILE*); extern const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF*, ttag_t, TIFFDataType); extern const TIFFFieldInfo* _TIFFFieldWithTag(TIFF*, ttatiff-v3.4beta018/libtiff/tif_dir.c000444 004341 000024 00000065256 06003062741 016570 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dir.c,v 1.151 1995/07/19 00:39:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Directory Tag Get & Set Routines. * (and also some miscellaneous stuff) */ #include "tiffiop.h" /* * These are used in the backwards compatibility code... */ #define DATATYPE_VOID 0 /* !untyped data */ #define DATATYPE_INT 1 /* !signed integer data */ #define DATATYPE_UINT 2 /* !unsigned integer data */ #define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ void _TIFFsetByteArray(void** vpp, void* vp, long n) { if (*vpp) _TIFFfree(*vpp), *vpp = 0; if (vp && (*vpp = (void*) _TIFFmalloc(n))) _TIFFmemcpy(*vpp, vp, n); } void _TIFFsetString(char** cpp, char* cp) { _TIFFsetByteArray((void**) cpp, (void*) cp, (long) (strlen(cp)+1)); } void _TIFFsetShortArray(uint16** wpp, uint16* wp, long n) { _TIFFsetByteArray((void**) wpp, (void*) wp, n*sizeof (uint16)); } void _TIFFsetLongArray(uint32** lpp, uint32* lp, long n) { _TIFFsetByteArray((void**) lpp, (void*) lp, n*sizeof (uint32)); } void _TIFFsetFloatArray(float** fpp, float* fp, long n) { _TIFFsetByteArray((void**) fpp, (void*) fp, n*sizeof (float)); } void _TIFFsetDoubleArray(double** dpp, double* dp, long n) { _TIFFsetByteArray((void**) dpp, (void*) dp, n*sizeof (double)); } /* * Install extra samples information. */ static int setExtraSamples(TIFFDirectory* td, va_list ap, int* v) { uint16* va; int i; *v = va_arg(ap, int); if ((uint16) *v > td->td_samplesperpixel) return (0); va = va_arg(ap, uint16*); if (*v > 0 && va == NULL) /* typically missing param */ return (0); for (i = 0; i < *v; i++) if (va[i] > EXTRASAMPLE_UNASSALPHA) return (0); td->td_extrasamples = (uint16) *v; _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); return (1); } static int _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; int status = 1; uint32 v32; int i, v; switch (tag) { case TIFFTAG_SUBFILETYPE: td->td_subfiletype = va_arg(ap, uint32); break; case TIFFTAG_IMAGEWIDTH: td->td_imagewidth = va_arg(ap, uint32); break; case TIFFTAG_IMAGELENGTH: td->td_imagelength = va_arg(ap, uint32); break; case TIFFTAG_BITSPERSAMPLE: td->td_bitspersample = (uint16) va_arg(ap, int); /* * If the data require post-decoding processing * to byte-swap samples, set it up here. Note * that since tags are required to be ordered, * compression code can override this behaviour * in the setup method if it wants to roll the * post decoding work in with its normal work. */ if (tif->tif_flags & TIFF_SWAB) { if (td->td_bitspersample == 16) tif->tif_postdecode = _TIFFSwab16BitData; else if (td->td_bitspersample == 32) tif->tif_postdecode = _TIFFSwab32BitData; else if (td->td_bitspersample == 64) tif->tif_postdecode = _TIFFSwab64BitData; } break; case TIFFTAG_COMPRESSION: v = va_arg(ap, int) & 0xffff; /* * If we're changing the compression scheme, * the notify the previous module so that it * can cleanup any state it's setup. */ if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { if (td->td_compression == v) break; (*tif->tif_cleanup)(tif); tif->tif_flags &= ~TIFF_CODERSETUP; } /* * Setup new compression routine state. */ if (status = TIFFSetCompressionScheme(tif, v)) td->td_compression = v; break; case TIFFTAG_PHOTOMETRIC: td->td_photometric = (uint16) va_arg(ap, int); break; case TIFFTAG_THRESHHOLDING: td->td_threshholding = (uint16) va_arg(ap, int); break; case TIFFTAG_FILLORDER: v = va_arg(ap, int); if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) goto badvalue; td->td_fillorder = (uint16) v; break; case TIFFTAG_DOCUMENTNAME: _TIFFsetString(&td->td_documentname, va_arg(ap, char*)); break; case TIFFTAG_ARTIST: _TIFFsetString(&td->td_artist, va_arg(ap, char*)); break; case TIFFTAG_DATETIME: _TIFFsetString(&td->td_datetime, va_arg(ap, char*)); break; case TIFFTAG_HOSTCOMPUTER: _TIFFsetString(&td->td_hostcomputer, va_arg(ap, char*)); break; case TIFFTAG_IMAGEDESCRIPTION: _TIFFsetString(&td->td_imagedescription, va_arg(ap, char*)); break; case TIFFTAG_MAKE: _TIFFsetString(&td->td_make, va_arg(ap, char*)); break; case TIFFTAG_MODEL: _TIFFsetString(&td->td_model, va_arg(ap, char*)); break; case TIFFTAG_SOFTWARE: _TIFFsetString(&td->td_software, va_arg(ap, char*)); break; case TIFFTAG_ORIENTATION: v = va_arg(ap, int); if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) { TIFFWarning(tif->tif_name, "Bad value %ld for \"%s\" tag ignored", v, _TIFFFieldWithTag(tif, tag)->field_name); } else td->td_orientation = (uint16) v; break; case TIFFTAG_SAMPLESPERPIXEL: /* XXX should cross check -- e.g. if pallette, then 1 */ v = va_arg(ap, int); if (v == 0) goto badvalue; td->td_samplesperpixel = (uint16) v; break; case TIFFTAG_ROWSPERSTRIP: v32 = va_arg(ap, uint32); if (v32 == 0) goto badvalue32; td->td_rowsperstrip = v32; if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { td->td_tilelength = v32; td->td_tilewidth = td->td_imagewidth; } break; case TIFFTAG_MINSAMPLEVALUE: td->td_minsamplevalue = (uint16) va_arg(ap, int); break; case TIFFTAG_MAXSAMPLEVALUE: td->td_maxsamplevalue = (uint16) va_arg(ap, int); break; case TIFFTAG_SMINSAMPLEVALUE: td->td_sminsamplevalue = (double) va_arg(ap, dblparam_t); break; case TIFFTAG_SMAXSAMPLEVALUE: td->td_smaxsamplevalue = (double) va_arg(ap, dblparam_t); break; case TIFFTAG_XRESOLUTION: td->td_xresolution = (float) va_arg(ap, dblparam_t); break; case TIFFTAG_YRESOLUTION: td->td_yresolution = (float) va_arg(ap, dblparam_t); break; case TIFFTAG_PLANARCONFIG: v = va_arg(ap, int); if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) goto badvalue; td->td_planarconfig = (uint16) v; break; case TIFFTAG_PAGENAME: _TIFFsetString(&td->td_pagename, va_arg(ap, char*)); break; case TIFFTAG_XPOSITION: td->td_xposition = (float) va_arg(ap, dblparam_t); break; case TIFFTAG_YPOSITION: td->td_yposition = (float) va_arg(ap, dblparam_t); break; case TIFFTAG_RESOLUTIONUNIT: v = va_arg(ap, int); if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) goto badvalue; td->td_resolutionunit = (uint16) v; break; case TIFFTAG_PAGENUMBER: td->td_pagenumber[0] = (uint16) va_arg(ap, int); td->td_pagenumber[1] = (uint16) va_arg(ap, int); break; case TIFFTAG_HALFTONEHINTS: td->td_halftonehints[0] = (uint16) va_arg(ap, int); td->td_halftonehints[1] = (uint16) va_arg(ap, int); break; case TIFFTAG_COLORMAP: v32 = (uint32)(1L<td_bitspersample); _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); break; case TIFFTAG_EXTRASAMPLES: if (!setExtraSamples(td, ap, &v)) goto badvalue; break; case TIFFTAG_MATTEING: td->td_extrasamples = (uint16) (va_arg(ap, int) != 0); if (td->td_extrasamples) { uint16 sv = EXTRASAMPLE_ASSOCALPHA; _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); } break; case TIFFTAG_TILEWIDTH: v32 = va_arg(ap, uint32); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarning(tif->tif_name, "Nonstandard tile width %d, convert file", v32); } td->td_tilewidth = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILELENGTH: v32 = va_arg(ap, uint32); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarning(tif->tif_name, "Nonstandard tile length %d, convert file", v32); } td->td_tilelength = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILEDEPTH: v32 = va_arg(ap, uint32); if (v32 == 0) goto badvalue32; td->td_tiledepth = v32; break; case TIFFTAG_DATATYPE: v = va_arg(ap, int); switch (v) { case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; default: goto badvalue; } td->td_sampleformat = (uint16) v; break; case TIFFTAG_SAMPLEFORMAT: v = va_arg(ap, int); if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_VOID < v) goto badvalue; td->td_sampleformat = (uint16) v; break; case TIFFTAG_IMAGEDEPTH: td->td_imagedepth = va_arg(ap, uint32); break; #if SUBIFD_SUPPORT case TIFFTAG_SUBIFD: if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { td->td_nsubifd = (uint16) va_arg(ap, int); _TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*), (long) td->td_nsubifd); } else { TIFFError(tif->tif_name, "Sorry, cannot nest SubIFDs"); status = 0; } break; #endif #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: _TIFFsetFloatArray(&td->td_ycbcrcoeffs, va_arg(ap, float*), 3); break; case TIFFTAG_YCBCRPOSITIONING: td->td_ycbcrpositioning = (uint16) va_arg(ap, int); break; case TIFFTAG_YCBCRSUBSAMPLING: td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int); td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int); break; #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_WHITEPOINT: _TIFFsetFloatArray(&td->td_whitepoint, va_arg(ap, float*), 2); break; case TIFFTAG_PRIMARYCHROMATICITIES: _TIFFsetFloatArray(&td->td_primarychromas, va_arg(ap, float*), 6); break; case TIFFTAG_TRANSFERFUNCTION: v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; for (i = 0; i < v; i++) _TIFFsetShortArray(&td->td_transferfunction[i], va_arg(ap, uint16*), 1L<td_bitspersample); break; case TIFFTAG_REFERENCEBLACKWHITE: /* XXX should check for null range */ _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); break; #endif #ifdef CMYK_SUPPORT case TIFFTAG_INKSET: td->td_inkset = (uint16) va_arg(ap, int); break; case TIFFTAG_DOTRANGE: /* XXX should check for null range */ td->td_dotrange[0] = (uint16) va_arg(ap, int); td->td_dotrange[1] = (uint16) va_arg(ap, int); break; case TIFFTAG_INKNAMES: _TIFFsetString(&td->td_inknames, va_arg(ap, char*)); break; case TIFFTAG_TARGETPRINTER: _TIFFsetString(&td->td_targetprinter, va_arg(ap, char*)); break; #endif default: TIFFError(tif->tif_name, "Internal error, tag value botch, tag \"%s\"", _TIFFFieldWithTag(tif, tag)->field_name); status = 0; break; } if (status) { TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); tif->tif_flags |= TIFF_DIRTYDIRECT; } va_end(ap); return (status); badvalue: TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v, _TIFFFieldWithTag(tif, tag)->field_name); va_end(ap); return (0); badvalue32: TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32, _TIFFFieldWithTag(tif, tag)->field_name); va_end(ap); return (0); } /* * Return 1/0 according to whether or not * it is permissible to set the tag's value. * Note that we allow ImageLength to be changed * so that we can append and extend to images. * Any other tag may not be altered once writing * has commenced, unless its value has no effect * on the format of the data that is written. */ static int OkToChangeTag(TIFF* tif, ttag_t tag) { if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING)) { const TIFFFieldInfo *fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); /* * Consult info table to see if tag can be changed * after we've started writing. We only allow changes * to those tags that don't/shouldn't affect the * compression and/or format of the data. */ if (fip && !fip->field_oktochange) { TIFFError("TIFFSetField", "%s: Cannot modify tag \"%s\" while writing", tif->tif_name, fip->field_name); return (0); } } return (1); } /* * Record the value of a field in the * internal directory structure. The * field will be written to the file * when/if the directory structure is * updated. */ int TIFFSetField(TIFF* tif, ttag_t tag, ...) { va_list ap; int status; va_start(ap, tag); status = TIFFVSetField(tif, tag, ap); va_end(ap); return (status); } /* * Like TIFFSetField, but taking a varargs * parameter list. This routine is useful * for building higher-level interfaces on * top of the library. */ int TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) { return OkToChangeTag(tif, tag) ? (*tif->tif_vsetfield)(tif, tag, ap) : 0; } static int _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; switch (tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, uint32*) = td->td_subfiletype; break; case TIFFTAG_IMAGEWIDTH: *va_arg(ap, uint32*) = td->td_imagewidth; break; case TIFFTAG_IMAGELENGTH: *va_arg(ap, uint32*) = td->td_imagelength; break; case TIFFTAG_BITSPERSAMPLE: *va_arg(ap, uint16*) = td->td_bitspersample; break; case TIFFTAG_COMPRESSION: *va_arg(ap, uint16*) = td->td_compression; break; case TIFFTAG_PHOTOMETRIC: *va_arg(ap, uint16*) = td->td_photometric; break; case TIFFTAG_THRESHHOLDING: *va_arg(ap, uint16*) = td->td_threshholding; break; case TIFFTAG_FILLORDER: *va_arg(ap, uint16*) = td->td_fillorder; break; case TIFFTAG_DOCUMENTNAME: *va_arg(ap, char**) = td->td_documentname; break; case TIFFTAG_ARTIST: *va_arg(ap, char**) = td->td_artist; break; case TIFFTAG_DATETIME: *va_arg(ap, char**) = td->td_datetime; break; case TIFFTAG_HOSTCOMPUTER: *va_arg(ap, char**) = td->td_hostcomputer; break; case TIFFTAG_IMAGEDESCRIPTION: *va_arg(ap, char**) = td->td_imagedescription; break; case TIFFTAG_MAKE: *va_arg(ap, char**) = td->td_make; break; case TIFFTAG_MODEL: *va_arg(ap, char**) = td->td_model; break; case TIFFTAG_SOFTWARE: *va_arg(ap, char**) = td->td_software; break; case TIFFTAG_ORIENTATION: *va_arg(ap, uint16*) = td->td_orientation; break; case TIFFTAG_SAMPLESPERPIXEL: *va_arg(ap, uint16*) = td->td_samplesperpixel; break; case TIFFTAG_ROWSPERSTRIP: *va_arg(ap, uint32*) = td->td_rowsperstrip; break; case TIFFTAG_MINSAMPLEVALUE: *va_arg(ap, uint16*) = td->td_minsamplevalue; break; case TIFFTAG_MAXSAMPLEVALUE: *va_arg(ap, uint16*) = td->td_maxsamplevalue; break; case TIFFTAG_SMINSAMPLEVALUE: *va_arg(ap, double*) = td->td_sminsamplevalue; break; case TIFFTAG_SMAXSAMPLEVALUE: *va_arg(ap, double*) = td->td_smaxsamplevalue; break; case TIFFTAG_XRESOLUTION: *va_arg(ap, float*) = td->td_xresolution; break; case TIFFTAG_YRESOLUTION: *va_arg(ap, float*) = td->td_yresolution; break; case TIFFTAG_PLANARCONFIG: *va_arg(ap, uint16*) = td->td_planarconfig; break; case TIFFTAG_XPOSITION: *va_arg(ap, float*) = td->td_xposition; break; case TIFFTAG_YPOSITION: *va_arg(ap, float*) = td->td_yposition; break; case TIFFTAG_PAGENAME: *va_arg(ap, char**) = td->td_pagename; break; case TIFFTAG_RESOLUTIONUNIT: *va_arg(ap, uint16*) = td->td_resolutionunit; break; case TIFFTAG_PAGENUMBER: *va_arg(ap, uint16*) = td->td_pagenumber[0]; *va_arg(ap, uint16*) = td->td_pagenumber[1]; break; case TIFFTAG_HALFTONEHINTS: *va_arg(ap, uint16*) = td->td_halftonehints[0]; *va_arg(ap, uint16*) = td->td_halftonehints[1]; break; case TIFFTAG_COLORMAP: *va_arg(ap, uint16**) = td->td_colormap[0]; *va_arg(ap, uint16**) = td->td_colormap[1]; *va_arg(ap, uint16**) = td->td_colormap[2]; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: *va_arg(ap, uint32**) = td->td_stripoffset; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: *va_arg(ap, uint32**) = td->td_stripbytecount; break; case TIFFTAG_MATTEING: *va_arg(ap, uint16*) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); break; case TIFFTAG_EXTRASAMPLES: *va_arg(ap, uint16*) = td->td_extrasamples; *va_arg(ap, uint16**) = td->td_sampleinfo; break; case TIFFTAG_TILEWIDTH: *va_arg(ap, uint32*) = td->td_tilewidth; break; case TIFFTAG_TILELENGTH: *va_arg(ap, uint32*) = td->td_tilelength; break; case TIFFTAG_TILEDEPTH: *va_arg(ap, uint32*) = td->td_tiledepth; break; case TIFFTAG_DATATYPE: switch (td->td_sampleformat) { case SAMPLEFORMAT_UINT: *va_arg(ap, uint16*) = DATATYPE_UINT; break; case SAMPLEFORMAT_INT: *va_arg(ap, uint16*) = DATATYPE_INT; break; case SAMPLEFORMAT_IEEEFP: *va_arg(ap, uint16*) = DATATYPE_IEEEFP; break; case SAMPLEFORMAT_VOID: *va_arg(ap, uint16*) = DATATYPE_VOID; break; } break; case TIFFTAG_SAMPLEFORMAT: *va_arg(ap, uint16*) = td->td_sampleformat; break; case TIFFTAG_IMAGEDEPTH: *va_arg(ap, uint32*) = td->td_imagedepth; break; #if SUBIFD_SUPPORT case TIFFTAG_SUBIFD: *va_arg(ap, uint16*) = td->td_nsubifd; *va_arg(ap, uint32**) = td->td_subifd; break; #endif #ifdef YCBCR_SUPPORT case TIFFTAG_YCBCRCOEFFICIENTS: *va_arg(ap, float**) = td->td_ycbcrcoeffs; break; case TIFFTAG_YCBCRPOSITIONING: *va_arg(ap, uint16*) = td->td_ycbcrpositioning; break; case TIFFTAG_YCBCRSUBSAMPLING: *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; break; #endif #ifdef COLORIMETRY_SUPPORT case TIFFTAG_WHITEPOINT: *va_arg(ap, float**) = td->td_whitepoint; break; case TIFFTAG_PRIMARYCHROMATICITIES: *va_arg(ap, float**) = td->td_primarychromas; break; case TIFFTAG_TRANSFERFUNCTION: *va_arg(ap, uint16**) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { *va_arg(ap, uint16**) = td->td_transferfunction[1]; *va_arg(ap, uint16**) = td->td_transferfunction[2]; } break; case TIFFTAG_REFERENCEBLACKWHITE: *va_arg(ap, float**) = td->td_refblackwhite; break; #endif #ifdef CMYK_SUPPORT case TIFFTAG_INKSET: *va_arg(ap, uint16*) = td->td_inkset; break; case TIFFTAG_DOTRANGE: *va_arg(ap, uint16*) = td->td_dotrange[0]; *va_arg(ap, uint16*) = td->td_dotrange[1]; break; case TIFFTAG_INKNAMES: *va_arg(ap, char**) = td->td_inknames; break; case TIFFTAG_TARGETPRINTER: *va_arg(ap, char**) = td->td_targetprinter; break; #endif default: TIFFError("_TIFFVGetField", "Internal error, no value returned for tag \"%s\"", _TIFFFieldWithTag(tif, tag)->field_name); break; } return (1); } /* * Return the value of a field in the * internal directory structure. */ int TIFFGetField(TIFF* tif, ttag_t tag, ...) { int status; va_list ap; va_start(ap, tag); status = TIFFVGetField(tif, tag, ap); va_end(ap); return (status); } /* * Like TIFFGetField, but taking a varargs * parameter list. This routine is useful * for building higher-level interfaces on * top of the library. */ int TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) { const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); return (fip && TIFFFieldSet(tif, fip->field_bit) ? (*tif->tif_vgetfield)(tif, tag, ap) : 0); } #define CleanupField(member) { \ if (td->member) { \ _TIFFfree(td->member); \ td->member = 0; \ } \ } /* * Release storage associated with a directory. */ void TIFFFreeDirectory(TIFF* tif) { register TIFFDirectory *td = &tif->tif_dir; CleanupField(td_colormap[0]); CleanupField(td_colormap[1]); CleanupField(td_colormap[2]); CleanupField(td_documentname); CleanupField(td_artist); CleanupField(td_datetime); CleanupField(td_hostcomputer); CleanupField(td_imagedescription); CleanupField(td_make); CleanupField(td_model); CleanupField(td_software); CleanupField(td_pagename); CleanupField(td_sampleinfo); #if SUBIFD_SUPPORT CleanupField(td_subifd); #endif #ifdef YCBCR_SUPPORT CleanupField(td_ycbcrcoeffs); #endif #ifdef CMYK_SUPPORT CleanupField(td_inknames); CleanupField(td_targetprinter); #endif #ifdef COLORIMETRY_SUPPORT CleanupField(td_whitepoint); CleanupField(td_primarychromas); CleanupField(td_refblackwhite); CleanupField(td_transferfunction[0]); CleanupField(td_transferfunction[1]); CleanupField(td_transferfunction[2]); #endif CleanupField(td_stripoffset); CleanupField(td_stripbytecount); } #undef CleanupField /* * Client Tag extension support (from Niles Ritter). */ static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender) { TIFFExtendProc prev = _TIFFextender; _TIFFextender = extender; return (prev); } /* * Setup a default directory structure. */ int TIFFDefaultDirectory(TIFF* tif) { register TIFFDirectory* td = &tif->tif_dir; _TIFFSetupFieldInfo(tif); _TIFFmemset(td, 0, sizeof (*td)); td->td_fillorder = FILLORDER_MSB2LSB; td->td_bitspersample = 1; td->td_threshholding = THRESHHOLD_BILEVEL; td->td_orientation = ORIENTATION_TOPLEFT; td->td_samplesperpixel = 1; td->td_rowsperstrip = (uint32) -1; td->td_tilewidth = (uint32) -1; td->td_tilelength = (uint32) -1; td->td_tiledepth = 1; td->td_resolutionunit = RESUNIT_INCH; td->td_sampleformat = SAMPLEFORMAT_VOID; td->td_imagedepth = 1; #ifdef YCBCR_SUPPORT td->td_ycbcrsubsampling[0] = 2; td->td_ycbcrsubsampling[1] = 2; td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; #endif #ifdef CMYK_SUPPORT td->td_inkset = INKSET_CMYK; #endif tif->tif_postdecode = _TIFFNoPostDecode; tif->tif_vsetfield = _TIFFVSetField; tif->tif_vgetfield = _TIFFVGetField; tif->tif_printdir = NULL; /* * Give client code a chance to install their own * tag extensions & methods, prior to compression overloads. */ if (_TIFFextender) (*_TIFFextender)(tif); (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); /* * NB: The directory is marked dirty as a result of setting * up the default compression scheme. However, this really * isn't correct -- we want TIFF_DIRTYDIRECT to be set only * if the user does something. We could just do the setup * by hand, but it seems better to use the normal mechanism * (i.e. TIFFSetField). */ tif->tif_flags &= ~TIFF_DIRTYDIRECT; return (1); } static int TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off) { static const char module[] = "TIFFAdvanceDirectory"; uint16 dircount; if (!SeekOK(tif, *nextdir) || !ReadOK(tif, &dircount, sizeof (uint16))) { TIFFError(module, "%s: Error fetching directory count", tif->tif_name); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); if (off != NULL) *off = TIFFSeekFile(tif, dircount*sizeof (TIFFDirEntry), SEEK_CUR); else (void) TIFFSeekFile(tif, dircount*sizeof (TIFFDirEntry), SEEK_CUR); if (!ReadOK(tif, nextdir, sizeof (uint32))) { TIFFError(module, "%s: Error fetching directory link", tif->tif_name); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(nextdir); return (1); } /* * Set the n-th directory as the current directory. * NB: Directories are numbered starting at 0. */ int TIFFSetDirectory(TIFF* tif, tdir_t dirn) { uint32 nextdir; tdir_t n; nextdir = tif->tif_header.tiff_diroff; for (n = dirn; n > 0 && nextdir != 0; n--) if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) return (0); tif->tif_nextdiroff = nextdir; /* * Set curdir to the actual directory index. The * -1 is because TIFFReadDirectory will increment * tif_curdir after successfully reading the directory. */ tif->tif_curdir = (dirn - n) - 1; return (TIFFReadDirectory(tif)); } /* * Set the current directory to be the directory * located at the specified file offset. This interface * is used mainly to access directories linked with * the SubIFD tag (e.g. thumbnail images). */ int TIFFSetSubDirectory(TIFF* tif, uint32 diroff) { tif->tif_nextdiroff = diroff; return (TIFFReadDirectory(tif)); } /* * Return file offset of the current directory. */ uint32 TIFFCurrentDirOffset(TIFF* tif) { return (tif->tif_diroff); } /* * Return an indication of whether or not we are * at the last directory in the file. */ int TIFFLastDirectory(TIFF* tif) { return (tif->tif_nextdiroff == 0); } /* * Unlink the specified directory from the directory chain. */ int TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) { static const char module[] = "TIFFUnlinkDirectory"; uint32 nextdir; toff_t off; tdir_t n; if (tif->tif_mode == O_RDONLY) { TIFFError(module, "Can not unlink directory in read-only file"); return (0); } /* * Go to the directory before the one we want * to unlink and nab the offset of the link * field we'll need to patch. */ nextdir = tif->tif_header.tiff_diroff; off = sizeof (uint16) + sizeof (uint16); for (n = dirn-1; n > 0; n--) { if (nextdir == 0) { TIFFError(module, "Directory %d does not exist", dirn); return (0); } if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) return (0); } /* * Advance to the directory to be unlinked and fetch * the offset of the directory that follows. */ if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) return (0); /* * Go back and patch the link field of the preceding * directory to point to the offset of the directory * that follows. */ (void) TIFFSeekFile(tif, off, SEEK_SET); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&nextdir); if (!WriteOK(tif, &nextdir, sizeof (uint32))) { TIFFError(module, "Error writing directory link"); return (0); } /* * Leave directory state setup safely. We don't have * facilities for doing inserting and removing directories, * so it's safest to just invalidate everything. This * means that the caller can only append to the directory * chain. */ (*tif->tif_cleanup)(tif); if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; tif->tif_rawcc = 0; } tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); TIFFFreeDirectory(tif); TIFFDefaultDirectory(tif); tif->tif_diroff = 0; /* force link on next write */ tif->tif_nextdiroff = 0; /* next write must be at end */ tif->tif_curoff = 0; tif->tif_row = (uint32) -1; tif->tif_curstrip = (tstrip_t) -1; return (1); } (*tif->tif_cleanup)(tif); if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; tif->tif_rawcc = 0; } tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE); TIFFFreeDirectory(tif); TIFFDefaultDirectory(tif); tif->tif_diroff = 0; /* force link on ntiff-v3.4beta018/libtiff/tif_dirinfo.c000444 004341 000024 00000032761 06003062741 017437 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirinfo.c,v 1.36 1995/06/30 05:46:47 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Core Directory Tag Support. */ #include "tiffiop.h" #include /* * NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG. * If a tag can have both LONG and SHORT types * then the LONG must be placed before the SHORT for * writing to work properly. */ static const TIFFFieldInfo tiffFieldInfo[] = { { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, FIELD_SUBFILETYPE, TRUE, FALSE, "SubfileType" }, /* XXX SHORT for compatibility w/ old versions of the library */ { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, TRUE, FALSE, "SubfileType" }, { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, FIELD_SUBFILETYPE, TRUE, FALSE, "OldSubfileType" }, { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, FALSE, FALSE, "ImageWidth" }, { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, FALSE, FALSE, "ImageWidth" }, { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, FIELD_IMAGEDIMENSIONS, TRUE, FALSE, "ImageLength" }, { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDIMENSIONS, TRUE, FALSE, "ImageLength" }, { TIFFTAG_BITSPERSAMPLE, -1,-1, TIFF_SHORT, FIELD_BITSPERSAMPLE, FALSE, FALSE, "BitsPerSample" }, { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, FIELD_COMPRESSION, FALSE, FALSE, "Compression" }, { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, FIELD_PHOTOMETRIC, FALSE, FALSE, "PhotometricInterpretation" }, { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, FIELD_THRESHHOLDING, TRUE, FALSE, "Threshholding" }, { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, FALSE, "CellWidth" }, { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, FALSE, "CellLength" }, { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, FIELD_FILLORDER, FALSE, FALSE, "FillOrder" }, { TIFFTAG_DOCUMENTNAME, -1,-1, TIFF_ASCII, FIELD_DOCUMENTNAME, TRUE, FALSE, "DocumentName" }, { TIFFTAG_IMAGEDESCRIPTION, -1,-1, TIFF_ASCII, FIELD_IMAGEDESCRIPTION, TRUE, FALSE, "ImageDescription" }, { TIFFTAG_MAKE, -1,-1, TIFF_ASCII, FIELD_MAKE, TRUE, FALSE, "Make" }, { TIFFTAG_MODEL, -1,-1, TIFF_ASCII, FIELD_MODEL, TRUE, FALSE, "Model" }, { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_LONG, FIELD_STRIPOFFSETS, FALSE, FALSE, "StripOffsets" }, { TIFFTAG_STRIPOFFSETS, -1,-1, TIFF_SHORT, FIELD_STRIPOFFSETS, FALSE, FALSE, "StripOffsets" }, { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, FIELD_ORIENTATION, FALSE, FALSE, "Orientation" }, { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, FIELD_SAMPLESPERPIXEL, FALSE, FALSE, "SamplesPerPixel" }, { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, FIELD_ROWSPERSTRIP, FALSE, FALSE, "RowsPerStrip" }, { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_SHORT, FIELD_ROWSPERSTRIP, FALSE, FALSE, "RowsPerStrip" }, { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, FALSE, FALSE, "StripByteCounts" }, { TIFFTAG_STRIPBYTECOUNTS, -1,-1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, FALSE, FALSE, "StripByteCounts" }, { TIFFTAG_MINSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MINSAMPLEVALUE, TRUE, FALSE, "MinSampleValue" }, { TIFFTAG_MAXSAMPLEVALUE, -2,-1, TIFF_SHORT, FIELD_MAXSAMPLEVALUE, TRUE, FALSE, "MaxSampleValue" }, { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, FALSE, FALSE, "XResolution" }, { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, FIELD_RESOLUTION, FALSE, FALSE, "YResolution" }, { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, FIELD_PLANARCONFIG, FALSE, FALSE, "PlanarConfiguration" }, { TIFFTAG_PAGENAME, -1,-1, TIFF_ASCII, FIELD_PAGENAME, TRUE, FALSE, "PageName" }, { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, TRUE, FALSE, "XPosition" }, { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, FIELD_POSITION, TRUE, FALSE, "YPosition" }, { TIFFTAG_FREEOFFSETS, -1,-1, TIFF_LONG, FIELD_IGNORE, FALSE, FALSE, "FreeOffsets" }, { TIFFTAG_FREEBYTECOUNTS, -1,-1, TIFF_LONG, FIELD_IGNORE, FALSE, FALSE, "FreeByteCounts" }, { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, FALSE, "GrayResponseUnit" }, { TIFFTAG_GRAYRESPONSECURVE,-1,-1, TIFF_SHORT, FIELD_IGNORE, TRUE, FALSE, "GrayResponseCurve" }, { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, FIELD_RESOLUTIONUNIT, FALSE, FALSE, "ResolutionUnit" }, { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, FIELD_PAGENUMBER, TRUE, FALSE, "PageNumber" }, { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE, TRUE, FALSE, "ColorResponseUnit" }, #ifdef COLORIMETRY_SUPPORT { TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION, TRUE, FALSE, "TransferFunction" }, #endif { TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_SOFTWARE, TRUE, FALSE, "Software" }, { TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_DATETIME, TRUE, FALSE, "DateTime" }, { TIFFTAG_ARTIST, -1,-1, TIFF_ASCII, FIELD_ARTIST, TRUE, FALSE, "Artist" }, { TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_HOSTCOMPUTER, TRUE, FALSE, "HostComputer" }, #ifdef COLORIMETRY_SUPPORT { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL,FIELD_WHITEPOINT, TRUE, FALSE, "WhitePoint" }, { TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL,FIELD_PRIMARYCHROMAS, TRUE, FALSE, "PrimaryChromaticities" }, #endif { TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP, TRUE, FALSE, "ColorMap" }, { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS, TRUE, FALSE, "HalftoneHints" }, { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, FALSE, FALSE, "TileWidth" }, { TIFFTAG_TILEWIDTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, FALSE, FALSE, "TileWidth" }, { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, FIELD_TILEDIMENSIONS, FALSE, FALSE, "TileLength" }, { TIFFTAG_TILELENGTH, 1, 1, TIFF_SHORT, FIELD_TILEDIMENSIONS, FALSE, FALSE, "TileLength" }, { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG, FIELD_STRIPOFFSETS, FALSE, FALSE, "TileOffsets" }, { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG, FIELD_STRIPBYTECOUNTS, FALSE, FALSE, "TileByteCounts" }, { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS, FALSE, FALSE, "TileByteCounts" }, #ifdef TIFFTAG_SUBIFD { TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD, TRUE, TRUE, "SubIFD" }, #endif #ifdef CMYK_SUPPORT /* 6.0 CMYK tags */ { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_INKSET, FALSE, FALSE, "InkSet" }, { TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES, TRUE, FALSE, "InkNames" }, { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, FIELD_DOTRANGE, FALSE, FALSE, "DotRange" }, { TIFFTAG_DOTRANGE, 2, 2, TIFF_BYTE, FIELD_DOTRANGE, FALSE, FALSE, "DotRange" }, { TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_TARGETPRINTER, TRUE, FALSE, "TargetPrinter" }, #endif { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES, FALSE, FALSE, "ExtraSamples" }, /* XXX for bogus Adobe Photoshop v2.5 files */ { TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_BYTE, FIELD_EXTRASAMPLES, FALSE, FALSE, "ExtraSamples" }, { TIFFTAG_SAMPLEFORMAT, -1,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, FALSE, FALSE, "SampleFormat" }, { TIFFTAG_SMINSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMINSAMPLEVALUE, TRUE, FALSE, "SMinSampleValue" }, { TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE, TRUE, FALSE, "SMaxSampleValue" }, #ifdef YCBCR_SUPPORT /* 6.0 YCbCr tags */ { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_YCBCRCOEFFICIENTS, FALSE, FALSE, "YCbCrCoefficients" }, { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING, FALSE, FALSE, "YCbCrSubsampling" }, { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING, FALSE, FALSE, "YCbCrPositioning" }, #endif #ifdef COLORIMETRY_SUPPORT { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_RATIONAL, FIELD_REFBLACKWHITE, TRUE, FALSE, "ReferenceBlackWhite" }, /* XXX temporarily accept LONG for backwards compatibility */ { TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_LONG, FIELD_REFBLACKWHITE, TRUE, FALSE, "ReferenceBlackWhite" }, #endif /* begin SGI tags */ { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, FIELD_EXTRASAMPLES, FALSE, FALSE, "Matteing" }, { TIFFTAG_DATATYPE, -2,-1, TIFF_SHORT, FIELD_SAMPLEFORMAT, FALSE, FALSE, "DataType" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, FIELD_IMAGEDEPTH, FALSE, FALSE, "ImageDepth" }, { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_SHORT, FIELD_IMAGEDEPTH, FALSE, FALSE, "ImageDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, FIELD_TILEDEPTH, FALSE, FALSE, "TileDepth" }, { TIFFTAG_TILEDEPTH, 1, 1, TIFF_SHORT, FIELD_TILEDEPTH, FALSE, FALSE, "TileDepth" }, /* end SGI tags */ }; #define N(a) (sizeof (a) / sizeof (a[0])) void _TIFFSetupFieldInfo(TIFF* tif) { if (tif->tif_fieldinfo) { _TIFFfree(tif->tif_fieldinfo); tif->tif_nfields = 0; } _TIFFMergeFieldInfo(tif, tiffFieldInfo, N(tiffFieldInfo)); } static int tagCompare(const void* a, const void* b) { const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a; const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b; int c = ta->field_tag - tb->field_tag; return (c != 0 ? c : tb->field_type - ta->field_type); } void _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n) { TIFFFieldInfo** tp; int i; if (tif->tif_nfields > 0) { tif->tif_fieldinfo = (TIFFFieldInfo**) _TIFFrealloc(tif->tif_fieldinfo, (tif->tif_nfields+n) * sizeof (TIFFFieldInfo*)); } else { tif->tif_fieldinfo = (TIFFFieldInfo**) _TIFFmalloc(n * sizeof (TIFFFieldInfo*)); } tp = &tif->tif_fieldinfo[tif->tif_nfields]; for (i = 0; i < n; i++) tp[i] = (TIFFFieldInfo*) &info[i]; /* XXX */ /* * NB: the core tags are presumed sorted correctly. */ if (tif->tif_nfields > 0) qsort(tif->tif_fieldinfo, (size_t) (tif->tif_nfields += n), sizeof (TIFFFieldInfo*), tagCompare); else tif->tif_nfields += n; } void _TIFFPrintFieldInfo(TIFF* tif, FILE* fd) { int i; 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" , i , fip->field_tag , fip->field_readcount, fip->field_writecount , fip->field_type , fip->field_bit , fip->field_oktochange ? "TRUE" : "FALSE" , fip->field_passcount ? "TRUE" : "FALSE" , fip->field_name ); } } const int tiffDataWidth[] = { 1, /* nothing */ 1, /* TIFF_BYTE */ 1, /* TIFF_ASCII */ 2, /* TIFF_SHORT */ 4, /* TIFF_LONG */ 8, /* TIFF_RATIONAL */ 1, /* TIFF_SBYTE */ 1, /* TIFF_UNDEFINED */ 2, /* TIFF_SSHORT */ 4, /* TIFF_SLONG */ 8, /* TIFF_SRATIONAL */ 4, /* TIFF_FLOAT */ 8, /* TIFF_DOUBLE */ }; /* * Return nearest TIFFDataType to the sample type of an image. */ TIFFDataType _TIFFSampleToTagType(TIFF* tif) { int bps = (int) TIFFhowmany(tif->tif_dir.td_bitspersample, 8); switch (tif->tif_dir.td_sampleformat) { case SAMPLEFORMAT_IEEEFP: return (bps == 4 ? TIFF_FLOAT : TIFF_DOUBLE); case SAMPLEFORMAT_INT: return (bps <= 1 ? TIFF_SBYTE : bps <= 2 ? TIFF_SSHORT : TIFF_SLONG); case SAMPLEFORMAT_UINT: return (bps <= 1 ? TIFF_BYTE : bps <= 2 ? TIFF_SHORT : TIFF_LONG); case SAMPLEFORMAT_VOID: return (TIFF_UNDEFINED); } /*NOTREACHED*/ return (TIFF_UNDEFINED); } const TIFFFieldInfo* _TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt) { static const TIFFFieldInfo *last = NULL; int i, n; if (last && last->field_tag == tag && (dt == TIFF_ANY || dt == last->field_type)) return (last); /* NB: if table gets big, use sorted search (e.g. binary search) */ for (i = 0, n = tif->tif_nfields; i < n; i++) { const TIFFFieldInfo* fip = tif->tif_fieldinfo[i]; if (fip->field_tag == tag && (dt == TIFF_ANY || fip->field_type == dt)) return (last = fip); } return ((const TIFFFieldInfo *)0); } #include #include const TIFFFieldInfo* _TIFFFieldWithTag(TIFF* tif, ttag_t tag) { const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY); if (!fip) { TIFFError("TIFFFieldWithTag", "Internal error, unknown tag 0x%x", (u_int) tag); assert(fip != NULL); /*NOTREACHED*/ } return (fip); } fo* fip = tif->tiff-v3.4beta018/libtiff/tif_dirread.c000444 004341 000024 00000112426 06003062742 017415 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirread.c,v 1.68 1995/06/30 05:46:47 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Directory Read Support Routines. */ #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 TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); 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); } /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ int TIFFReadDirectory(TIFF* tif) { 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; tif->tif_diroff = tif->tif_nextdiroff; if (tif->tif_diroff == 0) /* no more directories */ return (0); /* * Cleanup any previous compression state. */ if (tif->tif_curdir != (tdir_t) -1) (*tif->tif_cleanup)(tif); tif->tif_curdir++; nextdiroff = 0; if (!isMapped(tif)) { if (!SeekOK(tif, tif->tif_diroff)) { TIFFError(tif->tif_name, "Seek error accessing TIFF directory"); return (0); } if (!ReadOK(tif, &dircount, sizeof (uint16))) { TIFFError(tif->tif_name, "Can not read TIFF directory count"); return (0); } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof (TIFFDirEntry), "to read TIFF directory"); if (dir == NULL) return (0); if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { TIFFError(tif->tif_name, "Can not read TIFF directory"); goto bad; } /* * Read offset to next directory for sequential scans. */ (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); } else { toff_t off = tif->tif_diroff; if (off + sizeof (short) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory 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 directory"); if (dir == NULL) return (0); if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { TIFFError(tif->tif_name, "Can not read TIFF directory"); 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); tif->tif_nextdiroff = nextdiroff; tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ /* * 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; /* free any old stuff and reinit */ TIFFFreeDirectory(tif); TIFFDefaultDirectory(tif); /* * Electronic Arts writes gray-scale TIFF files * without a PlanarConfiguration directory entry. * Thus we setup a default value here, even though * the TIFF spec says there is no default value. */ TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); /* * Sigh, we must make a separate pass through the * directory for the following reason: * * We must process the Compression tag in the first pass * in order to merge in codec-private tag definitions (otherwise * we may get complaints about unknown tags). However, the * Compression tag may be dependent on the SamplesPerPixel * tag value because older TIFF specs permited Compression * to be written as a SamplesPerPixel-count tag entry. * Thus if we don't first figure out the correct SamplesPerPixel * tag value then we may end up ignoring the Compression tag * value because it has an incorrect count value (if the * true value of SamplesPerPixel is not 1). * * It sure would have been nice if Aldus had really thought * this stuff through carefully. */ for (dp = dir, n = dircount; n > 0; n--, dp++) { if (tif->tif_flags & TIFF_SWAB) { TIFFSwabArrayOfShort(&dp->tdir_tag, 2); TIFFSwabArrayOfLong(&dp->tdir_count, 2); } if (dp->tdir_tag == TIFFTAG_SAMPLESPERPIXEL) { if (!TIFFFetchNormalTag(tif, dp)) goto bad; dp->tdir_tag = IGNORE; } } /* * First real pass over the directory. */ fix = 0; for (dp = dir, n = dircount; n > 0; n--, dp++) { /* * Find the field information entry for this tag. */ if (dp->tdir_tag == IGNORE) continue; /* * 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 < tif->tif_fieldinfo[fix]->field_tag) { if (!diroutoforderwarning) { TIFFWarning(tif->tif_name, "invalid TIFF directory; tags are not sorted in ascending order"); diroutoforderwarning = 1; } fix = 0; /* O(n^2) */ } while (fix < tif->tif_nfields && tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) fix++; if (fix == tif->tif_nfields || tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { TIFFWarning(tif->tif_name, "unknown field with tag %d (0x%x) ignored", dp->tdir_tag, dp->tdir_tag); dp->tdir_tag = IGNORE; fix = 0; /* restart search */ continue; } /* * Null out old tags that we ignore. */ if (tif->tif_fieldinfo[fix]->field_bit == FIELD_IGNORE) { ignore: dp->tdir_tag = IGNORE; continue; } /* * Check data type. */ fip = tif->tif_fieldinfo[fix]; while (dp->tdir_type != (u_short) fip->field_type) { if (fip->field_type == TIFF_ANY) /* wildcard */ break; fip++, fix++; if (fix == tif->tif_nfields || 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; } switch (dp->tdir_tag) { case TIFFTAG_COMPRESSION: /* * The 5.0 spec says the Compression tag has * one value, while earlier specs say it has * one value per sample. Because of this, we * accept the tag if one value is supplied. */ if (dp->tdir_count == 1) { v = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; } if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || !TIFFSetField(tif, dp->tdir_tag, iv)) goto bad; dp->tdir_tag = IGNORE; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEOFFSETS: case TIFFTAG_TILEBYTECOUNTS: TIFFSetFieldBit(tif, fip->field_bit); break; case TIFFTAG_IMAGEWIDTH: case TIFFTAG_IMAGELENGTH: case TIFFTAG_IMAGEDEPTH: case TIFFTAG_TILELENGTH: case TIFFTAG_TILEWIDTH: case TIFFTAG_TILEDEPTH: case TIFFTAG_PLANARCONFIG: case TIFFTAG_ROWSPERSTRIP: if (!TIFFFetchNormalTag(tif, dp)) goto bad; dp->tdir_tag = IGNORE; break; case TIFFTAG_EXTRASAMPLES: (void) TIFFFetchExtraSamples(tif, dp); dp->tdir_tag = IGNORE; break; } } /* * Allocate directory structure and setup defaults. */ if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { MissingRequired(tif, "ImageLength"); goto bad; } if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { MissingRequired(tif, "PlanarConfiguration"); goto bad; } /* * Setup appropriate structures (by strip or by tile) */ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { td->td_nstrips = TIFFNumberOfStrips(tif); td->td_tilewidth = td->td_imagewidth; td->td_tilelength = td->td_rowsperstrip; td->td_tiledepth = td->td_imagedepth; tif->tif_flags &= ~TIFF_ISTILED; } else { td->td_nstrips = TIFFNumberOfTiles(tif); tif->tif_flags |= TIFF_ISTILED; } td->td_stripsperimage = td->td_nstrips; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets"); goto bad; } /* * Second pass: extract other information. */ for (dp = dir, n = dircount; n > 0; n--, dp++) { if (dp->tdir_tag == IGNORE) continue; switch (dp->tdir_tag) { case TIFFTAG_MINSAMPLEVALUE: case TIFFTAG_MAXSAMPLEVALUE: case TIFFTAG_BITSPERSAMPLE: /* * The 5.0 spec says the Compression tag has * one value, while earlier specs say it has * one value per sample. Because of this, we * accept the tag if one value is supplied. * * The MinSampleValue, MaxSampleValue and * BitsPerSample tags are supposed to be written * as one value/sample, but some vendors incorrectly * write one value only -- so we accept that * as well (yech). */ if (dp->tdir_count == 1) { v = TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); if (!TIFFSetField(tif, dp->tdir_tag, (int)v)) goto bad; break; } /* fall thru... */ case TIFFTAG_DATATYPE: case TIFFTAG_SAMPLEFORMAT: if (!TIFFFetchPerSampleShorts(tif, dp, &iv) || !TIFFSetField(tif, dp->tdir_tag, iv)) goto bad; break; case TIFFTAG_SMINSAMPLEVALUE: case TIFFTAG_SMAXSAMPLEVALUE: if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || !TIFFSetField(tif, dp->tdir_tag, dv)) goto bad; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripoffset)) goto bad; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: if (!TIFFFetchStripThing(tif, dp, td->td_nstrips, &td->td_stripbytecount)) goto bad; break; case TIFFTAG_COLORMAP: case TIFFTAG_TRANSFERFUNCTION: /* * TransferFunction can have either 1x or 3x data * values; Colormap can have only 3x items. */ v = 1L<td_bitspersample; if (dp->tdir_tag == TIFFTAG_COLORMAP || dp->tdir_count != (uint32) v) { if (!CheckDirCount(tif, dp, (uint32)(3*v))) break; } v *= sizeof (uint16); cp = CheckMalloc(tif, dp->tdir_count * sizeof (uint16), "to read \"TransferFunction\" tag"); if (cp != NULL) { if (TIFFFetchData(tif, dp, cp)) { /* * This deals with there being only * one array to apply to all samples. */ uint32 c = (uint32)1 << td->td_bitspersample; if (dp->tdir_count == c) v = 0; TIFFSetField(tif, dp->tdir_tag, cp, cp+v, cp+2*v); } _TIFFfree(cp); } break; case TIFFTAG_PAGENUMBER: case TIFFTAG_HALFTONEHINTS: case TIFFTAG_YCBCRSUBSAMPLING: case TIFFTAG_DOTRANGE: (void) TIFFFetchShortPair(tif, dp); break; #ifdef COLORIMETRY_SUPPORT case TIFFTAG_REFERENCEBLACKWHITE: (void) TIFFFetchRefBlackWhite(tif, dp); break; #endif /* BEGIN REV 4.0 COMPATIBILITY */ case TIFFTAG_OSUBFILETYPE: v = 0; switch (TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset)) { case OFILETYPE_REDUCEDIMAGE: v = FILETYPE_REDUCEDIMAGE; break; case OFILETYPE_PAGE: v = FILETYPE_PAGE; break; } if (v) (void) TIFFSetField(tif, TIFFTAG_SUBFILETYPE, (int)v); break; /* END REV 4.0 COMPATIBILITY */ default: (void) TIFFFetchNormalTag(tif, dp); break; } } /* * Verify Palette image has a Colormap. */ if (td->td_photometric == PHOTOMETRIC_PALETTE && !TIFFFieldSet(tif, FIELD_COLORMAP)) { MissingRequired(tif, "Colormap"); goto bad; } /* * Attempt to deal with a missing StripByteCounts tag. */ if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { /* * Some manufacturers violate the spec by not giving * the size of the strips. In this case, assume there * is one uncompressed strip of data. */ if ((td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_nstrips > 1) || (td->td_planarconfig == PLANARCONFIG_SEPARATE && td->td_nstrips != td->td_samplesperpixel)) { MissingRequired(tif, "StripByteCounts"); goto bad; } TIFFWarning(tif->tif_name, "TIFF directory is missing required \"%s\" field, calculating from imagelength", _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); #define BYTECOUNTLOOKSBAD \ (td->td_stripbytecount[0] == 0 || \ (td->td_compression == COMPRESSION_NONE && \ td->td_stripbytecount[0] > TIFFGetFileSize(tif) - td->td_stripoffset[0])) } else if (td->td_nstrips == 1 && BYTECOUNTLOOKSBAD) { /* * Plexus (and others) sometimes give a value * of zero for a tag when they don't know what * the correct value is! Try and handle the * simple case of estimating the size of a one * strip image. */ TIFFWarning(tif->tif_name, "Bogus \"%s\" field, ignoring and calculating from imagelength", _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); EstimateStripByteCounts(tif, dir, dircount); } if (dir) _TIFFfree((char *)dir); if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) td->td_maxsamplevalue = (uint16)((1L<td_bitspersample)-1); /* * Setup default compression scheme. */ if (!TIFFFieldSet(tif, FIELD_COMPRESSION)) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); #if STRIPCHOP_SUPPORT /* * Some manufacturers make life difficult by writing * large amounts of uncompressed data as a single strip. * This is contrary to the recommendations of the spec. * The following makes an attempt at breaking such images * into strips closer to the recommended 8k bytes. A * side effect, however, is that the RowsPerStrip tag * value may be changed. */ if (td->td_nstrips == 1 && td->td_compression == COMPRESSION_NONE && td->td_tilewidth == td->td_imagewidth) ChopUpSingleUncompressedStrip(tif); #endif /* * Reinitialize i/o since we are starting on a new directory. */ tif->tif_row = (uint32) -1; tif->tif_curstrip = (tstrip_t) -1; tif->tif_col = (uint32) -1; tif->tif_curtile = (ttile_t) -1; tif->tif_tilesize = TIFFTileSize(tif); tif->tif_scanlinesize = TIFFScanlineSize(tif); 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) { float v = (float) TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); TIFFCvtIEEEFloatToNative(tif, 1, &v); 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. */ static int TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp) { static char mesg[] = "to fetch tag value"; int ok = 0; const TIFFFieldInfo* fip = _TIFFFieldWithTag(tif, dp->tdir_tag); 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 ? TIFFSetField(tif, dp->tdir_tag, dp->tdir_count, cp) : TIFFSetField(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 TIFFSetField 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 ? TIFFSetField(tif, dp->tdir_tag, 1, &v) : TIFFSetField(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 ? TIFFSetField(tif, dp->tdir_tag, 1, &v32) : TIFFSetField(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 ? TIFFSetField(tif, dp->tdir_tag, 1, &v) : TIFFSetField(tif, dp->tdir_tag, v)); } break; case TIFF_DOUBLE: { double v; ok = (TIFFFetchDoubleArray(tif, dp, &v) && (fip->field_passcount ? TIFFSetField(tif, dp->tdir_tag, 1, &v) : TIFFSetField(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 = TIFFSetField(tif, dp->tdir_tag, c); } } break; } } return (ok); } #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 (TIFFFetchNormalTag(tif, dir)); /* * 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 */ stripbytes > bytecount) stripbytes = bytecount; newcounts[strip] = stripbytes; newoffsets[strip] = offset; offset += stripbytes; bytecount -= stripbytes; } /* * Replace old single strip info with multi-strip info. */ tiff-v3.4beta018/libtiff/tif_dirwrite.c000444 004341 000024 00000064317 06003062742 017641 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dirwrite.c,v 1.52 1995/06/30 05:46:47 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Directory Write Support Routines. */ #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 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 /* * Write the contents of the current directory * to the specified file. This routine doesn't * handle overwriting a directory with auxiliary * storage that's been changed. */ int TIFFWriteDirectory(TIFF* tif) { uint16 dircount; uint32 diroff; ttag_t tag; uint32 nfields; tsize_t dirsize; char* data; TIFFDirEntry* dir; TIFFDirectory* td; u_long b, fields[FIELD_SETLONGS]; int fi, nfi; if (tif->tif_mode == O_RDONLY) return (1); /* * Clear write state so that subsequent images with * different characteristics get the right buffers * setup for them. */ if (tif->tif_flags & TIFF_POSTENCODE) { tif->tif_flags &= ~TIFF_POSTENCODE; if (!(*tif->tif_postencode)(tif)) { TIFFError(tif->tif_name, "Error post-encoding before directory write"); return (0); } } (*tif->tif_close)(tif); /* shutdown encoder */ /* * Flush any data that might have been written * by the compression close+cleanup routines. */ if (tif->tif_rawcc > 0 && !TIFFFlushData1(tif)) { TIFFError(tif->tif_name, "Error flushing data before directory write"); return (0); } if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; tif->tif_rawcc = 0; } tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); td = &tif->tif_dir; /* * 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 <= FIELD_LAST; b++) if (TIFFFieldSet(tif, b)) nfields += (b < FIELD_SUBFILETYPE ? 2 : 1); dirsize = nfields * sizeof (TIFFDirEntry); data = (char*) _TIFFmalloc(dirsize); if (data == NULL) { TIFFError(tif->tif_name, "Cannot write directory, out of space"); return (0); } /* * Directory hasn't been placed yet, put * it at the end of the file and link it * into the existing directory structure. */ if (tif->tif_diroff == 0 && !TIFFLinkDirectory(tif)) goto bad; tif->tif_dataoff = (toff_t)( tif->tif_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. */ _TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields)); /* * Write out ExtraSamples tag only if * extra samples are present in the data. */ if (FieldSet(fields, FIELD_EXTRASAMPLES) && !td->td_extrasamples) { ResetFieldBit(fields, FIELD_EXTRASAMPLES); nfields--; dirsize -= sizeof (TIFFDirEntry); } /*XXX*/ for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) { const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi]; if (!FieldSet(fields, fip->field_bit)) continue; switch (fip->field_bit) { case FIELD_STRIPOFFSETS: /* * We use one field bit for both strip and tile * offsets, and so must be careful in selecting * the appropriate field descriptor (so that tags * are written in sorted order). */ tag = isTiled(tif) ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS; if (tag != fip->field_tag) continue; if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, (uint32) td->td_nstrips, td->td_stripoffset)) goto bad; break; case FIELD_STRIPBYTECOUNTS: /* * We use one field bit for both strip and tile * byte counts, and so must be careful in selecting * the appropriate field descriptor (so that tags * are written in sorted order). */ tag = isTiled(tif) ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS; if (tag != fip->field_tag) continue; if (!TIFFWriteLongArray(tif, TIFF_LONG, tag, dir, (uint32) td->td_nstrips, td->td_stripbytecount)) goto bad; break; case FIELD_ROWSPERSTRIP: TIFFSetupShortLong(tif, TIFFTAG_ROWSPERSTRIP, dir, td->td_rowsperstrip); break; case FIELD_COLORMAP: if (!TIFFWriteShortTable(tif, TIFFTAG_COLORMAP, dir, 3, td->td_colormap)) goto bad; break; case FIELD_IMAGEDIMENSIONS: TIFFSetupShortLong(tif, TIFFTAG_IMAGEWIDTH, dir++, td->td_imagewidth); TIFFSetupShortLong(tif, TIFFTAG_IMAGELENGTH, dir, td->td_imagelength); break; case FIELD_TILEDIMENSIONS: TIFFSetupShortLong(tif, TIFFTAG_TILEWIDTH, dir++, td->td_tilewidth); TIFFSetupShortLong(tif, TIFFTAG_TILELENGTH, dir, td->td_tilelength); break; case FIELD_POSITION: WriteRationalPair(TIFF_RATIONAL, TIFFTAG_XPOSITION, td->td_xposition, TIFFTAG_YPOSITION, td->td_yposition); break; case FIELD_RESOLUTION: WriteRationalPair(TIFF_RATIONAL, TIFFTAG_XRESOLUTION, td->td_xresolution, TIFFTAG_YRESOLUTION, td->td_yresolution); break; case FIELD_BITSPERSAMPLE: case FIELD_MINSAMPLEVALUE: case FIELD_MAXSAMPLEVALUE: case FIELD_SAMPLEFORMAT: if (!TIFFWritePerSampleShorts(tif, fip->field_tag, dir)) goto bad; break; case FIELD_SMINSAMPLEVALUE: case FIELD_SMAXSAMPLEVALUE: if (!TIFFWritePerSampleAnys(tif, _TIFFSampleToTagType(tif), fip->field_tag, dir)) goto bad; break; case FIELD_PAGENUMBER: case FIELD_HALFTONEHINTS: #ifdef YCBCR_SUPPORT case FIELD_YCBCRSUBSAMPLING: #endif #ifdef CMYK_SUPPORT case FIELD_DOTRANGE: #endif if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) goto bad; break; #ifdef COLORIMETRY_SUPPORT case FIELD_TRANSFERFUNCTION: if (!TIFFWriteTransferFunction(tif, dir)) goto bad; break; #endif #if SUBIFD_SUPPORT case FIELD_SUBIFD: if (!TIFFWriteNormalTag(tif, dir, fip)) goto bad; /* * Total hack: if this directory includes a SubIFD * tag then force the next directories to be * written as ``sub directories'' of this one. This * is used to write things like thumbnails and * image masks that one wants to keep out of the * normal directory linkage access mechanism. */ if (dir->tdir_count > 0) { tif->tif_flags |= TIFF_INSUBIFD; tif->tif_nsubifd = dir->tdir_count; if (dir->tdir_count > 1) tif->tif_subifdoff = dir->tdir_offset; else tif->tif_subifdoff = (uint32)( tif->tif_diroff + sizeof (uint16) + ((char*)&dir->tdir_offset-data)); } break; #endif default: if (!TIFFWriteNormalTag(tif, dir, fip)) goto bad; break; } dir++; ResetFieldBit(fields, fip->field_bit); } /* * Write directory. */ dircount = (uint16) nfields; diroff = (uint32) tif->tif_nextdiroff; 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(&diroff); } (void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET); if (!WriteOK(tif, &dircount, sizeof (dircount))) { TIFFError(tif->tif_name, "Error writing directory count"); goto bad; } if (!WriteOK(tif, data, dirsize)) { TIFFError(tif->tif_name, "Error writing directory contents"); goto bad; } if (!WriteOK(tif, &diroff, sizeof (diroff))) { TIFFError(tif->tif_name, "Error writing directory link"); goto bad; } TIFFFreeDirectory(tif); _TIFFfree(data); tif->tif_flags &= ~TIFF_DIRTYDIRECT; (*tif->tif_cleanup)(tif); /* * Reset directory-related state for subsequent * directories. */ TIFFDefaultDirectory(tif); tif->tif_diroff = 0; tif->tif_curoff = 0; tif->tif_row = (uint32) -1; tif->tif_curstrip = (tstrip_t) -1; return (1); bad: _TIFFfree(data); return (0); } #undef WriteRationalPair /* * Process tags that are not special cased. */ static int TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip) { 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) { TIFFGetField(tif, fip->field_tag, &wc, &wp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &wp); if (!WRITEF(TIFFWriteShortArray, wp)) return (0); } else { uint16 sv; TIFFGetField(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) { TIFFGetField(tif, fip->field_tag, &wc, &lp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &lp); if (!WRITEF(TIFFWriteLongArray, lp)) return (0); } else { /* XXX handle LONG->SHORT conversion */ TIFFGetField(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) { TIFFGetField(tif, fip->field_tag, &wc, &fp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &fp); if (!WRITEF(TIFFWriteRationalArray, fp)) return (0); } else { float fv; TIFFGetField(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) { TIFFGetField(tif, fip->field_tag, &wc, &fp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &fp); if (!WRITEF(TIFFWriteFloatArray, fp)) return (0); } else { float fv; TIFFGetField(tif, fip->field_tag, &fv); if (!WRITEF(TIFFWriteFloatArray, &fv)) return (0); } break; case TIFF_DOUBLE: { double* dp; if (wc == (u_short) TIFF_VARIABLE) { TIFFGetField(tif, fip->field_tag, &wc, &dp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &dp); TIFFCvtNativeToIEEEDouble(tif, wc, dp); if (!TIFFWriteData(tif, dir, (char*) dp)) return (0); } break; case TIFF_ASCII: { char* cp; TIFFGetField(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) { TIFFGetField(tif, fip->field_tag, &wc, &cp); dir->tdir_count = wc; } else TIFFGetField(tif, fip->field_tag, &cp); if (!TIFFWriteByteArray(tif, dir, cp)) return (0); } break; } return (1); } #undef WRITEF /* * 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_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_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 = 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); } 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 (nextditiff-v3.4beta018/libtiff/tif_dumpmode.c000444 004341 000024 00000006014 06003062742 017610 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_dumpmode.c,v 1.39 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * "Null" Compression Algorithm Support. */ #include "tiffiop.h" /* * Encode a hunk of pixels. */ static int DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) { (void) s; while (cc > 0) { tsize_t n; n = cc; if (tif->tif_rawcc + n > tif->tif_rawdatasize) n = tif->tif_rawdatasize - tif->tif_rawcc; /* * Avoid copy if client has setup raw * data buffer to avoid extra copy. */ if (tif->tif_rawcp != pp) _TIFFmemcpy(tif->tif_rawcp, pp, n); tif->tif_rawcp += n; tif->tif_rawcc += n; pp += n; cc -= n; if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif)) return (-1); } return (1); } /* * Decode a hunk of pixels. */ static int DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { (void) s; if (tif->tif_rawcc < cc) { TIFFError(tif->tif_name, "DumpModeDecode: Not enough data for scanline %d", tif->tif_row); return (0); } /* * Avoid copy if client has setup raw * data buffer to avoid extra copy. */ if (tif->tif_rawcp != buf) _TIFFmemcpy(buf, tif->tif_rawcp, cc); tif->tif_rawcp += cc; tif->tif_rawcc -= cc; return (1); } /* * Seek forwards nrows in the current strip. */ static int DumpModeSeek(TIFF* tif, uint32 nrows) { tif->tif_rawcp += nrows * tif->tif_scanlinesize; tif->tif_rawcc -= nrows * tif->tif_scanlinesize; return (1); } /* * Initialize dump mode. */ int TIFFInitDumpMode(TIFF* tif, int scheme) { (void) scheme; tif->tif_decoderow = DumpModeDecode; tif->tif_decodestrip = DumpModeDecode; tif->tif_decodetile = DumpModeDecode; tif->tif_encoderow = DumpModeEncode; tif->tif_encodestrip = DumpModeEncode; tif->tif_encodetile = DumpModeEncode; tif->tif_seek = DumpModeSeek; return (1); } tif, uint32 nrows) { tif->tif_rawcp += nrows * tif->tif_scanlinesize; tif->tif_rawcc -= nrows * tif->tif_scanlinesize; return (1); } /* * Initialize dump mode. */ int TIFFInitDumpMode(TIFF* tif, int scheme) { (void) scheme; tif->tif_decoderow = DumpModeDecode; tif->tif_decodestrip = DumpModeDecode; tif->tif_decodetile = DumpModeDecode; tif->tif_encoderow = DumpModeEncode; tif->tif_encodestrip = DumpModeEncode; tif->tif_encodetile = DumpModeEncode; tif->tif_seek = DumpModeSeek; retiff-v3.4beta018/libtiff/tif_error.c000444 004341 000024 00000003242 06003062743 017130 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_error.c,v 1.20 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler) { TIFFErrorHandler prev = _TIFFerrorHandler; _TIFFerrorHandler = handler; return (prev); } void TIFFError(const char* module, const char* fmt, ...) { if (_TIFFerrorHandler) { va_list ap; va_start(ap, fmt); (*_TIFFerrorHandler)(module, fmt, ap); va_end(ap); } } AGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include "tiffiop.h" TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler) { TIFFErrorHandler prev = _TIFFerrorHandler; _TIFFerrorHandler = handler; return (prev); } void TIFFError(contiff-v3.4beta018/libtiff/tif_fax3.c000444 004341 000024 00000116443 06003062743 016650 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.c,v 1.128 1995/07/17 01:27:30 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" #ifdef CCITT_SUPPORT /* * TIFF Library. * * CCITT Group 3 (T.4) and Group 4 (T.6) Compression Support. * * This file contains support for decoding and encoding TIFF * compression algorithms 2, 3, 4, and 32771. * * Decoder support is derived, with permission, from the code * in Frank Cringle's viewfax program; * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tif_fax3.h" #define G3CODES #include "t4.h" #include #include /* * NB: define PURIFY if you're using purify and you want * to avoid some harmless array bounds complaints that * can happen in the _TIFFFax3fillruns routine. */ /* * Compression+decompression state blocks are * derived from this ``base state'' block. */ typedef struct { int mode; /* operating mode */ uint32 rowbytes; /* bytes in a decoded scanline */ uint32 rowpixels; /* pixels in a scanline */ uint16 cleanfaxdata; /* CleanFaxData tag */ uint32 badfaxrun; /* BadFaxRun tag */ uint32 badfaxlines; /* BadFaxLines tag */ uint32 groupoptions; /* Group 3/4 options tag */ TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ } Fax3BaseState; #define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) typedef struct { Fax3BaseState b; const u_char* bitmap; /* bit reversal table */ uint32 data; /* current i/o byte/word */ int bit; /* current i/o bit in byte */ int EOLcnt; /* count of EOL codes recognized */ TIFFFaxFillFunc fill; /* fill routine */ uint16* runs; /* b&w runs for current/previous row */ uint16* refruns; /* runs for reference line */ uint16* curruns; /* runs for current line */ } Fax3DecodeState; #define DecoderState(tif) ((Fax3DecodeState*) Fax3State(tif)) typedef struct { Fax3BaseState b; int data; /* current i/o byte */ int bit; /* current i/o bit in byte */ enum { G3_1D, G3_2D } tag; /* encoding state */ u_char* refline; /* reference line for 2d decoding */ int k; /* #rows left that can be 2d encoded */ int maxk; /* max #rows that can be 2d encoded */ } Fax3EncodeState; #define EncoderState(tif) ((Fax3EncodeState*) Fax3State(tif)) #define is2DEncoding(sp) \ (sp->b.groupoptions & GROUP3OPT_2DENCODING) #define isAligned(p,t) ((((u_long)(p)) & (sizeof (t)-1)) == 0) /* * Group 3 and Group 4 Decoding. */ /* * These macros glue the TIFF library state to * the state expected by Frank's decoder. */ #define DECLARE_STATE(tif, sp, mod) \ static const char module[] = mod; \ Fax3DecodeState* sp = DecoderState(tif); \ int a0; /* reference element */ \ int lastx = sp->b.rowpixels; /* last element in row */ \ uint32 BitAcc; /* bit accumulator */ \ int BitsAvail; /* # valid bits in BitAcc */ \ int RunLength; /* length of current run */ \ u_char* cp; /* next byte of input data */ \ u_char* ep; /* end of input data */ \ uint16* pa; /* place to stuff next run */ \ uint16* thisrun; /* current row's run array */ \ int EOLcnt; /* # EOL codes recognized */ \ const u_char* bitmap = sp->bitmap; /* input data bit reverser */ \ const TIFFFaxTabEnt* TabEnt #define DECLARE_STATE_2D(tif, sp, mod) \ DECLARE_STATE(tif, sp, mod); \ int b1; /* next change on prev line */ \ uint16* pb /* next run in reference line */\ /* * Load any state that may be changed during decoding. */ #define CACHE_STATE(tif, sp) do { \ BitAcc = sp->data; \ BitsAvail = sp->bit; \ EOLcnt = sp->EOLcnt; \ cp = (unsigned char*) tif->tif_rawcp; \ ep = cp + tif->tif_rawcc; \ } while (0) /* * Save state possibly changed during decoding. */ #define UNCACHE_STATE(tif, sp) do { \ sp->bit = BitsAvail; \ sp->data = BitAcc; \ sp->EOLcnt = EOLcnt; \ tif->tif_rawcc -= (tidata_t) cp - tif->tif_rawcp; \ tif->tif_rawcp = (tidata_t) cp; \ } while (0) /* * Setup state for decoding a strip. */ static int Fax3PreDecode(TIFF* tif, tsample_t s) { Fax3DecodeState* sp = DecoderState(tif); (void) s; assert(sp != NULL); sp->bit = 0; /* force initial read */ sp->data = 0; sp->EOLcnt = 0; /* force initial scan for EOL */ /* * Decoder assumes lsb-to-msb bit order. Note that we select * this here rather than in Fax3SetupState so that viewers can * hold the image open, fiddle with the FillOrder tag value, * and then re-decode the image. Otherwise they'd need to close * and open the image to get the state reset. */ sp->bitmap = TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); if (sp->refruns) { /* init reference line to white */ sp->refruns[0] = sp->b.rowpixels; sp->refruns[1] = 0; } return (1); } /* * Routine for handling various errors/conditions. * Note how they are "glued into the decoder" by * overriding the definitions used by the decoder. */ static void Fax3Unexpected(const char* module, TIFF* tif, uint32 a0) { TIFFError(module, "%s: Bad code word at scanline %d (x %lu)", tif->tif_name, tif->tif_row, (u_long) a0); } #define unexpected(table, a0) Fax3Unexpected(module, tif, a0) static void Fax3Extension(const char* module, TIFF* tif, uint32 a0) { TIFFError(module, "%s: Uncompressed data (not supported) at scanline %d (x %lu)", tif->tif_name, tif->tif_row, (u_long) a0); } #define extension(a0) Fax3Extension(module, tif, a0) static void Fax3BadLength(const char* module, TIFF* tif, uint32 a0, uint32 lastx) { TIFFWarning(module, "%s: %s at scanline %d (got %lu, expected %lu)", tif->tif_name, a0 < lastx ? "Premature EOL" : "Line length mismatch", tif->tif_row, (u_long) a0, (u_long) lastx); } #define badlength(a0,lastx) Fax3BadLength(module, tif, a0, lastx) static void Fax3PrematureEOF(const char* module, TIFF* tif, uint32 a0) { TIFFWarning(module, "%s: Premature EOF at scanline %d (x %lu)", tif->tif_name, tif->tif_row, (u_long) a0); } #define prematureEOF(a0) Fax3PrematureEOF(module, tif, a0) #define Nop /* * Decode the requested amount of G3 1D-encoded data. */ static int Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { DECLARE_STATE(tif, sp, "Fax3Decode1D"); (void) s; CACHE_STATE(tif, sp); thisrun = sp->curruns; while ((long)occ > 0) { a0 = 0; RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif SYNC_EOL(EOF1D); EXPAND1D(EOF1Da); (*sp->fill)(buf, thisrun, pa, lastx); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; if (occ != 0) tif->tif_row++; continue; EOF1D: /* premature EOF */ CLEANUP_RUNS(); EOF1Da: /* premature EOF */ (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); return (-1); } UNCACHE_STATE(tif, sp); return (1); } #define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } /* * Decode the requested amount of G3 2D-encoded data. */ static int Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); int is1D; /* current line is 1d/2d-encoded */ (void) s; CACHE_STATE(tif, sp); while ((long)occ > 0) { a0 = 0; RunLength = 0; pa = thisrun = sp->curruns; #ifdef FAX3_DEBUG printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", BitAcc, BitsAvail, EOLcnt); #endif SYNC_EOL(EOF2D); NeedBits8(1, EOF2D); is1D = GetBits(1); /* 1D/2D-encoding tag bit */ ClrBits(1); #ifdef FAX3_DEBUG printf(" %s\n-------------------- %d\n", is1D ? "1D" : "2D", tif->tif_row); fflush(stdout); #endif pb = sp->refruns; b1 = *pb++; if (is1D) EXPAND1D(EOF2Da); else EXPAND2D(EOF2Da); (*sp->fill)(buf, thisrun, pa, lastx); SETVAL(0); /* imaginary change for reference */ SWAP(uint16*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; if (occ != 0) tif->tif_row++; continue; EOF2D: /* premature EOF */ CLEANUP_RUNS(); EOF2Da: /* premature EOF */ (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); return (-1); } UNCACHE_STATE(tif, sp); return (1); } #undef SWAP /* * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. * For machines with 64-bit longs this is <16 bytes; otherwise * this is <8 bytes. We optimize the code here to reflect the * machine characteristics. */ #if defined(__alpha) || _MIPS_SZLONG == 64 #define FILL(n, cp) \ switch (n) { \ case 15:(cp)[14] = 0xff; case 14:(cp)[13] = 0xff; case 13: (cp)[12] = 0xff;\ case 12:(cp)[11] = 0xff; case 11:(cp)[10] = 0xff; case 10: (cp)[9] = 0xff;\ case 9: (cp)[8] = 0xff; case 8: (cp)[7] = 0xff; case 7: (cp)[6] = 0xff;\ case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; case 4: (cp)[3] = 0xff;\ case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ } #define ZERO(n, cp) \ switch (n) { \ case 15:(cp)[14] = 0; case 14:(cp)[13] = 0; case 13: (cp)[12] = 0; \ case 12:(cp)[11] = 0; case 11:(cp)[10] = 0; case 10: (cp)[9] = 0; \ case 9: (cp)[8] = 0; case 8: (cp)[7] = 0; case 7: (cp)[6] = 0; \ case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; case 4: (cp)[3] = 0; \ case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ } #else #define FILL(n, cp) \ switch (n) { \ case 7: (cp)[6] = 0xff; case 6: (cp)[5] = 0xff; case 5: (cp)[4] = 0xff; \ case 4: (cp)[3] = 0xff; case 3: (cp)[2] = 0xff; case 2: (cp)[1] = 0xff; \ case 1: (cp)[0] = 0xff; (cp) += (n); case 0: ; \ } #define ZERO(n, cp) \ switch (n) { \ case 7: (cp)[6] = 0; case 6: (cp)[5] = 0; case 5: (cp)[4] = 0; \ case 4: (cp)[3] = 0; case 3: (cp)[2] = 0; case 2: (cp)[1] = 0; \ case 1: (cp)[0] = 0; (cp) += (n); case 0: ; \ } #endif /* * Bit-fill a row according to the white/black * runs generated during G3/G4 decoding. */ void _TIFFFax3fillruns(u_char* buf, uint16* runs, uint16* erun, uint32 lastx) { static const unsigned char _fillmasks[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; u_char* cp; uint32 x, bx, run; int32 n, nw; long* lp; if ((erun-runs)&1) *erun++ = 0; x = 0; for (; runs < erun; runs += 2) { run = runs[0]; if (x+run > lastx) run = runs[0] = lastx - x; if (run) { cp = buf + (x>>3); bx = x&7; if (run > 8-bx) { if (bx) { /* align to byte boundary */ *cp++ &= 0xff << (8-bx); run -= 8-bx; } if (n = run >> 3) { /* multiple bytes to fill */ if ((n/sizeof (long)) > 1) { /* * Align to longword boundary and fill. */ for (; n && !isAligned(cp, long); n--) *cp++ = 0x00; lp = (long*) cp; nw = (int32)(n / sizeof (long)); n -= nw * sizeof (long); do { *lp++ = 0L; } while (--nw); cp = (u_char*) lp; } ZERO(n, cp); run &= 7; } #ifdef PURIFY if (run) cp[0] &= 0xff >> run; #else cp[0] &= 0xff >> run; #endif } else cp[0] &= ~(_fillmasks[run]>>bx); x += runs[0]; } run = runs[1]; if (x+run > lastx) run = runs[1] = lastx - x; if (run) { cp = buf + (x>>3); bx = x&7; if (run > 8-bx) { if (bx) { /* align to byte boundary */ *cp++ |= 0xff >> bx; run -= 8-bx; } if (n = run>>3) { /* multiple bytes to fill */ if ((n/sizeof (long)) > 1) { /* * Align to longword boundary and fill. */ for (; n && !isAligned(cp, long); n--) *cp++ = 0xff; lp = (long*) cp; nw = (int32)(n / sizeof (long)); n -= nw * sizeof (long); do { *lp++ = -1L; } while (--nw); cp = (u_char*) lp; } FILL(n, cp); run &= 7; } #ifdef PURIFY if (run) cp[0] |= 0xff00 >> run; #else cp[0] |= 0xff00 >> run; #endif } else cp[0] |= _fillmasks[run]>>bx; x += runs[1]; } } assert(x == lastx); } #undef ZERO #undef FILL /* * Setup G3/G4-related compression/decompression state * before data is processed. This routine is called once * per image -- it sets up different state based on whether * or not decoding or encoding is being done and whether * 1D- or 2D-encoded data is involved. */ static int Fax3SetupState(TIFF* tif) { TIFFDirectory* td = &tif->tif_dir; Fax3BaseState* sp = Fax3State(tif); long rowbytes, rowpixels; int needsRefLine; if (td->td_bitspersample != 1) { TIFFError(tif->tif_name, "Bits/sample must be 1 for Group 3/4 encoding/decoding"); return (0); } /* * Calculate the scanline/tile widths. */ if (isTiled(tif)) { rowbytes = TIFFTileRowSize(tif); rowpixels = td->td_tilewidth; } else { rowbytes = TIFFScanlineSize(tif); rowpixels = td->td_imagewidth; } sp->rowbytes = (uint32) rowbytes; sp->rowpixels = (uint32) rowpixels; /* * Allocate any additional space required for decoding/encoding. */ needsRefLine = ( (sp->groupoptions & GROUP3OPT_2DENCODING) || td->td_compression == COMPRESSION_CCITTFAX4 ); if (tif->tif_mode == O_RDONLY) { /* 1d/2d decoding */ Fax3DecodeState* dsp = DecoderState(tif); uint32 nruns = needsRefLine ? 2*TIFFroundup(rowpixels,32) : rowpixels; dsp->runs = (uint16*) _TIFFmalloc(nruns*sizeof (uint16)); if (dsp->runs == NULL) { TIFFError("Fax3SetupState", "%s: No space for Group 3/4 run arrays", tif->tif_name); return (0); } dsp->curruns = dsp->runs; if (needsRefLine) dsp->refruns = dsp->runs + (nruns>>1); else dsp->refruns = NULL; if (is2DEncoding(dsp)) { /* NB: default is 1D routine */ tif->tif_decoderow = Fax3Decode2D; tif->tif_decodestrip = Fax3Decode2D; tif->tif_decodetile = Fax3Decode2D; } } else if (needsRefLine) { /* 2d encoding */ Fax3EncodeState* esp = EncoderState(tif); /* * 2d encoding requires a scanline * buffer for the ``reference line''; the * scanline against which delta encoding * is referenced. The reference line must * be initialized to be ``white'' (done elsewhere). */ esp->refline = (u_char*) _TIFFmalloc(rowbytes); if (esp->refline == NULL) { TIFFError("Fax3SetupState", "%s: No space for Group 3/4 reference line", tif->tif_name); return (0); } } else /* 1d encoding */ EncoderState(tif)->refline = NULL; return (1); } /* * CCITT Group 3 FAX Encoding. */ #define Fax3FlushBits(tif, sp) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ *(tif)->tif_rawcp++ = (sp)->data; \ (tif)->tif_rawcc++; \ (sp)->data = 0, (sp)->bit = 8; \ } #define _FlushBits(tif) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ *(tif)->tif_rawcp++ = data; \ (tif)->tif_rawcc++; \ data = 0, bit = 8; \ } static const int _msbmask[9] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; #define _PutBits(tif, bits, length) { \ while (length > bit) { \ data |= bits >> (length - bit); \ length -= bit; \ _FlushBits(tif); \ } \ data |= (bits & _msbmask[length]) << (bit - length); \ bit -= length; \ if (bit == 0) \ _FlushBits(tif); \ } /* * Write a variable-length bit-value to * the output stream. Values are * assumed to be at most 16 bits. */ static void Fax3PutBits(TIFF* tif, u_int bits, u_int length) { Fax3EncodeState* sp = EncoderState(tif); int bit = sp->bit; int data = sp->data; _PutBits(tif, bits, length); sp->data = data; sp->bit = bit; } /* * Write a code to the output stream. */ #define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) /* * Write the sequence of codes that describes * the specified span of zero's or one's. The * appropriate table that holds the make-up and * terminating codes is supplied. */ static void putspan(TIFF* tif, int32 span, const tableentry* tab) { Fax3EncodeState* sp = EncoderState(tif); int bit = sp->bit; int data = sp->data; u_int code, length; while (span >= 2624) { const tableentry* te = &tab[63 + (2560>>6)]; code = te->code, length = te->length; _PutBits(tif, code, length); span -= te->runlen; } if (span >= 64) { const tableentry* te = &tab[63 + (span>>6)]; assert(te->runlen == 64*(span>>6)); code = te->code, length = te->length; _PutBits(tif, code, length); span -= te->runlen; } code = tab[span].code, length = tab[span].length; _PutBits(tif, code, length); sp->data = data; sp->bit = bit; } /* * Write an EOL code to the output stream. The zero-fill * logic for byte-aligning encoded scanlines is handled * here. We also handle writing the tag bit for the next * scanline when doing 2d encoding. */ static void Fax3PutEOL(TIFF* tif) { Fax3EncodeState* sp = EncoderState(tif); int bit = sp->bit; int data = sp->data; u_int code, length; if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { /* * Force bit alignment so EOL will terminate on * a byte boundary. That is, force the bit alignment * to 16-12 = 4 before putting out the EOL code. */ int align = 8 - 4; if (align != sp->bit) { if (align > sp->bit) align = sp->bit + (8 - align); else align = sp->bit - align; code = 0; _PutBits(tif, 0, align); } } code = EOL, length = 12; if (is2DEncoding(sp)) code = (code<<1) | (sp->tag == G3_1D), length++; _PutBits(tif, code, length); sp->data = data; sp->bit = bit; } /* * Reset encoding state at the start of a strip. */ static int Fax3PreEncode(TIFF* tif, tsample_t s) { Fax3EncodeState* sp = EncoderState(tif); (void) s; assert(sp != NULL); sp->bit = 8; sp->data = 0; sp->tag = G3_1D; /* * This is necessary for Group 4; otherwise it isn't * needed because the first scanline of each strip ends * up being copied into the refline. */ if (sp->refline) _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); if (is2DEncoding(sp)) { float res = tif->tif_dir.td_yresolution; /* * The CCITT spec says that when doing 2d encoding, you * should only do it on K consecutive scanlines, where K * depends on the resolution of the image being encoded * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory * code initializes td_yresolution to 0, this code will * select a K of 2 unless the YResolution tag is set * appropriately. (Note also that we fudge a little here * and use 150 lpi to avoid problems with units conversion.) */ if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) res = (res * .3937f) / 2.54f; /* convert to inches */ sp->maxk = (res > 150 ? 4 : 2); sp->k = sp->maxk-1; } else sp->k = sp->maxk = 0; return (1); } static const u_char zeroruns[256] = { 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1f */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2f */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 - 0xaf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 - 0xbf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 - 0xcf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 - 0xdf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 - 0xef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 - 0xff */ }; static const u_char oneruns[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x0f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ }; /* * On certain systems it pays to inline * the routines that find pixel spans. */ #ifdef VAXC static int32 find0span(u_char*, int32, int32); static int32 find1span(u_char*, int32, int32); #pragma inline(find0span,find1span) #endif /* * Find a span of ones or zeros using the supplied * table. The ``base'' of the bit string is supplied * along with the start+end bit indices. */ INLINE static int32 find0span(u_char* bp, int32 bs, int32 be) { int32 bits = be - bs; int32 n, span; bp += bs>>3; /* * Check partial byte on lhs. */ if (bits > 0 && (n = (bs & 7))) { span = zeroruns[(*bp << n) & 0xff]; if (span > 8-n) /* table value too generous */ span = 8-n; if (span > bits) /* constrain span to bit range */ span = bits; if (n+span < 8) /* doesn't extend to edge of byte */ return (span); bits -= span; bp++; } else span = 0; if (bits >= 2*8*sizeof (long)) { long* lp; /* * Align to longword boundary and check longwords. */ while (!isAligned(bp, long)) { if (*bp != 0x00) return (span + zeroruns[*bp]); span += 8, bits -= 8; bp++; } lp = (long*) bp; while (bits >= 8*sizeof (long) && *lp == 0) { span += 8*sizeof (long), bits -= 8*sizeof (long); lp++; } bp = (u_char*) lp; } /* * Scan full bytes for all 0's. */ while (bits >= 8) { if (*bp != 0x00) /* end of run */ return (span + zeroruns[*bp]); span += 8, bits -= 8; bp++; } /* * Check partial byte on rhs. */ if (bits > 0) { n = zeroruns[*bp]; span += (n > bits ? bits : n); } return (span); } INLINE static int32 find1span(u_char* bp, int32 bs, int32 be) { int32 bits = be - bs; int32 n, span; bp += bs>>3; /* * Check partial byte on lhs. */ if (bits > 0 && (n = (bs & 7))) { span = oneruns[(*bp << n) & 0xff]; if (span > 8-n) /* table value too generous */ span = 8-n; if (span > bits) /* constrain span to bit range */ span = bits; if (n+span < 8) /* doesn't extend to edge of byte */ return (span); bits -= span; bp++; } else span = 0; if (bits >= 2*8*sizeof (long)) { long* lp; /* * Align to longword boundary and check longwords. */ while (!isAligned(bp, long)) { if (*bp != 0xff) return (span + oneruns[*bp]); span += 8, bits -= 8; bp++; } lp = (long*) bp; while (bits >= 8*sizeof (long) && *lp == ~0) { span += 8*sizeof (long), bits -= 8*sizeof (long); lp++; } bp = (u_char*) lp; } /* * Scan full bytes for all 1's. */ while (bits >= 8) { if (*bp != 0xff) /* end of run */ return (span + oneruns[*bp]); span += 8, bits -= 8; bp++; } /* * Check partial byte on rhs. */ if (bits > 0) { n = oneruns[*bp]; span += (n > bits ? bits : n); } return (span); } /* * Return the offset of the next bit in the range * [bs..be] that is different from the specified * color. The end, be, is returned if no such bit * exists. */ #define finddiff(_cp, _bs, _be, _color) \ (_bs + (_color ? find1span(_cp,_bs,_be) : find0span(_cp,_bs,_be))) /* * Like finddiff, but also check the starting bit * against the end in case start > end. */ #define finddiff2(_cp, _bs, _be, _color) \ (_bs < _be ? finddiff(_cp,_bs,_be,_color) : _be) /* * 1d-encode a row of pixels. The encoding is * a sequence of all-white or all-black spans * of pixels encoded with Huffman codes. */ static int Fax3Encode1DRow(TIFF* tif, u_char* bp, uint32 bits) { Fax3EncodeState* sp = EncoderState(tif); int32 bs = 0, span; for (;;) { span = find0span(bp, bs, bits); /* white span */ putspan(tif, span, TIFFFaxWhiteCodes); bs += span; if (bs >= bits) break; span = find1span(bp, bs, bits); /* black span */ putspan(tif, span, TIFFFaxBlackCodes); bs += span; if (bs >= bits) break; } if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { if (sp->bit != 8) /* byte-align */ Fax3FlushBits(tif, sp); if ((sp->b.mode&FAXMODE_WORDALIGN) && !isAligned(tif->tif_rawcp, uint16)) Fax3FlushBits(tif, sp); } return (1); } static const tableentry horizcode = { 3, 0x1 }; /* 001 */ static const tableentry passcode = { 4, 0x1 }; /* 0001 */ static const tableentry vcodes[7] = { { 7, 0x03 }, /* 0000 011 */ { 6, 0x03 }, /* 0000 11 */ { 3, 0x03 }, /* 011 */ { 1, 0x1 }, /* 1 */ { 3, 0x2 }, /* 010 */ { 6, 0x02 }, /* 0000 10 */ { 7, 0x02 } /* 0000 010 */ }; /* * 2d-encode a row of pixels. Consult the CCITT * documentation for the algorithm. */ static int Fax3Encode2DRow(TIFF* tif, u_char* bp, u_char* rp, uint32 bits) { #define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) int32 a0 = 0; int32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); int32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); int32 a2, b2; for (;;) { b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); if (b2 >= a1) { int32 d = b1 - a1; if (!(-3 <= d && d <= 3)) { /* horizontal mode */ a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); putcode(tif, &horizcode); if (a0+a1 == 0 || PIXEL(bp, a0) == 0) { putspan(tif, a1-a0, TIFFFaxWhiteCodes); putspan(tif, a2-a1, TIFFFaxBlackCodes); } else { putspan(tif, a1-a0, TIFFFaxBlackCodes); putspan(tif, a2-a1, TIFFFaxWhiteCodes); } a0 = a2; } else { /* vertical mode */ putcode(tif, &vcodes[d+3]); a0 = a1; } } else { /* pass mode */ putcode(tif, &passcode); a0 = b2; } if (a0 >= bits) break; a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); } return (1); #undef PIXEL } /* * Encode a buffer of pixels. */ static int Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { Fax3EncodeState* sp = EncoderState(tif); (void) s; while ((long)cc > 0) { if ((sp->b.mode & FAXMODE_NOEOL) == 0) Fax3PutEOL(tif); if (is2DEncoding(sp)) { if (sp->tag == G3_1D) { if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) return (0); sp->tag = G3_2D; } else { if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) return (0); sp->k--; } if (sp->k == 0) { sp->tag = G3_1D; sp->k = sp->maxk-1; } else _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); } else { if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) return (0); } bp += sp->b.rowbytes; cc -= sp->b.rowbytes; if (cc != 0) tif->tif_row++; } return (1); } static int Fax3PostEncode(TIFF* tif) { Fax3EncodeState* sp = EncoderState(tif); if (sp->bit != 8) Fax3FlushBits(tif, sp); return (1); } static void Fax3Close(TIFF* tif) { if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) { Fax3EncodeState* sp = EncoderState(tif); u_int code = EOL; u_int length = 12; int i; if (is2DEncoding(sp)) code = (code<<1) | (sp->tag == G3_1D), length++; for (i = 0; i < 6; i++) Fax3PutBits(tif, code, length); Fax3FlushBits(tif, sp); } } static void Fax3Cleanup(TIFF* tif) { if (tif->tif_data) { if (tif->tif_mode == O_RDONLY) { Fax3DecodeState* sp = DecoderState(tif); if (sp->runs) _TIFFfree(sp->runs); } else { Fax3EncodeState* sp = EncoderState(tif); if (sp->refline) _TIFFfree(sp->refline); } _TIFFfree(tif->tif_data); tif->tif_data = NULL; } } #define FIELD_FAXMODE (FIELD_CODEC+0) #define FIELD_OPTIONS (FIELD_CODEC+1) #define FIELD_BADFAXLINES (FIELD_CODEC+2) #define FIELD_CLEANFAXDATA (FIELD_CODEC+3) #define FIELD_BADFAXRUN (FIELD_CODEC+4) static const TIFFFieldInfo fax3FieldInfo[] = { { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_FAXMODE, FALSE, FALSE, "" }, { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, FALSE, FALSE, "Group3Options" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines" }, { TIFFTAG_BADFAXLINES, 1, 1, TIFF_SHORT, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines" }, { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, FIELD_CLEANFAXDATA, TRUE, FALSE, "CleanFaxData" }, { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_LONG, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines" }, { TIFFTAG_CONSECUTIVEBADFAXLINES,1,1, TIFF_SHORT, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines" }, }; static const TIFFFieldInfo fax4FieldInfo[] = { { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, FIELD_FAXMODE, FALSE, FALSE, "" }, { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, FIELD_OPTIONS, FALSE, FALSE, "Group4Options" }, }; #define N(a) (sizeof (a) / sizeof (a[0])) static int Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); switch (tag) { case TIFFTAG_FAXMODE: sp->mode = va_arg(ap, int); return (1); /* NB: pseudo tag */ case TIFFTAG_FAXFILLFUNC: if (tif->tif_mode == O_RDONLY) DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); return (1); /* NB: pseudo tag */ case TIFFTAG_GROUP3OPTIONS: case TIFFTAG_GROUP4OPTIONS: sp->groupoptions = va_arg(ap, uint32); break; case TIFFTAG_BADFAXLINES: sp->badfaxlines = va_arg(ap, uint32); break; case TIFFTAG_CLEANFAXDATA: sp->cleanfaxdata = (uint16) va_arg(ap, int); break; case TIFFTAG_CONSECUTIVEBADFAXLINES: sp->badfaxrun = va_arg(ap, uint32); break; default: return (*sp->vsetparent)(tif, tag, ap); } TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); tif->tif_flags |= TIFF_DIRTYDIRECT; return (1); } static int Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); switch (tag) { case TIFFTAG_FAXMODE: *va_arg(ap, int*) = sp->mode; break; case TIFFTAG_FAXFILLFUNC: if (tif->tif_mode == O_RDONLY) *va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill; break; case TIFFTAG_GROUP3OPTIONS: case TIFFTAG_GROUP4OPTIONS: *va_arg(ap, uint32*) = sp->groupoptions; break; case TIFFTAG_BADFAXLINES: *va_arg(ap, uint32*) = sp->badfaxlines; break; case TIFFTAG_CLEANFAXDATA: *va_arg(ap, uint16*) = sp->cleanfaxdata; break; case TIFFTAG_CONSECUTIVEBADFAXLINES: *va_arg(ap, uint32*) = sp->badfaxrun; break; default: return (*sp->vgetparent)(tif, tag, ap); } return (1); } static void Fax3PrintDir(TIFF* tif, FILE* fd, long flags) { Fax3BaseState* sp = Fax3State(tif); (void) flags; if (TIFFFieldSet(tif,FIELD_OPTIONS)) { const char* sep = " "; if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) { fprintf(fd, " Group 4 Options:"); if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) fprintf(fd, "%suncompressed data", sep); } else { fprintf(fd, " Group 3 Options:"); if (sp->groupoptions & GROUP3OPT_2DENCODING) fprintf(fd, "%s2-d encoding", sep), sep = "+"; if (sp->groupoptions & GROUP3OPT_FILLBITS) fprintf(fd, "%sEOL padding", sep), sep = "+"; if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) fprintf(fd, "%suncompressed data", sep); } fprintf(fd, " (%lu = 0x%lx)\n", (u_long) sp->groupoptions, (u_long) sp->groupoptions); } if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { fprintf(fd, " Fax Data:"); switch (sp->cleanfaxdata) { case CLEANFAXDATA_CLEAN: fprintf(fd, " clean"); break; case CLEANFAXDATA_REGENERATED: fprintf(fd, " receiver regenerated"); break; case CLEANFAXDATA_UNCLEAN: fprintf(fd, " uncorrected errors"); break; } fprintf(fd, " (%u = 0x%x)\n", sp->cleanfaxdata, sp->cleanfaxdata); } if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) fprintf(fd, " Bad Fax Lines: %lu\n", (u_long) sp->badfaxlines); if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", (u_long) sp->badfaxrun); } int TIFFInitCCITTFax3(TIFF* tif, int scheme) { Fax3BaseState* sp; /* * Allocate state block so tag methods have storage to record values. */ if (tif->tif_mode == O_RDONLY) tif->tif_data = _TIFFmalloc(sizeof (Fax3DecodeState)); else tif->tif_data = _TIFFmalloc(sizeof (Fax3EncodeState)); if (tif->tif_data == NULL) { TIFFError("TIFFInitCCITTFax3", "%s: No space for state block", tif->tif_name); return (0); } sp = Fax3State(tif); /* * Merge codec-specific tag information and * override parent get/set field methods. */ switch (scheme) { case COMPRESSION_CCITTFAX3: _TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo)); break; case COMPRESSION_CCITTFAX4: _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); break; } sp->vgetparent = tif->tif_vgetfield; tif->tif_vgetfield = Fax3VGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_vsetfield; tif->tif_vsetfield = Fax3VSetField; /* hook for codec tags */ tif->tif_printdir = Fax3PrintDir; /* hook for codec tags */ sp->groupoptions = 0; TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); if (tif->tif_mode == O_RDONLY) { tif->tif_flags |= TIFF_NOBITREV;/* decoder does bit reversal */ DecoderState(tif)->runs = NULL; TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); } else EncoderState(tif)->refline = NULL; /* * Install codec methods. */ tif->tif_setupdecode = Fax3SetupState; tif->tif_predecode = Fax3PreDecode; tif->tif_decoderow = Fax3Decode1D; tif->tif_decodestrip = Fax3Decode1D; tif->tif_decodetile = Fax3Decode1D; tif->tif_setupencode = Fax3SetupState; tif->tif_preencode = Fax3PreEncode; tif->tif_postencode = Fax3PostEncode; tif->tif_encoderow = Fax3Encode; tif->tif_encodestrip = Fax3Encode; tif->tif_encodetile = Fax3Encode; tif->tif_close = Fax3Close; tif->tif_cleanup = Fax3Cleanup; return (1); } /* * CCITT Group 4 (T.6) Facsimile-compatible * Compression Scheme Support. */ #define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } /* * Decode the requested amount of G4-encoded data. */ static int Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { DECLARE_STATE_2D(tif, sp, "Fax4Decode"); (void) s; CACHE_STATE(tif, sp); while ((long)occ > 0) { a0 = 0; RunLength = 0; pa = thisrun = sp->curruns; pb = sp->refruns; b1 = *pb++; #ifdef FAX3_DEBUG printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif EXPAND2D(EOFG4); (*sp->fill)(buf, thisrun, pa, lastx); SETVAL(0); /* imaginary change for reference */ SWAP(uint16*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; if (occ != 0) tif->tif_row++; continue; EOFG4: (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); return (-1); } UNCACHE_STATE(tif, sp); return (1); } #undef SWAP /* * Encode the requested amount of data. */ static int Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { Fax3EncodeState *sp = EncoderState(tif); (void) s; while ((long)cc > 0) { if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) return (0); _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); bp += sp->b.rowbytes; cc -= sp->b.rowbytes; if (cc != 0) tif->tif_row++; } return (1); } static int Fax4PostEncode(TIFF* tif) { Fax3EncodeState *sp = EncoderState(tif); /* terminate strip w/ EOFB */ Fax3PutBits(tif, EOL, 12); Fax3PutBits(tif, EOL, 12); if (sp->bit != 8) Fax3FlushBits(tif, sp); return (1); } int TIFFInitCCITTFax4(TIFF* tif, int scheme) { if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 logic */ tif->tif_decoderow = Fax4Decode; tif->tif_decodestrip = Fax4Decode; tif->tif_decodetile = Fax4Decode; tif->tif_encoderow = Fax4Encode; tif->tif_encodestrip = Fax4Encode; tif->tif_encodetile = Fax4Encode; tif->tif_postencode = Fax4PostEncode; /* * Suppress RTC at the end of each strip. */ return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); } else return (0); } /* * CCITT Group 3 1-D Modified Huffman RLE Compression Support. * (Compression algorithms 2 and 32771) */ /* * Decode the requested amount of RLE-encoded data. */ static int Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); int mode = sp->b.mode; (void) s; CACHE_STATE(tif, sp); thisrun = sp->curruns; while ((long)occ > 0) { a0 = 0; RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif EXPAND1D(EOFRLE); (*sp->fill)(buf, thisrun, pa, lastx); /* * Cleanup at the end of the row. */ if (mode & FAXMODE_BYTEALIGN) { int n = BitsAvail - (BitsAvail &~ 7); ClrBits(n); } else if (mode & FAXMODE_WORDALIGN) { int n = BitsAvail - (BitsAvail &~ 15); ClrBits(n); if (BitsAvail == 0 && !isAligned(cp, uint16)) cp++; } buf += sp->b.rowbytes; occ -= sp->b.rowbytes; if (occ != 0) tif->tif_row++; continue; EOFRLE: /* premature EOF */ (*sp->fill)(buf, thisrun, pa, lastx); UNCACHE_STATE(tif, sp); return (-1); } UNCACHE_STATE(tif, sp); return (1); } int TIFFInitCCITTRLE(TIFF* tif, int scheme) { if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 compression */ tif->tif_decoderow = Fax3DecodeRLE; tif->tif_decodestrip = Fax3DecodeRLE; tif->tif_decodetile = Fax3DecodeRLE; /* * Suppress RTC+EOLs when encoding and byte-align data. */ return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); } else return (0); } int TIFFInitCCITTRLEW(TIFF* tif, int scheme) { if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 compression */ tif->tif_decoderow = Fax3DecodeRLE; tif->tif_decodestrip = Fax3DecodeRLE; tif->tif_decodetile = Fax3DecodeRLE; /* * Suppress RTC+EOLs when encoding and word-align data. */ return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_WORDALIGN); } else return (0); } #endif /* CCITT_SUPPORT */ ORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); } else return (0); } int TIFFInitCCITTRLEW(TIFF* tif, int scheme) { if (TIFFInitCCITTFax3(tif, scheme)) { /* reuse G3 compression */ tif->tif_decoderow = Fax3DecodeRLE; tif-tiff-v3.4beta018/libtiff/tif_fax3.h000444 004341 000024 00000034364 06003062744 016657 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_fax3.h,v 1.26 1995/07/17 01:27:30 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #ifndef _FAX3_ #define _FAX3_ /* * TIFF Library. * * CCITT Group 3 (T.4) and Group 4 (T.6) Decompression Support. * * Decoder support is derived, with permission, from the code * in Frank Cringle's viewfax program; * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tiff.h" /* * To override the default routine used to image decoded * spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC. * The routine must have the type signature given below; * for example: * * fillruns(unsigned char* buf, uint16* runs, uint16* erun, uint32 lastx) * * where buf is place to set the bits, runs is the array of b&w run * lengths (white then black), erun is the last run in the array, and * lastx is the width of the row in pixels. Fill routines can assume * the run array has room for at least lastx runs and can overwrite * data in the run array as needed (e.g. to append zero runs to bring * the count up to a nice multiple). */ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint16*, uint16*, uint32); /* * The default run filler; made external for other decoders. */ #if defined(__cplusplus) extern "C" { #endif extern void _TIFFFax3fillruns(unsigned char*, uint16*, uint16*, uint32); #if defined(__cplusplus) } #endif /* finite state machine codes */ #define S_Null 0 #define S_Pass 1 #define S_Horiz 2 #define S_V0 3 #define S_VR 4 #define S_VL 5 #define S_Ext 6 #define S_TermW 7 #define S_TermB 8 #define S_MakeUpW 9 #define S_MakeUpB 10 #define S_MakeUp 11 #define S_EOL 12 typedef struct { /* state table entry */ unsigned char State; /* see above */ unsigned char Width; /* width of code in bits */ uint16 Param; /* unsigned 16-bit run length in bits */ } TIFFFaxTabEnt; extern const TIFFFaxTabEnt TIFFFaxMainTable[]; extern const TIFFFaxTabEnt TIFFFaxWhiteTable[]; extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; /* * The following macros define the majority of the G3/G4 decoder * algorithm using the state tables defined elsewhere. To build * a decoder you need some setup code and some glue code. Note * that you may also need/want to change the way the NeedBits* * macros get input data if, for example, you know the data to be * decoded is properly aligned and oriented (doing so before running * the decoder can be a big performance win). * * Consult the decoder in the TIFF library for an idea of what you * need to define and setup to make use of these definitions. * * NB: to enable a debugging version of these macros define FAX3_DEBUG * before including this file. Trace output goes to stdout. */ #ifndef EndOfData #define EndOfData() (cp >= ep) #endif /* * Need <=8 or <=16 bits of input data. Unlike viewfax we * cannot use/assume a word-aligned, properly bit swizzled * input data set because data may come from an arbitrarily * aligned, read-only source such as a memory-mapped file. * Note also that the viewfax decoder does not check for * running off the end of the input data buffer. This is * possible for G3-encoded data because it prescans the input * data to count EOL markers, but can cause problems for G4 * data. In any event, we don't prescan and must watch for * running out of data since we can't permit the library to * scan past the end of the input data buffer. */ #ifndef NeedBits8 #define NeedBits8(n,eoflab) do { \ if (BitsAvail < (n)) { \ if (EndOfData()) goto eoflab; \ BitAcc |= bitmap[*cp++]<>= (n); \ } while (0) #ifdef FAX3_DEBUG static const char* StateNames[] = { "Null ", "Pass ", "Horiz ", "V0 ", "VR ", "VL ", "Ext ", "TermW ", "TermB ", "MakeUpW", "MakeUpB", "MakeUp ", "EOL ", }; #define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') #define LOOKUP8(wid,tab,eoflab) do { \ int t; \ NeedBits8(wid,eoflab); \ TabEnt = tab + GetBits(wid); \ printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ StateNames[TabEnt->State], TabEnt->Param); \ for (t = 0; t < TabEnt->Width; t++) \ DEBUG_SHOW; \ putchar('\n'); \ fflush(stdout); \ ClrBits(TabEnt->Width); \ } while (0) #define LOOKUP16(wid,tab,eoflab) do { \ int t; \ NeedBits16(wid,eoflab); \ TabEnt = tab + GetBits(wid); \ printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ StateNames[TabEnt->State], TabEnt->Param); \ for (t = 0; t < TabEnt->Width; t++) \ DEBUG_SHOW; \ putchar('\n'); \ fflush(stdout); \ ClrBits(TabEnt->Width); \ } while (0) #define SETVAL(x) do { \ *pa++ = RunLength + (x); \ printf("SETVAL: %d\t%d\n", RunLength + (x), a0); \ a0 += x; \ RunLength = 0; \ } while (0) #else #define LOOKUP8(wid,tab,eoflab) do { \ NeedBits8(wid,eoflab); \ TabEnt = tab + GetBits(wid); \ ClrBits(TabEnt->Width); \ } while (0) #define LOOKUP16(wid,tab,eoflab) do { \ NeedBits16(wid,eoflab); \ TabEnt = tab + GetBits(wid); \ ClrBits(TabEnt->Width); \ } while (0) /* * Append a run to the run length array for the * current row and reset decoding state. */ #define SETVAL(x) do { \ *pa++ = RunLength + (x); \ a0 += (x); \ RunLength = 0; \ } while (0) #endif /* * Synchronize input decoding at the start of each * row by scanning for an EOL (if appropriate) and * skipping any trash data that might be present * after a decoding error. Note that the decoding * done elsewhere that recognizes an EOL only consumes * 11 consecutive zero bits. This means that if EOLcnt * is non-zero then we still need to scan for the final flag * bit that is part of the EOL code. */ #define SYNC_EOL(eoflab) do { \ if (EOLcnt == 0) { \ for (;;) { \ NeedBits16(11,eoflab); \ if (GetBits(11) == 0) \ break; \ ClrBits(11); \ } \ } \ for (;;) { \ NeedBits8(8,eoflab); \ if (GetBits(8)) \ break; \ ClrBits(8); \ } \ while (GetBits(1) == 0) \ ClrBits(1); \ ClrBits(1); /* EOL bit */ \ EOLcnt = 0; /* reset EOL counter/flag */ \ } while (0) /* * Cleanup the array of runs after decoding a row. * We adjust final runs to insure the user buffer is not * overwritten and/or undecoded area is white filled. */ #define CLEANUP_RUNS() do { \ if (RunLength) \ SETVAL(0); \ if (a0 != lastx) { \ badlength(a0, lastx); \ while (a0 > lastx && pa > thisrun) \ a0 -= *--pa; \ if (a0 < lastx) { \ if (a0 < 0) \ a0 = 0; \ if ((pa-thisrun)&1) \ SETVAL(0); \ SETVAL(lastx - a0); \ } else if (a0 > lastx) { \ SETVAL(lastx); \ SETVAL(0); \ } \ } \ } while (0) /* * Decode a line of 1D-encoded data. * * The line expanders are written as macros so that they can be reused * but still have direct access to the local variables of the "calling" * function. * * Note that unlike the original version we have to explicitly test for * a0 >= lastx after each black/white run is decoded. This is because * the original code depended on the input data being zero-padded to * insure the decoder recognized an EOL before running out of data. */ #define EXPAND1D(eoflab) do { \ for (;;) { \ for (;;) { \ LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ switch (TabEnt->State) { \ case S_EOL: \ EOLcnt = 1; \ goto done1d; \ case S_TermW: \ SETVAL(TabEnt->Param); \ goto doneWhite1d; \ case S_MakeUpW: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ unexpected("WhiteTable", a0); \ goto done1d; \ } \ } \ doneWhite1d: \ if (a0 >= lastx) \ goto done1d; \ for (;;) { \ LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ switch (TabEnt->State) { \ case S_EOL: \ EOLcnt = 1; \ goto done1d; \ case S_TermB: \ SETVAL(TabEnt->Param); \ goto doneBlack1d; \ case S_MakeUpB: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ unexpected("BlackTable", a0); \ goto done1d; \ } \ } \ doneBlack1d: \ if (a0 >= lastx) \ goto done1d; \ } \ eof1d: \ prematureEOF(a0); \ CLEANUP_RUNS(); \ goto eoflab; \ done1d: \ CLEANUP_RUNS(); \ } while (0) /* * Update the value of b1 using the array * of runs for the reference line. */ #define CHECK_b1 do { \ if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ b1 += pb[0] + pb[1]; \ pb += 2; \ } \ } while (0) /* * Expand a row of 2D-encoded data. */ #define EXPAND2D(eoflab) do { \ while (a0 < lastx) { \ LOOKUP8(7, TIFFFaxMainTable, eof2d); \ switch (TabEnt->State) { \ case S_Pass: \ CHECK_b1; \ b1 += *pb++; \ RunLength += b1 - a0; \ a0 = b1; \ b1 += *pb++; \ break; \ case S_Horiz: \ if ((pa-thisrun)&1) { \ for (;;) { /* black first */ \ LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ switch (TabEnt->State) { \ case S_TermB: \ SETVAL(TabEnt->Param); \ goto doneWhite2da; \ case S_MakeUpB: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ goto badBlack2d; \ } \ } \ doneWhite2da:; \ for (;;) { /* then white */ \ LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ switch (TabEnt->State) { \ case S_TermW: \ SETVAL(TabEnt->Param); \ goto doneBlack2da; \ case S_MakeUpW: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ goto badWhite2d; \ } \ } \ doneBlack2da:; \ } else { \ for (;;) { /* white first */ \ LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ switch (TabEnt->State) { \ case S_TermW: \ SETVAL(TabEnt->Param); \ goto doneWhite2db; \ case S_MakeUpW: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ goto badWhite2d; \ } \ } \ doneWhite2db:; \ for (;;) { /* then black */ \ LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ switch (TabEnt->State) { \ case S_TermB: \ SETVAL(TabEnt->Param); \ goto doneBlack2db; \ case S_MakeUpB: \ case S_MakeUp: \ a0 += TabEnt->Param; \ RunLength += TabEnt->Param; \ break; \ default: \ goto badBlack2d; \ } \ } \ doneBlack2db:; \ } \ CHECK_b1; \ break; \ case S_V0: \ CHECK_b1; \ SETVAL(b1 - a0); \ b1 += *pb++; \ break; \ case S_VR: \ CHECK_b1; \ SETVAL(b1 - a0 + TabEnt->Param); \ b1 += *pb++; \ break; \ case S_VL: \ CHECK_b1; \ SETVAL(b1 - a0 - TabEnt->Param); \ b1 -= *--pb; \ break; \ case S_Ext: \ *pa++ = lastx - a0; \ extension(a0); \ goto eol2d; \ case S_EOL: \ *pa++ = lastx - a0; \ NeedBits8(5,eof2d); \ if (GetBits(5)) \ unexpected("EOL", a0); \ EOLcnt = 1; \ goto eol2d; \ default: \ badMain2d: \ unexpected("MainTable", a0); \ goto eol2d; \ badBlack2d: \ unexpected("BlackTable", a0); \ goto eol2d; \ badWhite2d: \ unexpected("WhiteTable", a0); \ goto eol2d; \ eof2d: \ prematureEOF(a0); \ CLEANUP_RUNS(); \ goto eoflab; \ } \ } \ if (RunLength) { \ /* expect a final V0 */ \ NeedBits8(1,eof2d); \ if (!GetBits(1)) \ goto badMain2d; \ ClrBits(1); \ SETVAL(0); \ } \ eol2d: \ CLEANUP_RUNS(); \ } while (0) #endif /* _FAX3_ */ goto eol2d; \ badWhite2d: \ unexpected("WhiteTable", a0); \ goto eol2d; \ eof2d: \ prematureEOF(a0); \ CLEANUP_RUNS(); \ goto eoflab; \ } \ } \ if (RunLength) { \ /*tiff-v3.4beta018/libtiff/tif_flush.c000444 004341 000024 00000003524 06003062744 017124 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_flush.c,v 1.21 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" int TIFFFlush(TIFF* tif) { if (tif->tif_mode != O_RDONLY) { if (!TIFFFlushData(tif)) return (0); if ((tif->tif_flags & TIFF_DIRTYDIRECT) && !TIFFWriteDirectory(tif)) return (0); } return (1); } /* * Flush buffered data to the file. */ int TIFFFlushData(TIFF* tif) { if ((tif->tif_flags & TIFF_BEENWRITING) == 0) return (0); if (tif->tif_flags & TIFF_POSTENCODE) { tif->tif_flags &= ~TIFF_POSTENCODE; if (!(*tif->tif_postencode)(tif)) return (0); } return (TIFFFlushData1(tif)); } TIFFFlush(TIFF* tif) { if (tif->tif_mode != O_RDONLY) { if (!TIFFFlushData(tif)) return (0); if ((tif->tif_flags & TIFF_DIRTYDIRECT) && !TIFFWriteDirectory(ttiff-v3.4beta018/libtiff/tif_getimage.c000444 004341 000024 00000130214 06003062745 017563 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_getimage.c,v 1.38 1995/07/17 01:27:18 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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 * * Read and return a packed RGBA image. */ #include "tiffiop.h" #include #include static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); static int pickTileContigCase(TIFFRGBAImage*); static int pickTileSeparateCase(TIFFRGBAImage*); static const char photoTag[] = "PhotometricInterpretation"; /* * Check the image to see if TIFFReadRGBAImage can deal with it. * 1/0 is returned according to whether or not the image can * be handled. If 0 is returned, emsg contains the reason * why it is being rejected. */ int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) { TIFFDirectory* td = &tif->tif_dir; uint16 photometric; int colorchannels; switch (td->td_bitspersample) { case 1: case 2: case 4: case 8: case 16: break; default: sprintf(emsg, "Sorry, can not handle images with %d-bit samples", td->td_bitspersample); return (0); } colorchannels = td->td_samplesperpixel - td->td_extrasamples; if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { switch (colorchannels) { case 1: photometric = PHOTOMETRIC_MINISBLACK; break; case 3: photometric = PHOTOMETRIC_RGB; break; default: sprintf(emsg, "Missing needed %s tag", photoTag); return (0); } } switch (photometric) { case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_PALETTE: if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_samplesperpixel != 1) { sprintf(emsg, "Sorry, can not handle contiguous data with %s=%d, and %s=%d", photoTag, photometric, "Samples/pixel", td->td_samplesperpixel); return (0); } break; case PHOTOMETRIC_YCBCR: if (td->td_planarconfig != PLANARCONFIG_CONTIG) { sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", "Planarconfiguration", td->td_planarconfig); return (0); } break; case PHOTOMETRIC_RGB: if (colorchannels < 3) { sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", "Color channels", colorchannels); return (0); } break; #ifdef CMYK_SUPPORT case PHOTOMETRIC_SEPARATED: if (td->td_inkset != INKSET_CMYK) { sprintf(emsg, "Sorry, can not handle separated image with %s=%d", "InkSet", td->td_inkset); return (0); } if (td->td_samplesperpixel != 4) { sprintf(emsg, "Sorry, can not handle separated image with %s=%d", "Samples/pixel", td->td_samplesperpixel); return (0); } break; #endif default: sprintf(emsg, "Sorry, can not handle image with %s=%d", photoTag, photometric); return (0); } return (1); } void TIFFRGBAImageEnd(TIFFRGBAImage* img) { if (img->Map) _TIFFfree(img->Map), img->Map = NULL; if (img->BWmap) _TIFFfree(img->BWmap), img->BWmap = NULL; if (img->PALmap) _TIFFfree(img->PALmap), img->PALmap = NULL; if (img->ycbcr) _TIFFfree(img->ycbcr), img->ycbcr = NULL; } 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 TIFFRGBAImageBegin(TIFFRGBAImage* 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); switch (img->bitspersample) { case 1: case 2: case 4: case 8: case 16: break; default: sprintf(emsg, "Sorry, can not image with %d-bit samples", img->bitspersample); return (0); } 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: 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); } img->Map = NULL; img->BWmap = NULL; img->PALmap = NULL; img->ycbcr = NULL; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); img->isContig = !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); if (img->isContig) { img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; (void) pickTileContigCase(img); } else { img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; (void) pickTileSeparateCase(img); } return (1); } int TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { if (img->get == NULL) { TIFFError(TIFFFileName(img->tif), "No \"get\" routine setup"); return (0); } if (img->put.any == NULL) { TIFFError(TIFFFileName(img->tif), "No \"put\" routine setupl; probably can not handle image format"); return (0); } return (*img->get)(img, raster, w, h); } /* * Read the specified image into an ABGR-format raster. */ int TIFFReadRGBAImage(TIFF* tif, uint32 rwidth, uint32 rheight, uint32* raster, int stop) { char emsg[1024]; TIFFRGBAImage img; int ok; if (TIFFRGBAImageBegin(&img, tif, stop, emsg)) { /* XXX verify rwidth and rheight against width and height */ ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, rwidth, img.height); TIFFRGBAImageEnd(&img); } else { TIFFError(TIFFFileName(tif), emsg); ok = 0; } return (ok); } static uint32 setorientation(TIFFRGBAImage* img, uint32 h) { TIFF* tif = img->tif; uint32 y; 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: y = 0; 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: y = h-1; break; } return (y); } /* * Get an tile-organized image that has * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 */ static int gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; uint16 orientation; uint32 col, row, y; uint32 tw, th; u_char* buf; int32 fromskew, toskew; 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); y = setorientation(img, h); orientation = img->orientation; toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); 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; (*put)(img, raster+y*w+col, col, y, npix, nrow, fromskew, toskew + fromskew, buf); } else { (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf); } } y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow); } _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(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; uint16 orientation; uint32 col, row, y; uint32 tw, th; u_char* buf; u_char* r; u_char* g; u_char* b; u_char* a; tsize_t tilesize; int32 fromskew, toskew; 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); y = setorientation(img, h); orientation = img->orientation; toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w); 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; (*put)(img, raster+y*w+col, col, y, npix, nrow, fromskew, toskew + fromskew, r, g, b, a); } else { (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, r, g, b, a); } } y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow); } _TIFFfree(buf); return (1); } /* * Get a strip-organized image that has * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 */ static int gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; uint16 orientation; uint32 row, y, nrow; u_char* buf; uint32 rowsperstrip; uint32 imagewidth = img->width; tsize_t scanline; int32 fromskew, toskew; buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); if (buf == 0) { TIFFError(TIFFFileName(tif), "No space for strip buffer"); return (0); } y = setorientation(img, h); orientation = img->orientation; toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); 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; (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf); y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow); } _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(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; uint16 orientation; u_char *buf; u_char *r, *g, *b, *a; uint32 row, y, nrow; tsize_t scanline; uint32 rowsperstrip; uint32 imagewidth = img->width; tsize_t stripsize; int32 fromskew, toskew; 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); y = setorientation(img, h); orientation = img->orientation; toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w); 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; (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r, g, b, a); y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow); } _TIFFfree(buf); return (1); } /* * The following routines move decoded data returned * from the TIFF library into rasters filled with packed * ABGR pixels (i.e. suitable for passing to lrecwrite.) * * The routines have been created according to the most * important cases and optimized. pickTileContigCase and * pickTileSeparateCase analyze the parameters and select * the appropriate "put" routine to use. */ #define REPEAT8(op) REPEAT4(op); REPEAT4(op) #define REPEAT4(op) REPEAT2(op); REPEAT2(op) #define REPEAT2(op) op; op #define CASE8(x,op) \ switch (x) { \ case 7: op; case 6: op; case 5: op; \ case 4: op; case 3: op; case 2: op; \ case 1: op; \ } #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } #define NOP #define UNROLL8(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 8; _x -= 8) { \ op1; \ REPEAT8(op2); \ } \ if (_x > 0) { \ op1; \ CASE8(_x,op2); \ } \ } #define UNROLL4(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 4; _x -= 4) { \ op1; \ REPEAT4(op2); \ } \ if (_x > 0) { \ op1; \ CASE4(_x,op2); \ } \ } #define UNROLL2(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 2; _x -= 2) { \ op1; \ REPEAT2(op2); \ } \ if (_x) { \ op1; \ op2; \ } \ } #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } #define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } #define A1 ((uint32)(0xffL<<24)) #define PACK(r,g,b) \ ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) #define PACK4(r,g,b,a) \ ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) #define W2B(v) (((v)>>8)&0xff) #define PACKW(r,g,b) \ ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) #define PACKW4(r,g,b,a) \ ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) #define DECLAREContigPutFunc(name) \ static void name(\ TIFFRGBAImage* img, \ uint32* cp, \ uint32 x, uint32 y, \ uint32 w, uint32 h, \ int32 fromskew, int32 toskew, \ u_char* pp \ ) /* * 8-bit palette => colormap/RGB */ DECLAREContigPutFunc(put8bitcmaptile) { uint32** PALmap = img->PALmap; (void) x; (void) y; while (h-- > 0) { UNROLL8(w, NOP, *cp++ = PALmap[*pp++][0]); cp += toskew; pp += fromskew; } } /* * 4-bit palette => colormap/RGB */ DECLAREContigPutFunc(put4bitcmaptile) { uint32** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 2; while (h-- > 0) { uint32* bw; UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 2-bit palette => colormap/RGB */ DECLAREContigPutFunc(put2bitcmaptile) { uint32** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 4; while (h-- > 0) { uint32* bw; UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 1-bit palette => colormap/RGB */ DECLAREContigPutFunc(put1bitcmaptile) { uint32** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 8; while (h-- > 0) { uint32* bw; UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 8-bit greyscale => colormap/RGB */ DECLAREContigPutFunc(putgreytile) { uint32** BWmap = img->BWmap; (void) y; while (h-- > 0) { for (x = w; x-- > 0;) *cp++ = BWmap[*pp++][0]; cp += toskew; pp += fromskew; } } /* * 1-bit bilevel => colormap/RGB */ DECLAREContigPutFunc(put1bitbwtile) { uint32** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 8; while (h-- > 0) { uint32* bw; UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 2-bit greyscale => colormap/RGB */ DECLAREContigPutFunc(put2bitbwtile) { uint32** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 4; while (h-- > 0) { uint32* bw; UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 4-bit greyscale => colormap/RGB */ DECLAREContigPutFunc(put4bitbwtile) { uint32** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 2; while (h-- > 0) { uint32* bw; UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; } } /* * 8-bit packed samples, no Map => RGB */ DECLAREContigPutFunc(putRGBcontig8bittile) { int samplesperpixel = img->samplesperpixel; (void) x; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { UNROLL8(w, NOP, *cp++ = PACK(pp[0], pp[1], pp[2]); pp += samplesperpixel); cp += toskew; pp += fromskew; } } /* * 8-bit packed samples, w/ Map => RGB */ DECLAREContigPutFunc(putRGBcontig8bitMaptile) { TIFFRGBValue* Map = img->Map; int samplesperpixel = img->samplesperpixel; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = PACK(Map[pp[0]], Map[pp[1]], Map[pp[2]]); pp += samplesperpixel; } pp += fromskew; cp += toskew; } } /* * 8-bit packed samples => RGBA w/ associated alpha * (known to have Map == NULL) */ DECLAREContigPutFunc(putRGBAAcontig8bittile) { int samplesperpixel = img->samplesperpixel; (void) x; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { UNROLL8(w, NOP, *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); pp += samplesperpixel); cp += toskew; pp += fromskew; } } /* * 8-bit packed samples => RGBA w/ unassociated alpha * (known to have Map == NULL) */ DECLAREContigPutFunc(putRGBUAcontig8bittile) { int samplesperpixel = img->samplesperpixel; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { uint32 r, g, b, a; for (x = w; x-- > 0;) { a = pp[3]; r = (pp[0] * a) / 255; g = (pp[1] * a) / 255; b = (pp[2] * a) / 255; *cp++ = PACK4(r,g,b,a); pp += samplesperpixel; } cp += toskew; pp += fromskew; } } /* * 16-bit packed samples => RGB */ DECLAREContigPutFunc(putRGBcontig16bittile) { int samplesperpixel = img->samplesperpixel; uint16 *wp = (uint16 *)pp; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = PACKW(wp[0], wp[1], wp[2]); wp += samplesperpixel; } cp += toskew; wp += fromskew; } } /* * 16-bit packed samples => RGBA w/ associated alpha * (known to have Map == NULL) */ DECLAREContigPutFunc(putRGBAAcontig16bittile) { int samplesperpixel = img->samplesperpixel; uint16 *wp = (uint16 *)pp; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = PACKW4(wp[0], wp[1], wp[2], wp[3]); wp += samplesperpixel; } cp += toskew; wp += fromskew; } } /* * 16-bit packed samples => RGBA w/ unassociated alpha * (known to have Map == NULL) */ DECLAREContigPutFunc(putRGBUAcontig16bittile) { int samplesperpixel = img->samplesperpixel; uint16 *wp = (uint16 *)pp; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { uint32 r,g,b,a; /* * We shift alpha down four bits just in case unsigned * arithmetic doesn't handle the full range. * We still have plenty of accuracy, since the output is 8 bits. * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) * Since we want r*a * 0xff for eight bit output, * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. */ for (x = w; x-- > 0;) { a = wp[3] >> 4; r = (wp[0] * a) / 0x10eff; g = (wp[1] * a) / 0x10eff; b = (wp[2] * a) / 0x10eff; *cp++ = PACK4(r,g,b,a); wp += samplesperpixel; } cp += toskew; wp += fromskew; } } /* * 8-bit packed CMYK samples w/o Map => RGB * * NB: The conversion of CMYK->RGB is *very* crude. */ DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) { int samplesperpixel = img->samplesperpixel; uint16 r, g, b, k; (void) x; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { UNROLL8(w, NOP, k = 255 - pp[3]; r = (k*(255-pp[0]))/255; g = (k*(255-pp[1]))/255; b = (k*(255-pp[2]))/255; *cp++ = PACK(r, g, b); pp += samplesperpixel); cp += toskew; pp += fromskew; } } /* * 8-bit packed CMYK samples w/Map => RGB * * NB: The conversion of CMYK->RGB is *very* crude. */ DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; uint16 r, g, b, k; (void) y; fromskew *= samplesperpixel; while (h-- > 0) { for (x = w; x-- > 0;) { k = 255 - pp[3]; r = (k*(255-pp[0]))/255; g = (k*(255-pp[1]))/255; b = (k*(255-pp[2]))/255; *cp++ = PACK(Map[r], Map[g], Map[b]); pp += samplesperpixel; } pp += fromskew; cp += toskew; } } #define DECLARESepPutFunc(name) \ static void name(\ TIFFRGBAImage* img,\ uint32* cp,\ uint32 x, uint32 y, \ uint32 w, uint32 h,\ int32 fromskew, int32 toskew,\ u_char* r, u_char* g, u_char* b, u_char* a\ ) /* * 8-bit unpacked samples => RGB */ DECLARESepPutFunc(putRGBseparate8bittile) { (void) img; (void) x; (void) y; (void) a; while (h-- > 0) { UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); SKEW(r, g, b, fromskew); cp += toskew; } } /* * 8-bit unpacked samples => RGB */ DECLARESepPutFunc(putRGBseparate8bitMaptile) { TIFFRGBValue* Map = img->Map; (void) y; (void) a; while (h-- > 0) { for (x = w; x > 0; x--) *cp++ = PACK(Map[*r++], Map[*g++], Map[*b++]); SKEW(r, g, b, fromskew); cp += toskew; } } /* * 8-bit unpacked samples => RGBA w/ associated alpha */ DECLARESepPutFunc(putRGBAAseparate8bittile) { (void) img; (void) x; (void) y; while (h-- > 0) { UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); SKEW4(r, g, b, a, fromskew); cp += toskew; } } /* * 8-bit unpacked samples => RGBA w/ unassociated alpha */ DECLARESepPutFunc(putRGBUAseparate8bittile) { (void) img; (void) y; while (h-- > 0) { uint32 rv, gv, bv, av; for (x = w; x-- > 0;) { av = *a++; rv = (*r++ * av) / 255; gv = (*g++ * av) / 255; bv = (*b++ * av) / 255; *cp++ = PACK4(rv,gv,bv,av); } SKEW4(r, g, b, a, fromskew); cp += toskew; } } /* * 16-bit unpacked samples => RGB */ DECLARESepPutFunc(putRGBseparate16bittile) { uint16 *wr = (uint16*) r; uint16 *wg = (uint16*) g; uint16 *wb = (uint16*) b; (void) img; (void) y; (void) a; while (h-- > 0) { for (x = 0; x < w; x++) *cp++ = PACKW(*wr++, *wg++, *wb++); SKEW(wr, wg, wb, fromskew); cp += toskew; } } /* * 16-bit unpacked samples => RGBA w/ associated alpha */ DECLARESepPutFunc(putRGBAAseparate16bittile) { uint16 *wr = (uint16*) r; uint16 *wg = (uint16*) g; uint16 *wb = (uint16*) b; uint16 *wa = (uint16*) a; (void) img; (void) y; while (h-- > 0) { for (x = 0; x < w; x++) *cp++ = PACKW4(*wr++, *wg++, *wb++, *wa++); SKEW4(wr, wg, wb, wa, fromskew); cp += toskew; } } /* * 16-bit unpacked samples => RGBA w/ unassociated alpha */ DECLARESepPutFunc(putRGBUAseparate16bittile) { uint16 *wr = (uint16*) r; uint16 *wg = (uint16*) g; uint16 *wb = (uint16*) b; uint16 *wa = (uint16*) a; (void) img; (void) y; while (h-- > 0) { uint32 r,g,b,a; /* * We shift alpha down four bits just in case unsigned * arithmetic doesn't handle the full range. * We still have plenty of accuracy, since the output is 8 bits. * So we have (r * 0xffff) * (a * 0xfff)) = r*a * (0xffff*0xfff) * Since we want r*a * 0xff for eight bit output, * we divide by (0xffff * 0xfff) / 0xff == 0x10eff. */ for (x = w; x-- > 0;) { a = *wa++ >> 4; r = (*wr++ * a) / 0x10eff; g = (*wg++ * a) / 0x10eff; b = (*wb++ * a) / 0x10eff; *cp++ = PACK4(r,g,b,a); } SKEW4(wr, wg, wb, wa, fromskew); cp += toskew; } } /* * YCbCr -> RGB conversion and packing routines. The colorspace * conversion algorithm comes from the IJG v5a code; see below * for more information on how it works. */ #define YCbCrtoRGB(dst, yc) { \ int Y = (yc); \ dst = PACK( \ clamptab[Y+Crrtab[Cr]], \ clamptab[Y + (int)((Cbgtab[Cb]+Crgtab[Cr])>>16)], \ clamptab[Y+Cbbtab[Cb]]); \ } #define YCbCrSetup \ TIFFYCbCrToRGB* ycbcr = img->ycbcr; \ int* Crrtab = ycbcr->Cr_r_tab; \ int* Cbbtab = ycbcr->Cb_b_tab; \ int32* Crgtab = ycbcr->Cr_g_tab; \ int32* Cbgtab = ycbcr->Cb_g_tab; \ TIFFRGBValue* clamptab = ycbcr->clamptab /* * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) { YCbCrSetup; uint32* cp1 = cp+w+toskew; uint32* cp2 = cp1+w+toskew; uint32* cp3 = cp2+w+toskew; u_int incr = 3*w+4*toskew; (void) y; /* XXX adjust fromskew */ for (; h >= 4; h -= 4) { x = w>>2; do { int Cb = pp[16]; int Cr = pp[17]; YCbCrtoRGB(cp [0], pp[ 0]); YCbCrtoRGB(cp [1], pp[ 1]); YCbCrtoRGB(cp [2], pp[ 2]); YCbCrtoRGB(cp [3], pp[ 3]); YCbCrtoRGB(cp1[0], pp[ 4]); YCbCrtoRGB(cp1[1], pp[ 5]); YCbCrtoRGB(cp1[2], pp[ 6]); YCbCrtoRGB(cp1[3], pp[ 7]); YCbCrtoRGB(cp2[0], pp[ 8]); YCbCrtoRGB(cp2[1], pp[ 9]); YCbCrtoRGB(cp2[2], pp[10]); YCbCrtoRGB(cp2[3], pp[11]); YCbCrtoRGB(cp3[0], pp[12]); YCbCrtoRGB(cp3[1], pp[13]); YCbCrtoRGB(cp3[2], pp[14]); YCbCrtoRGB(cp3[3], pp[15]); cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; pp += 18; } while (--x); cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; pp += fromskew; } } /* * 8-bit packed YCbCr samples w/ 4,2 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) { YCbCrSetup; uint32* cp1 = cp+w+toskew; u_int incr = 2*toskew+w; (void) y; /* XXX adjust fromskew */ for (; h >= 2; h -= 2) { x = w>>2; do { int Cb = pp[8]; int Cr = pp[9]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); YCbCrtoRGB(cp [2], pp[2]); YCbCrtoRGB(cp [3], pp[3]); YCbCrtoRGB(cp1[0], pp[4]); YCbCrtoRGB(cp1[1], pp[5]); YCbCrtoRGB(cp1[2], pp[6]); YCbCrtoRGB(cp1[3], pp[7]); cp += 4, cp1 += 4; pp += 10; } while (--x); cp += incr, cp1 += incr; pp += fromskew; } } /* * 8-bit packed YCbCr samples w/ 4,1 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) { YCbCrSetup; (void) y; /* XXX adjust fromskew */ do { x = w>>2; do { int Cb = pp[4]; int Cr = pp[5]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); YCbCrtoRGB(cp [2], pp[2]); YCbCrtoRGB(cp [3], pp[3]); cp += 4; pp += 6; } while (--x); cp += toskew; pp += fromskew; } while (--h); } /* * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { YCbCrSetup; uint32* cp1 = cp+w+toskew; u_int incr = 2*toskew+w; (void) y; /* XXX adjust fromskew */ for (; h >= 2; h -= 2) { x = w>>1; do { int Cb = pp[4]; int Cr = pp[5]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); YCbCrtoRGB(cp1[0], pp[2]); YCbCrtoRGB(cp1[1], pp[3]); cp += 2, cp1 += 2; pp += 6; } while (--x); cp += incr, cp1 += incr; pp += fromskew; } } /* * 8-bit packed YCbCr samples w/ 2,1 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) { YCbCrSetup; (void) y; /* XXX adjust fromskew */ do { x = w>>1; do { int Cb = pp[2]; int Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); cp += 2; pp += 4; } while (--x); cp += toskew; pp += fromskew; } while (--h); } /* * 8-bit packed YCbCr samples w/ no subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) { YCbCrSetup; (void) y; /* XXX adjust fromskew */ do { x = w>>1; do { int Cb = pp[1]; int Cr = pp[2]; YCbCrtoRGB(*cp++, pp[0]); pp += 3; } while (--x); cp += toskew; pp += fromskew; } while (--h); } #undef YCbCrSetup #undef YCbCrtoRGB #define LumaRed coeffs[0] #define LumaGreen coeffs[1] #define LumaBlue coeffs[2] #define SHIFT 16 #define FIX(x) ((int32)((x) * (1L<RGB conversion tables. The conversion * is done according to the 6.0 spec: * * R = Y + Cr*(2 - 2*LumaRed) * B = Y + Cb*(2 - 2*LumaBlue) * G = Y * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen * * To avoid floating point arithmetic the fractional constants that * come out of the equations are represented as fixed point values * in the range 0...2^16. We also eliminate multiplications by * pre-calculating possible values indexed by Cb and Cr (this code * assumes conversion is being done for 8-bit samples). */ static void TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, TIFF* tif) { TIFFRGBValue* clamptab; float* coeffs; int i; clamptab = (TIFFRGBValue*)( (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) clamptab[i] = i; _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); _TIFFmemcpy(ycbcr->coeffs, coeffs, 3*sizeof (float)); { float f1 = 2-2*LumaRed; int32 D1 = FIX(f1); float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2); float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3); float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4); int x; ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; /* * i is the actual input pixel value in the range 0..255 * Cb and Cr values are in the range -128..127 (actually * they are in a range defined by the ReferenceBlackWhite * tag) so there is some range shifting to do here when * constructing tables indexed by the raw pixel data. * * XXX handle ReferenceBlackWhite correctly to calculate * Cb/Cr values to use in constructing the tables. */ for (i = 0, x = -128; i < 256; i++, x++) { ycbcr->Cr_r_tab[i] = (int)((D1*x + ONE_HALF)>>SHIFT); ycbcr->Cb_b_tab[i] = (int)((D3*x + ONE_HALF)>>SHIFT); ycbcr->Cr_g_tab[i] = D2*x; ycbcr->Cb_g_tab[i] = D4*x + ONE_HALF; } } } #undef SHIFT #undef ONE_HALF #undef FIX #undef LumaBlue #undef LumaGreen #undef LumaRed static tileContigRoutine initYCbCrConversion(TIFFRGBAImage* img) { uint16 hs, vs; if (img->ycbcr == NULL) { img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)) + 4*256*sizeof (TIFFRGBValue) + 2*256*sizeof (int) + 2*256*sizeof (int32) ); if (img->ycbcr == NULL) { TIFFError(TIFFFileName(img->tif), "No space for YCbCr->RGB conversion state"); return (NULL); } TIFFYCbCrToRGBInit(img->ycbcr, img->tif); } else { float* coeffs; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); if (_TIFFmemcmp(coeffs, img->ycbcr->coeffs, 3*sizeof (float)) != 0) TIFFYCbCrToRGBInit(img->ycbcr, img->tif); } /* * The 6.0 spec says that subsampling must be * one of 1, 2, or 4, and that vertical subsampling * must always be <= horizontal subsampling; so * there are only a few possibilities and we just * enumerate the cases. */ TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); switch ((hs<<4)|vs) { case 0x44: return (putcontig8bitYCbCr44tile); case 0x42: return (putcontig8bitYCbCr42tile); case 0x41: return (putcontig8bitYCbCr41tile); case 0x22: return (putcontig8bitYCbCr22tile); case 0x21: return (putcontig8bitYCbCr21tile); case 0x11: return (putcontig8bitYCbCr11tile); } return (NULL); } /* * Greyscale images with less than 8 bits/sample are handled * with a table to avoid lots of shifts and masks. The table * is setup so that put*bwtile (below) can retrieve 8/bitspersample * pixel values simply by indexing into the table with one * number. */ static int makebwmap(TIFFRGBAImage* img) { TIFFRGBValue* Map = img->Map; int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; int i; uint32* p; img->BWmap = (uint32**) _TIFFmalloc( 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); if (img->BWmap == NULL) { TIFFError(TIFFFileName(img->tif), "No space for B&W mapping table"); return (0); } p = (uint32*)(img->BWmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->BWmap[i] = p; switch (bitspersample) { #define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); case 1: GREY(i>>7); GREY((i>>6)&1); GREY((i>>5)&1); GREY((i>>4)&1); GREY((i>>3)&1); GREY((i>>2)&1); GREY((i>>1)&1); GREY(i&1); break; case 2: GREY(i>>6); GREY((i>>4)&3); GREY((i>>2)&3); GREY(i&3); break; case 4: GREY(i>>4); GREY(i&0xf); break; case 8: GREY(i); break; } #undef GREY } return (1); } /* * Construct a mapping table to convert from the range * of the data samples to [0,255] --for display. This * process also handles inverting B&W images when needed. */ static int setupMap(TIFFRGBAImage* img) { int32 x, range; range = (int32)((1L<bitspersample)-1); img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); if (img->Map == NULL) { TIFFError(TIFFFileName(img->tif), "No space for photometric conversion table"); return (0); } if (img->photometric == PHOTOMETRIC_MINISWHITE) { for (x = 0; x <= range; x++) img->Map[x] = ((range - x) * 255) / range; } else { for (x = 0; x <= range; x++) img->Map[x] = (x * 255) / range; } if (img->bitspersample <= 8 && (img->photometric == PHOTOMETRIC_MINISBLACK || img->photometric == PHOTOMETRIC_MINISWHITE)) { /* * Use photometric mapping table to construct * unpacking tables for samples <= 8 bits. */ if (!makebwmap(img)) return (0); /* no longer need Map, free it */ _TIFFfree(img->Map), img->Map = NULL; } return (1); } static int checkcmap(TIFFRGBAImage* img) { uint16* r = img->redcmap; uint16* g = img->greencmap; uint16* b = img->bluecmap; long n = 1L<bitspersample; while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) return (16); return (8); } static void cvtcmap(TIFFRGBAImage* img) { uint16* r = img->redcmap; uint16* g = img->greencmap; uint16* b = img->bluecmap; long i; for (i = (1L<bitspersample)-1; i >= 0; i--) { #define CVT(x) ((uint16)(((x) * 255) / ((1L<<16)-1))) r[i] = CVT(r[i]); g[i] = CVT(g[i]); b[i] = CVT(b[i]); #undef CVT } } /* * Palette images with <= 8 bits/sample are handled * with a table to avoid lots of shifts and masks. The table * is setup so that put*cmaptile (below) can retrieve 8/bitspersample * pixel values simply by indexing into the table with one * number. */ static int makecmap(TIFFRGBAImage* img) { int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; uint16* r = img->redcmap; uint16* g = img->greencmap; uint16* b = img->bluecmap; uint32 *p; int i; img->PALmap = (uint32**) _TIFFmalloc( 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); if (img->PALmap == NULL) { TIFFError(TIFFFileName(img->tif), "No space for Palette mapping table"); return (0); } p = (uint32*)(img->PALmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->PALmap[i] = p; #define CMAP(x) c = x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff); switch (bitspersample) { case 1: CMAP(i>>7); CMAP((i>>6)&1); CMAP((i>>5)&1); CMAP((i>>4)&1); CMAP((i>>3)&1); CMAP((i>>2)&1); CMAP((i>>1)&1); CMAP(i&1); break; case 2: CMAP(i>>6); CMAP((i>>4)&3); CMAP((i>>2)&3); CMAP(i&3); break; case 4: CMAP(i>>4); CMAP(i&0xf); break; case 8: CMAP(i); break; } #undef CMAP } return (1); } /* * Construct any mapping table used * by the associated put routine. */ static int buildMap(TIFFRGBAImage* img) { switch (img->photometric) { case PHOTOMETRIC_RGB: case PHOTOMETRIC_YCBCR: case PHOTOMETRIC_SEPARATED: if (img->bitspersample == 8) break; /* fall thru... */ case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: if (!setupMap(img)) return (0); break; case PHOTOMETRIC_PALETTE: /* * Convert 16-bit colormap to 8-bit (unless it looks * like an old-style 8-bit colormap). */ if (checkcmap(img) == 16) cvtcmap(img); else TIFFWarning(TIFFFileName(img->tif), "Assuming 8-bit colormap"); /* * Use mapping table and colormap to construct * unpacking tables for samples < 8 bits. */ if (img->bitspersample <= 8 && !makecmap(img)) return (0); break; } return (1); } /* * Select the appropriate conversion routine for packed data. */ static int pickTileContigCase(TIFFRGBAImage* img) { tileContigRoutine put = 0; if (buildMap(img)) { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAcontig8bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAcontig8bittile; else put = putRGBcontig8bittile; } else put = putRGBcontig8bitMaptile; break; case 16: put = putRGBcontig16bittile; if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAcontig16bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAcontig16bittile; } break; } break; case PHOTOMETRIC_SEPARATED: if (img->bitspersample == 8) { if (!img->Map) put = putRGBcontig8bitCMYKtile; else put = putRGBcontig8bitCMYKMaptile; } break; case PHOTOMETRIC_PALETTE: switch (img->bitspersample) { case 8: put = put8bitcmaptile; break; case 4: put = put4bitcmaptile; break; case 2: put = put2bitcmaptile; break; case 1: put = put1bitcmaptile; break; } break; case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (img->bitspersample) { case 8: put = putgreytile; break; case 4: put = put4bitbwtile; break; case 2: put = put2bitbwtile; break; case 1: put = put1bitbwtile; break; } break; case PHOTOMETRIC_YCBCR: if (img->bitspersample == 8) put = initYCbCrConversion(img); break; } } return ((img->put.contig = put) != 0); } /* * Select the appropriate conversion routine for unpacked data. * * NB: we assume that unpacked single channel data is directed * to the "packed routines. */ static int pickTileSeparateCase(TIFFRGBAImage* img) { tileSeparateRoutine put = 0; if (buildMap(img)) { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAseparate8bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAseparate8bittile; else put = putRGBseparate8bittile; } else put = putRGBseparate8bitMaptile; break; case 16: put = putRGBseparate16bittile; if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAseparate16bittile; else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAseparate16bittile; } break; } break; } } return ((img->put.separate = put) != 0); } else if (img->alpha == EXTRASAMPLE_UNASSALPHA) put = putRGBUAseparate8bittile; else put = putRGBseparate8bittile; } else put = putRGBseparate8bitMaptile; break; case 16: put = putRGBseparate16bittile; if (!img->Map) { if (img->alpha == EXTRASAMPLE_ASSOCALPHA) put = putRGBAAseparate16bittile; else if (img->alpha == EXTRASAMtiff-v3.4beta018/libtiff/tif_jpeg.c000444 004341 000024 00000122112 06003062745 016724 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_jpeg.c,v 1.23 1995/06/30 15:29:02 sam Exp $ */ /* * Copyright (c) 1994-1995 Sam Leffler * Copyright (c) 1994-1995 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. */ #include "tiffiop.h" #ifdef JPEG_SUPPORT /* * TIFF Library * * JPEG Compression support per TIFF Technical Note #2 * (*not* per the original TIFF 6.0 spec). * * This file is simply an interface to the libjpeg library written by * the Independent JPEG Group. You need release 5 or later of the IJG * code, which you can find on the Internet at ftp.uu.net:/graphics/jpeg/. * * Contributed by Tom Lane . */ #include #include #include #include "jpeglib.h" #include "jerror.h" /* * On some machines it may be worthwhile to use _setjmp or sigsetjmp * in place of plain setjmp. These macros will make it easier. */ #define SETJMP(jbuf) setjmp(jbuf) #define LONGJMP(jbuf,code) longjmp(jbuf,code) #define JMP_BUF jmp_buf typedef struct jpeg_destination_mgr jpeg_destination_mgr; typedef struct jpeg_source_mgr jpeg_source_mgr; typedef struct jpeg_error_mgr jpeg_error_mgr; /* * State block for each open TIFF file using * libjpeg to do JPEG compression/decompression. * * libjpeg's visible state is either a jpeg_compress_struct * or jpeg_decompress_struct depending on which way we * are going. comm can be used to refer to the fields * which are common to both. * * NB: cinfo is required to be the first member of JPEGState, * so we can safely cast JPEGState* -> jpeg_xxx_struct* * and vice versa! */ typedef struct { union { struct jpeg_compress_struct c; struct jpeg_decompress_struct d; struct jpeg_common_struct comm; } cinfo; /* NB: must be first */ jpeg_error_mgr err; /* libjpeg error manager */ JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ /* * The following two members could be a union, but * they're small enough that it's not worth the effort. */ jpeg_destination_mgr dest; /* data dest for compression */ jpeg_source_mgr src; /* data source for decompression */ /* private state */ TIFF* tif; /* back link needed by some code */ uint16 photometric; /* copy of PhotometricInterpretation */ uint16 h_sampling; /* luminance sampling factors */ uint16 v_sampling; tsize_t bytesperline; /* decompressed bytes per scanline */ /* pointers to intermediate buffers when processing downsampled data */ JSAMPARRAY ds_buffer[MAX_COMPONENTS]; int scancount; /* number of "scanlines" accumulated */ int samplesperclump; TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ TIFFStripMethod defsparent; /* super-class method */ TIFFTileMethod deftparent; /* super-class method */ /* pseudo-tag fields */ void* jpegtables; /* JPEGTables tag value, or NULL */ uint32 jpegtables_length; /* number of bytes in same */ int jpegquality; /* Compression quality level */ int jpegcolormode; /* Auto RGB<=>YCbCr convert? */ int jpegtablesmode; /* What to put in JPEGTables */ } JPEGState; #define JState(tif) ((JPEGState*)(tif)->tif_data) static int JPEGDecode(TIFF*, tidata_t, tsize_t, tsample_t); static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); static int JPEGEncode(TIFF*, tidata_t, tsize_t, tsample_t); static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); #define FIELD_JPEGTABLES (FIELD_CODEC+0) #define FIELD_JPEGQUALITY (FIELD_CODEC+1) #define FIELD_JPEGCOLORMODE (FIELD_CODEC+2) #define FIELD_JPEGTABLESMODE (FIELD_CODEC+3) static const TIFFFieldInfo jpegFieldInfo[] = { { TIFFTAG_JPEGTABLES, -1,-1, TIFF_UNDEFINED, FIELD_JPEGTABLES, FALSE, TRUE, "JPEGTables" }, { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, FIELD_JPEGQUALITY, TRUE, FALSE, "" }, { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, FIELD_JPEGCOLORMODE, FALSE, FALSE, "" }, { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, FIELD_JPEGTABLESMODE, FALSE, FALSE, "" }, }; #define N(a) (sizeof (a) / sizeof (a[0])) /* * libjpeg interface layer. * * We use setjmp/longjmp to return control to libtiff * when a fatal error is encountered within the JPEG * library. We also direct libjpeg error and warning * messages through the appropriate libtiff handlers. */ /* * Error handling routines (these replace corresponding * IJG routines from jerror.c). These are used for both * compression and decompression. */ static void TIFFjpeg_error_exit(j_common_ptr cinfo) { JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buffer); TIFFError("JPEGLib", buffer); /* display the error message */ jpeg_abort(cinfo); /* clean up libjpeg state */ LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ } /* * This routine is invoked only for warning messages, * since error_exit does its own thing and trace_level * is never set > 0. */ static void TIFFjpeg_output_message(j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message) (cinfo, buffer); TIFFWarning("JPEGLib", buffer); } /* * Interface routines. This layer of routines exists * primarily to limit side-effects from using setjmp. * Also, normal/error returns are converted into return * values per libtiff practice. */ #define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) #define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op),1)) static int TIFFjpeg_create_compress(JPEGState* sp) { /* initialize JPEG error handling */ sp->cinfo.c.err = jpeg_std_error(&sp->err); sp->err.error_exit = TIFFjpeg_error_exit; sp->err.output_message = TIFFjpeg_output_message; return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); } static int TIFFjpeg_create_decompress(JPEGState* sp) { /* initialize JPEG error handling */ sp->cinfo.d.err = jpeg_std_error(&sp->err); sp->err.error_exit = TIFFjpeg_error_exit; sp->err.output_message = TIFFjpeg_output_message; return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); } static int TIFFjpeg_set_defaults(JPEGState* sp) { return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); } static int TIFFjpeg_set_colorspace(JPEGState* sp, J_COLOR_SPACE colorspace) { return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); } static int TIFFjpeg_set_quality(JPEGState* sp, int quality, boolean force_baseline) { return CALLVJPEG(sp, jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); } static int TIFFjpeg_suppress_tables(JPEGState* sp, boolean suppress) { return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); } static int TIFFjpeg_start_compress(JPEGState* sp, boolean write_all_tables) { return CALLVJPEG(sp, jpeg_start_compress(&sp->cinfo.c, write_all_tables)); } static int TIFFjpeg_write_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int num_lines) { return CALLJPEG(sp, -1, (int) jpeg_write_scanlines(&sp->cinfo.c, scanlines, (JDIMENSION) num_lines)); } static int TIFFjpeg_write_raw_data(JPEGState* sp, JSAMPIMAGE data, int num_lines) { return CALLJPEG(sp, -1, (int) jpeg_write_raw_data(&sp->cinfo.c, data, (JDIMENSION) num_lines)); } static int TIFFjpeg_finish_compress(JPEGState* sp) { return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); } static int TIFFjpeg_write_tables(JPEGState* sp) { return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); } static int TIFFjpeg_read_header(JPEGState* sp, boolean require_image) { return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); } static int TIFFjpeg_start_decompress(JPEGState* sp) { return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); } static int TIFFjpeg_read_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int max_lines) { return CALLJPEG(sp, -1, (int) jpeg_read_scanlines(&sp->cinfo.d, scanlines, (JDIMENSION) max_lines)); } static int TIFFjpeg_read_raw_data(JPEGState* sp, JSAMPIMAGE data, int max_lines) { return CALLJPEG(sp, -1, (int) jpeg_read_raw_data(&sp->cinfo.d, data, (JDIMENSION) max_lines)); } static int TIFFjpeg_finish_decompress(JPEGState* sp) { return CALLJPEG(sp, -1, (int) jpeg_finish_decompress(&sp->cinfo.d)); } static int TIFFjpeg_abort(JPEGState* sp) { return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); } static int TIFFjpeg_destroy(JPEGState* sp) { return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); } static JSAMPARRAY TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id, JDIMENSION samplesperrow, JDIMENSION numrows) { return CALLJPEG(sp, (JSAMPARRAY) NULL, (*sp->cinfo.comm.mem->alloc_sarray) (&sp->cinfo.comm, pool_id, samplesperrow, numrows)); } /* * JPEG library destination data manager. * These routines direct compressed data from libjpeg into the * libtiff output buffer. */ static void std_init_destination(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; } static boolean std_empty_output_buffer(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; /* the entire buffer has been filled */ tif->tif_rawcc = tif->tif_rawdatasize; TIFFFlushData1(tif); sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; return (TRUE); } static void std_term_destination(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; tif->tif_rawcp = (tidata_t) sp->dest.next_output_byte; tif->tif_rawcc = tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; /* NB: libtiff does the final buffer flush */ } static void TIFFjpeg_data_dest(JPEGState* sp, TIFF* tif) { (void) tif; sp->cinfo.c.dest = &sp->dest; sp->dest.init_destination = std_init_destination; sp->dest.empty_output_buffer = std_empty_output_buffer; sp->dest.term_destination = std_term_destination; } /* * Alternate destination manager for outputting to JPEGTables field. */ static void tables_init_destination(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; /* while building, jpegtables_length is allocated buffer size */ sp->dest.next_output_byte = (JOCTET*) sp->jpegtables; sp->dest.free_in_buffer = (size_t) sp->jpegtables_length; } static boolean tables_empty_output_buffer(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; void* newbuf; /* the entire buffer has been filled; enlarge it by 1000 bytes */ newbuf = _TIFFrealloc((tdata_t) sp->jpegtables, (tsize_t) (sp->jpegtables_length + 1000)); if (newbuf == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; sp->dest.free_in_buffer = (size_t) 1000; sp->jpegtables = newbuf; sp->jpegtables_length += 1000; return (TRUE); } static void tables_term_destination(j_compress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; /* set tables length to number of bytes actually emitted */ sp->jpegtables_length -= sp->dest.free_in_buffer; } static int TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) { (void) tif; /* * Allocate a working buffer for building tables. * Initial size is 1000 bytes, which is usually adequate. */ if (sp->jpegtables) _TIFFfree(sp->jpegtables); sp->jpegtables_length = 1000; sp->jpegtables = (void*) _TIFFmalloc((tsize_t) sp->jpegtables_length); if (sp->jpegtables == NULL) { sp->jpegtables_length = 0; TIFFError("TIFFjpeg_tables_dest", "No space for JPEGTables"); return (0); } sp->cinfo.c.dest = &sp->dest; sp->dest.init_destination = tables_init_destination; sp->dest.empty_output_buffer = tables_empty_output_buffer; sp->dest.term_destination = tables_term_destination; return (1); } /* * JPEG library source data manager. * These routines supply compressed data to libjpeg. */ static void std_init_source(j_decompress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; } static boolean std_fill_input_buffer(j_decompress_ptr cinfo) { JPEGState* sp = (JPEGState* ) cinfo; static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI }; /* * Should never get here since entire strip/tile is * read into memory before the decompressor is called, * and thus was supplied by init_source. */ WARNMS(cinfo, JWRN_JPEG_EOF); /* insert a fake EOI marker */ sp->src.next_input_byte = dummy_EOI; sp->src.bytes_in_buffer = 2; return (TRUE); } static void std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { JPEGState* sp = (JPEGState*) cinfo; if (num_bytes > 0) { if (num_bytes > (long) sp->src.bytes_in_buffer) { /* oops, buffer overrun */ (void) std_fill_input_buffer(cinfo); } else { sp->src.next_input_byte += (size_t) num_bytes; sp->src.bytes_in_buffer -= (size_t) num_bytes; } } } static void std_term_source(j_decompress_ptr cinfo) { /* No work necessary here */ /* Or must we update tif->tif_rawcp, tif->tif_rawcc ??? */ /* (if so, need empty tables_term_source!) */ (void) cinfo; } static void TIFFjpeg_data_src(JPEGState* sp, TIFF* tif) { (void) tif; sp->cinfo.d.src = &sp->src; sp->src.init_source = std_init_source; sp->src.fill_input_buffer = std_fill_input_buffer; sp->src.skip_input_data = std_skip_input_data; sp->src.resync_to_restart = jpeg_resync_to_restart; sp->src.term_source = std_term_source; sp->src.bytes_in_buffer = 0; /* for safety */ sp->src.next_input_byte = NULL; } /* * Alternate source manager for reading from JPEGTables. * We can share all the code except for the init routine. */ static void tables_init_source(j_decompress_ptr cinfo) { JPEGState* sp = (JPEGState*) cinfo; sp->src.next_input_byte = (const JOCTET*) sp->jpegtables; sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length; } static void TIFFjpeg_tables_src(JPEGState* sp, TIFF* tif) { TIFFjpeg_data_src(sp, tif); sp->src.init_source = tables_init_source; } /* * Allocate downsampled-data buffers needed for downsampled I/O. * We use values computed in jpeg_start_compress or jpeg_start_decompress. * We use libjpeg's allocator so that buffers will be released automatically * when done with strip/tile. * This is also a handy place to compute samplesperclump, bytesperline. */ static int alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info, int num_components) { JPEGState* sp = JState(tif); int ci; jpeg_component_info* compptr; JSAMPARRAY buf; int samples_per_clump = 0; for (ci = 0, compptr = comp_info; ci < num_components; ci++, compptr++) { samples_per_clump += compptr->h_samp_factor * compptr->v_samp_factor; buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE, compptr->width_in_blocks * DCTSIZE, (JDIMENSION) (compptr->v_samp_factor*DCTSIZE)); if (buf == NULL) return (0); sp->ds_buffer[ci] = buf; } sp->samplesperclump = samples_per_clump; /* Cb,Cr both have sampling factors 1 */ /* so downsampled width of Cb is # of clumps per line */ sp->bytesperline = sizeof(JSAMPLE) * samples_per_clump * comp_info[1].downsampled_width; return (1); } /* * JPEG Decoding. */ static int JPEGSetupDecode(TIFF* tif) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; assert(sp != NULL); assert(sp->cinfo.comm.is_decompressor); /* Read JPEGTables if it is present */ if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) { TIFFjpeg_tables_src(sp, tif); if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { TIFFError("JPEGSetupDecode", "Bogus JPEGTables field"); return (0); } } /* Grab parameters that are same for all strips/tiles */ sp->photometric = td->td_photometric; switch (sp->photometric) { case PHOTOMETRIC_YCBCR: sp->h_sampling = td->td_ycbcrsubsampling[0]; sp->v_sampling = td->td_ycbcrsubsampling[1]; break; default: /* TIFF 6.0 forbids subsampling of all other color spaces */ sp->h_sampling = 1; sp->v_sampling = 1; break; } /* Set up for reading normal data */ TIFFjpeg_data_src(sp, tif); tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ return (1); } /* * Set up for decoding a strip or tile. */ static int JPEGPreDecode(TIFF* tif, tsample_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static char module[] = "JPEGPreDecode"; uint32 segment_width, segment_height; int downsampled_output; int ci; assert(sp != NULL); assert(sp->cinfo.comm.is_decompressor); /* * Reset decoder state from any previous strip/tile, * in case application didn't read the whole strip. */ if (!TIFFjpeg_abort(sp)) return (0); /* * Read the header for this strip/tile. */ if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) return (0); /* * Check image parameters and set decompression parameters. */ if (isTiled(tif)) { segment_width = td->td_tilewidth; segment_height = td->td_tilelength; sp->bytesperline = TIFFTileRowSize(tif); } else { segment_width = td->td_imagewidth; segment_height = td->td_imagelength - tif->tif_row; if (segment_height > td->td_rowsperstrip) segment_height = td->td_rowsperstrip; sp->bytesperline = TIFFScanlineSize(tif); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { /* * For PC 2, scale down the expected strip/tile size * to match a downsampled component */ segment_width = TIFFhowmany(segment_width, sp->h_sampling); segment_height = TIFFhowmany(segment_height, sp->v_sampling); } if (sp->cinfo.d.image_width != segment_width || sp->cinfo.d.image_height != segment_height) { TIFFError(module, "Improper JPEG strip/tile size"); return (0); } if (sp->cinfo.d.num_components != (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1)) { TIFFError(module, "Improper JPEG component count"); return (0); } if (sp->cinfo.d.data_precision != td->td_bitspersample) { TIFFError(module, "Improper JPEG data precision"); return (0); } if (td->td_planarconfig == PLANARCONFIG_CONTIG) { /* Component 0 should have expected sampling factors */ if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { TIFFError(module, "Improper JPEG sampling factors"); return (0); } /* Rest should have sampling factors 1,1 */ for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { TIFFError(module, "Improper JPEG sampling factors"); return (0); } } } else { /* PC 2's single component should have sampling factors 1,1 */ if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || sp->cinfo.d.comp_info[0].v_samp_factor != 1) { TIFFError(module, "Improper JPEG sampling factors"); return (0); } } downsampled_output = FALSE; if (td->td_planarconfig == PLANARCONFIG_CONTIG && sp->photometric == PHOTOMETRIC_YCBCR && sp->jpegcolormode == JPEGCOLORMODE_RGB) { /* Convert YCbCr to RGB */ sp->cinfo.d.jpeg_color_space = JCS_YCbCr; sp->cinfo.d.out_color_space = JCS_RGB; } else { /* Suppress colorspace handling */ sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; sp->cinfo.d.out_color_space = JCS_UNKNOWN; if (td->td_planarconfig == PLANARCONFIG_CONTIG && (sp->h_sampling != 1 || sp->v_sampling != 1)) downsampled_output = TRUE; /* XXX what about up-sampling? */ } if (downsampled_output) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.d.raw_data_out = TRUE; tif->tif_decoderow = JPEGDecodeRaw; tif->tif_decodestrip = JPEGDecodeRaw; tif->tif_decodetile = JPEGDecodeRaw; } else { /* Use normal interface to libjpeg */ sp->cinfo.d.raw_data_out = FALSE; tif->tif_decoderow = JPEGDecode; tif->tif_decodestrip = JPEGDecode; tif->tif_decodetile = JPEGDecode; } /* Start JPEG decompressor */ if (!TIFFjpeg_start_decompress(sp)) return (0); /* Allocate downsampled-data buffers if needed */ if (downsampled_output) { if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, sp->cinfo.d.num_components)) return (0); sp->scancount = DCTSIZE; /* mark buffer empty */ } return (1); } /* * Decode a chunk of pixels. * "Standard" case: returned data is not downsampled. */ static int JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { JPEGState *sp = JState(tif); tsize_t nrows; JSAMPROW bufptr[1]; (void) s; assert(sp != NULL); /* data is expected to be read in multiples of a scanline */ nrows = cc / sp->bytesperline; if (cc % sp->bytesperline) TIFFWarning(tif->tif_name, "fractional scanline not read"); while (nrows-- > 0) { bufptr[0] = (JSAMPROW) buf; if (TIFFjpeg_read_scanlines(sp, bufptr, 1) != 1) return (0); if (nrows > 0) tif->tif_row++; buf += sp->bytesperline; } /* Close down the decompressor if we've finished the strip or tile. */ if (sp->cinfo.d.output_scanline == sp->cinfo.d.output_height) { if (TIFFjpeg_finish_decompress(sp) != TRUE) return (0); } return (1); } /* * Decode a chunk of pixels. * Returned data is downsampled per sampling factors. */ static int JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; JSAMPLE* outptr; tsize_t nrows; JDIMENSION clumps_per_line, nclump; int clumpoffset, ci, xpos, ypos; jpeg_component_info* compptr; int samples_per_clump = sp->samplesperclump; (void) s; assert(sp != NULL); /* data is expected to be read in multiples of a scanline */ nrows = cc / sp->bytesperline; if (cc % sp->bytesperline) TIFFWarning(tif->tif_name, "fractional scanline not read"); /* Cb,Cr both have sampling factors 1, so this is correct */ clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; while (nrows-- > 0) { /* Reload downsampled-data buffer if needed */ if (sp->scancount >= DCTSIZE) { int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) return (0); sp->scancount = 0; /* Close down the decompressor if done. */ if (sp->cinfo.d.output_scanline >= sp->cinfo.d.output_height) { if (TIFFjpeg_finish_decompress(sp) != TRUE) return (0); } } /* * Fastest way to unseparate the data is to make one pass * over the scanline for each row of each component. */ clumpoffset = 0; /* first sample in clump */ for (ci = 0, compptr = sp->cinfo.d.comp_info; ci < sp->cinfo.d.num_components; ci++, compptr++) { int hsamp = compptr->h_samp_factor; int vsamp = compptr->v_samp_factor; for (ypos = 0; ypos < vsamp; ypos++) { inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; outptr = ((JSAMPLE*) buf) + clumpoffset; if (hsamp == 1) { /* fast path for at least Cb and Cr */ for (nclump = clumps_per_line; nclump-- > 0; ) { outptr[0] = *inptr++; outptr += samples_per_clump; } } else { /* general case */ for (nclump = clumps_per_line; nclump-- > 0; ) { for (xpos = 0; xpos < hsamp; xpos++) outptr[xpos] = *inptr++; outptr += samples_per_clump; } } clumpoffset += hsamp; } } sp->scancount++; if (nrows > 0) tif->tif_row++; buf += sp->bytesperline; } return (1); } /* * JPEG Encoding. */ static void unsuppress_quant_table (JPEGState* sp, int tblno) { JQUANT_TBL* qtbl; if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) qtbl->sent_table = FALSE; } static void unsuppress_huff_table (JPEGState* sp, int tblno) { JHUFF_TBL* htbl; if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) htbl->sent_table = FALSE; if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) htbl->sent_table = FALSE; } static int prepare_JPEGTables(TIFF* tif) { JPEGState* sp = JState(tif); /* Initialize quant tables for current quality setting */ if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) return (0); /* Mark only the tables we want for output */ /* NB: chrominance tables are currently used only with YCbCr */ if (!TIFFjpeg_suppress_tables(sp, TRUE)) return (0); if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { unsuppress_quant_table(sp, 0); if (sp->photometric == PHOTOMETRIC_YCBCR) unsuppress_quant_table(sp, 1); } if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { unsuppress_huff_table(sp, 0); if (sp->photometric == PHOTOMETRIC_YCBCR) unsuppress_huff_table(sp, 1); } /* Direct libjpeg output into jpegtables */ if (!TIFFjpeg_tables_dest(sp, tif)) return (0); /* Emit tables-only datastream */ if (!TIFFjpeg_write_tables(sp)) return (0); return (1); } static int JPEGSetupEncode(TIFF* tif) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static char module[] = "JPEGSetupEncode"; assert(sp != NULL); assert(!sp->cinfo.comm.is_decompressor); /* * Initialize all JPEG parameters to default values. * Note that jpeg_set_defaults needs legal values for * in_color_space and input_components. */ sp->cinfo.c.in_color_space = JCS_UNKNOWN; sp->cinfo.c.input_components = 1; if (!TIFFjpeg_set_defaults(sp)) return (0); /* Set per-file parameters */ sp->photometric = td->td_photometric; switch (sp->photometric) { case PHOTOMETRIC_YCBCR: sp->h_sampling = td->td_ycbcrsubsampling[0]; sp->v_sampling = td->td_ycbcrsubsampling[1]; /* * A ReferenceBlackWhite field *must* be present since the * default value is inappropriate for YCbCr. Fill in the * proper value if application didn't set it. */ #ifdef COLORIMETRY_SUPPORT if (!TIFFFieldSet(tif, FIELD_REFBLACKWHITE)) { float refbw[6]; long top = 1L << td->td_bitspersample; refbw[0] = 0; refbw[1] = (float)(top-1L); refbw[2] = (float)(top>>1); refbw[3] = refbw[1]; refbw[4] = refbw[2]; refbw[5] = refbw[1]; TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw); } #endif break; case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ case PHOTOMETRIC_MASK: TIFFError(module, "PhotometricInterpretation %d not allowed for JPEG", (int) sp->photometric); return (0); default: /* TIFF 6.0 forbids subsampling of all other color spaces */ sp->h_sampling = 1; sp->v_sampling = 1; break; } /* Verify miscellaneous parameters */ /* * This would need work if libtiff ever supports different * depths for different components, or if libjpeg ever supports * run-time selection of depth. Neither is imminent. */ if (td->td_bitspersample != BITS_IN_JSAMPLE) { TIFFError(module, "BitsPerSample %d not allowed for JPEG", (int) td->td_bitspersample); return (0); } sp->cinfo.c.data_precision = td->td_bitspersample; if (isTiled(tif)) { if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { TIFFError(module, "JPEG tile height must be multiple of %d", sp->v_sampling * DCTSIZE); return (0); } if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { TIFFError(module, "JPEG tile width must be multiple of %d", sp->h_sampling * DCTSIZE); return (0); } } else { if (td->td_rowsperstrip < td->td_imagelength && (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { TIFFError(module, "RowsPerStrip must be multiple of %d for JPEG", sp->v_sampling * DCTSIZE); return (0); } } /* Create a JPEGTables field if appropriate */ if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { if (!prepare_JPEGTables(tif)) return (0); /* Mark the field present */ /* Can't use TIFFSetField since BEENWRITING is already set! */ TIFFSetFieldBit(tif, FIELD_JPEGTABLES); tif->tif_flags |= TIFF_DIRTYDIRECT; } else { /* We do not support application-supplied JPEGTables, */ /* so mark the field not present */ TIFFClrFieldBit(tif, FIELD_JPEGTABLES); } /* Direct libjpeg output to libtiff's output buffer */ TIFFjpeg_data_dest(sp, tif); return (1); } /* * Set encoding state at the start of a strip or tile. */ static int JPEGPreEncode(TIFF* tif, tsample_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static char module[] = "JPEGPreEncode"; uint32 segment_width, segment_height; int downsampled_input; assert(sp != NULL); assert(!sp->cinfo.comm.is_decompressor); /* * Set encoding parameters for this strip/tile. */ if (isTiled(tif)) { segment_width = td->td_tilewidth; segment_height = td->td_tilelength; sp->bytesperline = TIFFTileRowSize(tif); } else { segment_width = td->td_imagewidth; segment_height = td->td_imagelength - tif->tif_row; if (segment_height > td->td_rowsperstrip) segment_height = td->td_rowsperstrip; sp->bytesperline = TIFFScanlineSize(tif); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { /* for PC 2, scale down the strip/tile size * to match a downsampled component */ segment_width = TIFFhowmany(segment_width, sp->h_sampling); segment_height = TIFFhowmany(segment_height, sp->v_sampling); } if (segment_width > 65535 || segment_height > 65535) { TIFFError(module, "Strip/tile too large for JPEG"); return (0); } sp->cinfo.c.image_width = segment_width; sp->cinfo.c.image_height = segment_height; downsampled_input = FALSE; if (td->td_planarconfig == PLANARCONFIG_CONTIG) { sp->cinfo.c.input_components = td->td_samplesperpixel; if (sp->photometric == PHOTOMETRIC_YCBCR) { if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { sp->cinfo.c.in_color_space = JCS_RGB; } else { sp->cinfo.c.in_color_space = JCS_YCbCr; if (sp->h_sampling != 1 || sp->v_sampling != 1) downsampled_input = TRUE; } if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) return (0); /* * Set Y sampling factors; * we assume jpeg_set_colorspace() set the rest to 1 */ sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; } else { sp->cinfo.c.in_color_space = JCS_UNKNOWN; if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) return (0); /* jpeg_set_colorspace set all sampling factors to 1 */ } } else { sp->cinfo.c.input_components = 1; sp->cinfo.c.in_color_space = JCS_UNKNOWN; if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) return (0); sp->cinfo.c.comp_info[0].component_id = s; /* jpeg_set_colorspace() set sampling factors to 1 */ if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { sp->cinfo.c.comp_info[0].quant_tbl_no = 1; sp->cinfo.c.comp_info[0].dc_tbl_no = 1; sp->cinfo.c.comp_info[0].ac_tbl_no = 1; } } /* ensure libjpeg won't write any extraneous markers */ sp->cinfo.c.write_JFIF_header = FALSE; sp->cinfo.c.write_Adobe_marker = FALSE; /* set up table handling correctly */ if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) { if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) return (0); unsuppress_quant_table(sp, 0); unsuppress_quant_table(sp, 1); } if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) sp->cinfo.c.optimize_coding = FALSE; else sp->cinfo.c.optimize_coding = TRUE; if (downsampled_input) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.c.raw_data_in = TRUE; tif->tif_encoderow = JPEGEncodeRaw; tif->tif_encodestrip = JPEGEncodeRaw; tif->tif_encodetile = JPEGEncodeRaw; } else { /* Use normal interface to libjpeg */ sp->cinfo.c.raw_data_in = FALSE; tif->tif_encoderow = JPEGEncode; tif->tif_encodestrip = JPEGEncode; tif->tif_encodetile = JPEGEncode; } /* Start JPEG compressor */ if (!TIFFjpeg_start_compress(sp, FALSE)) return (0); /* Allocate downsampled-data buffers if needed */ if (downsampled_input) { if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, sp->cinfo.c.num_components)) return (0); } sp->scancount = 0; return (1); } /* * Encode a chunk of pixels. * "Standard" case: incoming data is not downsampled. */ static int JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { JPEGState *sp = JState(tif); tsize_t nrows; JSAMPROW bufptr[1]; (void) s; assert(sp != NULL); /* data is expected to be supplied in multiples of a scanline */ nrows = cc / sp->bytesperline; if (cc % sp->bytesperline) TIFFWarning(tif->tif_name, "fractional scanline discarded"); while (nrows-- > 0) { bufptr[0] = (JSAMPROW) buf; if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) return (0); if (nrows > 0) tif->tif_row++; buf += sp->bytesperline; } return (1); } /* * Encode a chunk of pixels. * Incoming data is expected to be downsampled per sampling factors. */ static int JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; JSAMPLE* outptr; tsize_t nrows; JDIMENSION clumps_per_line, nclump; int clumpoffset, ci, xpos, ypos; jpeg_component_info* compptr; int samples_per_clump = sp->samplesperclump; (void) s; assert(sp != NULL); /* data is expected to be supplied in multiples of a scanline */ nrows = cc / sp->bytesperline; if (cc % sp->bytesperline) TIFFWarning(tif->tif_name, "fractional scanline discarded"); /* Cb,Cr both have sampling factors 1, so this is correct */ clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; while (nrows-- > 0) { /* * Fastest way to separate the data is to make one pass * over the scanline for each row of each component. */ clumpoffset = 0; /* first sample in clump */ for (ci = 0, compptr = sp->cinfo.c.comp_info; ci < sp->cinfo.c.num_components; ci++, compptr++) { int hsamp = compptr->h_samp_factor; int vsamp = compptr->v_samp_factor; int padding = (int) (compptr->width_in_blocks * DCTSIZE - clumps_per_line * hsamp); for (ypos = 0; ypos < vsamp; ypos++) { inptr = ((JSAMPLE*) buf) + clumpoffset; outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; if (hsamp == 1) { /* fast path for at least Cb and Cr */ for (nclump = clumps_per_line; nclump-- > 0; ) { *outptr++ = inptr[0]; inptr += samples_per_clump; } } else { /* general case */ for (nclump = clumps_per_line; nclump-- > 0; ) { for (xpos = 0; xpos < hsamp; xpos++) *outptr++ = inptr[xpos]; inptr += samples_per_clump; } } /* pad each scanline as needed */ for (xpos = 0; xpos < padding; xpos++) { *outptr = outptr[-1]; outptr++; } clumpoffset += hsamp; } } sp->scancount++; if (sp->scancount >= DCTSIZE) { int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) return (0); sp->scancount = 0; } if (nrows > 0) tif->tif_row++; buf += sp->bytesperline; } return (1); } /* * Finish up at the end of a strip or tile. */ static int JPEGPostEncode(TIFF* tif) { JPEGState *sp = JState(tif); if (sp->scancount > 0) { /* * Need to emit a partial bufferload of downsampled data. * Pad the data vertically. */ int ci, ypos, n; jpeg_component_info* compptr; for (ci = 0, compptr = sp->cinfo.c.comp_info; ci < sp->cinfo.c.num_components; ci++, compptr++) { int vsamp = compptr->v_samp_factor; tsize_t row_width = compptr->width_in_blocks * DCTSIZE * sizeof(JSAMPLE); for (ypos = sp->scancount * vsamp; ypos < DCTSIZE * vsamp; ypos++) { _TIFFmemcpy((tdata_t)sp->ds_buffer[ci][ypos], (tdata_t)sp->ds_buffer[ci][ypos-1], row_width); } } n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) return (0); } return (TIFFjpeg_finish_compress(JState(tif))); } static void JPEGCleanup(TIFF* tif) { if (tif->tif_data) { JPEGState *sp = JState(tif); TIFFjpeg_destroy(sp); /* release libjpeg resources */ if (sp->jpegtables) /* tag value */ _TIFFfree(sp->jpegtables); _TIFFfree(tif->tif_data); /* release local state */ tif->tif_data = NULL; } } static int JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap) { JPEGState* sp = JState(tif); TIFFDirectory* td = &tif->tif_dir; uint32 v32; switch (tag) { case TIFFTAG_JPEGTABLES: v32 = va_arg(ap, uint32); if (v32 == 0) { /* XXX */ return (0); } _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), (long) v32); sp->jpegtables_length = v32; TIFFSetFieldBit(tif, FIELD_JPEGTABLES); break; case TIFFTAG_JPEGQUALITY: sp->jpegquality = va_arg(ap, int); return (1); /* pseudo tag */ case TIFFTAG_JPEGCOLORMODE: sp->jpegcolormode = va_arg(ap, int); /* * Mark whether returned data is up-sampled or not * so TIFFStripSize and TIFFTileSize return values * that reflect the true amount of data. */ tif->tif_flags &= ~TIFF_UPSAMPLED; if (td->td_planarconfig == PLANARCONFIG_CONTIG) { if (td->td_photometric == PHOTOMETRIC_YCBCR && sp->jpegcolormode == JPEGCOLORMODE_RGB) { tif->tif_flags |= TIFF_UPSAMPLED; } else { if (td->td_ycbcrsubsampling[0] != 1 || td->td_ycbcrsubsampling[1] != 1) ; /* XXX what about up-sampling? */ } } /* * Must recalculate cached tile size * in case sampling state changed. */ tif->tif_tilesize = TIFFTileSize(tif); return (1); /* pseudo tag */ case TIFFTAG_JPEGTABLESMODE: sp->jpegtablesmode = va_arg(ap, int); return (1); /* pseudo tag */ default: return (*sp->vsetparent)(tif, tag, ap); } tif->tif_flags |= TIFF_DIRTYDIRECT; return (1); } static int JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap) { JPEGState* sp = JState(tif); switch (tag) { case TIFFTAG_JPEGTABLES: /* u_short is bogus --- should be uint32 ??? */ /* TIFFWriteNormalTag needs fixed XXX */ *va_arg(ap, u_short*) = (u_short) sp->jpegtables_length; *va_arg(ap, void**) = sp->jpegtables; break; case TIFFTAG_JPEGQUALITY: *va_arg(ap, int*) = sp->jpegquality; break; case TIFFTAG_JPEGCOLORMODE: *va_arg(ap, int*) = sp->jpegcolormode; break; case TIFFTAG_JPEGTABLESMODE: *va_arg(ap, int*) = sp->jpegtablesmode; break; default: return (*sp->vgetparent)(tif, tag, ap); } return (1); } static void JPEGPrintDir(TIFF* tif, FILE* fd, long flags) { JPEGState* sp = JState(tif); (void) flags; if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) fprintf(fd, " JPEG Tables: (%lu bytes)\n", (u_long) sp->jpegtables_length); } static uint32 JPEGDefaultStripSize(TIFF* tif, uint32 s) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; s = (*sp->defsparent)(tif, s); if (s < td->td_imagelength) s = TIFFroundup(s, td->td_ycbcrsubsampling[1] * DCTSIZE); return (s); } static void JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; (*sp->deftparent)(tif, tw, th); *tw = TIFFroundup(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); *th = TIFFroundup(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); } int TIFFInitJPEG(TIFF* tif, int scheme) { JPEGState* sp; assert(scheme == COMPRESSION_JPEG); /* * Allocate state block so tag methods have storage to record values. */ tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState)); if (tif->tif_data == NULL) { TIFFError("TIFFInitJPEG", "No space for JPEG state block"); return (0); } sp = JState(tif); sp->tif = tif; /* back link */ /* * Merge codec-specific tag information and * override parent get/set field methods. */ _TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo)); sp->vgetparent = tif->tif_vgetfield; tif->tif_vgetfield = JPEGVGetField; /* hook for codec tags */ sp->vsetparent = tif->tif_vsetfield; tif->tif_vsetfield = JPEGVSetField; /* hook for codec tags */ tif->tif_printdir = JPEGPrintDir; /* hook for codec tags */ /* Default values for codec-specific fields */ sp->jpegtables = NULL; sp->jpegtables_length = 0; sp->jpegquality = 75; /* Default IJG quality */ sp->jpegcolormode = JPEGCOLORMODE_RAW; sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; /* * Install codec methods. */ tif->tif_setupdecode = JPEGSetupDecode; tif->tif_predecode = JPEGPreDecode; tif->tif_decoderow = JPEGDecode; tif->tif_decodestrip = JPEGDecode; tif->tif_decodetile = JPEGDecode; tif->tif_setupencode = JPEGSetupEncode; tif->tif_preencode = JPEGPreEncode; tif->tif_postencode = JPEGPostEncode; tif->tif_encoderow = JPEGEncode; tif->tif_encodestrip = JPEGEncode; tif->tif_encodetile = JPEGEncode; tif->tif_cleanup = JPEGCleanup; sp->defsparent = tif->tif_defstripsize; tif->tif_defstripsize = JPEGDefaultStripSize; sp->deftparent = tif->tif_deftilesize; tif->tif_deftilesize = JPEGDefaultTileSize; tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ /* * Initialize libjpeg. */ if (tif->tif_mode == O_RDONLY) { if (!TIFFjpeg_create_decompress(sp)) return (0); } else { if (!TIFFjpeg_create_compress(sp)) return (0); } return (1); } #endif /* JPEG_SUPPORT */ JPEGEncode; tif->tif_cleanup = JPEGCleanup; sp->defsparent = tif->tif_defstripsize; tif->tif_defstripsize = JPEGDefaultStripSize; sp->deftparent = tif->tif_deftilesize; tif->tif_deftilesize = JPEGDefaultTileSize; tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ /* * Initialize libjpeg. */ if (tif->tif_mode == O_RDONLY) { if (!TIFFjpeg_create_decompress(sp)) return (0); } else { if (!TIFFjpeg_create_tiff-v3.4beta018/libtiff/tif_lzw.c000444 004341 000024 00000065134 06003062746 016626 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_lzw.c,v 1.69 1995/07/19 00:39:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" #ifdef LZW_SUPPORT /* * TIFF Library. * Rev 5.0 Lempel-Ziv & Welch Compression Support * * This code is derived from the compress program whose code is * derived from software contributed to Berkeley by James A. Woods, * derived from original work by Spencer Thomas and Joseph Orost. * * The original Berkeley copyright notice appears below in its entirety. */ #include "tif_predict.h" #include #include /* * NB: The 5.0 spec describes a different algorithm than Aldus * implements. Specifically, Aldus does code length transitions * one code earlier than should be done (for real LZW). * Earlier versions of this library implemented the correct * LZW algorithm, but emitted codes in a bit order opposite * to the TIFF spec. Thus, to maintain compatibility w/ Aldus * we interpret MSB-LSB ordered codes to be images written w/ * old versions of this library, but otherwise adhere to the * Aldus "off by one" algorithm. * * Future revisions to the TIFF spec are expected to "clarify this issue". */ #define LZW_COMPAT /* include backwards compatibility code */ /* * Each strip of data is supposed to be terminated by a CODE_EOI. * If the following #define is included, the decoder will also * check for end-of-strip w/o seeing this code. This makes the * library more robust, but also slower. */ #define LZW_CHECKEOS /* include checks for strips w/o EOI code */ #define MAXCODE(n) ((1L<<(n))-1) /* * The TIFF spec specifies that encoded bit * strings range from 9 to 12 bits. */ #define BITS_MIN 9 /* start with 9 bits */ #define BITS_MAX 12 /* max of 12 bit strings */ /* predefined codes */ #define CODE_CLEAR 256 /* code to clear string table */ #define CODE_EOI 257 /* end-of-information code */ #define CODE_FIRST 258 /* first free code entry */ #define CODE_MAX MAXCODE(BITS_MAX) #define HSIZE 9001L /* 91% occupancy */ #define HSHIFT (13-8) #ifdef LZW_COMPAT /* NB: +1024 is for compatibility with old files */ #define CSIZE (MAXCODE(BITS_MAX)+1024L) #else #define CSIZE (MAXCODE(BITS_MAX)+1L) #endif /* * State block for each open TIFF file using LZW * compression/decompression. Note that the predictor * state block must be first in this data structure. */ typedef struct { TIFFPredictorState predict; /* predictor super class */ u_short nbits; /* # of bits/code */ u_short maxcode; /* maximum code for lzw_nbits */ u_short free_ent; /* next free entry in hash table */ long nextdata; /* next bits of i/o */ long nextbits; /* # of valid bits in lzw_nextdata */ } LZWBaseState; #define lzw_nbits base.nbits #define lzw_maxcode base.maxcode #define lzw_free_ent base.free_ent #define lzw_nextdata base.nextdata #define lzw_nextbits base.nextbits /* * Decoding-specific state. */ typedef struct code_ent { struct code_ent *next; u_short length; /* string len, including this token */ u_char value; /* data value */ u_char firstchar; /* first token of string */ } code_t; typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); typedef struct { LZWBaseState base; long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ long dec_restart; /* restart count */ #ifdef LZW_CHECKEOS long dec_bitsleft; /* available bits in raw data */ #endif decodeFunc dec_decode; /* regular or backwards compatible */ code_t* dec_codep; /* current recognized code */ code_t* dec_oldcodep; /* previously recognized code */ code_t* dec_free_entp; /* next free entry */ code_t* dec_maxcodep; /* max available entry */ code_t* dec_codetab; /* kept separate for small machines */ } LZWDecodeState; /* * Encoding-specific state. */ typedef uint16 hcode_t; /* codes fit in 16 bits */ typedef struct { long hash; hcode_t code; } hash_t; typedef struct { LZWBaseState base; int enc_oldcode; /* last code encountered */ long enc_checkpoint; /* point at which to clear table */ #define CHECK_GAP 10000 /* enc_ratio check interval */ long enc_ratio; /* current compression ratio */ long enc_incount; /* (input) data bytes encoded */ long enc_outcount; /* encoded (output) bytes */ tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */ hash_t* enc_hashtab; /* kept separate for small machines */ } LZWEncodeState; #define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) #define DecoderState(tif) ((LZWDecodeState*) LZWState(tif)) #define EncoderState(tif) ((LZWEncodeState*) LZWState(tif)) static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); #ifdef LZW_COMPAT static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); #endif static void cl_hash(LZWEncodeState*); /* * LZW Decoder. */ #ifdef LZW_CHECKEOS /* * This check shouldn't be necessary because each * strip is suppose to be terminated with CODE_EOI. */ #define NextCode(_tif, _sp, _bp, _code, _get) { \ if ((_sp)->dec_bitsleft < nbits) { \ TIFFWarning(_tif->tif_name, \ "LZWDecode: Strip %d not terminated with EOI code", \ _tif->tif_curstrip); \ _code = CODE_EOI; \ } else { \ _get(_sp,_bp,_code); \ (_sp)->dec_bitsleft -= nbits; \ } \ } #else #define NextCode(tif, sp, bp, code, get) get(sp, bp, code) #endif static int LZWSetupDecode(TIFF* tif) { LZWDecodeState* sp = DecoderState(tif); static char module[] = " LZWSetupDecode"; int code; assert(sp != NULL); if (sp->dec_codetab == NULL) { sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); if (sp->dec_codetab == NULL) { TIFFError(module, "No space for LZW code table"); return (0); } /* * Pre-load the table. */ for (code = 255; code >= 0; code--) { sp->dec_codetab[code].value = code; sp->dec_codetab[code].firstchar = code; sp->dec_codetab[code].length = 1; sp->dec_codetab[code].next = NULL; } } return (1); } /* * Setup state for decoding a strip. */ static int LZWPreDecode(TIFF* tif, tsample_t s) { LZWDecodeState *sp = DecoderState(tif); (void) s; assert(sp != NULL); /* * Check for old bit-reversed codes. */ if (tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { #ifdef LZW_COMPAT if (!sp->dec_decode) { TIFFWarning(tif->tif_name, "Old-style LZW codes, convert file"); /* * Override default decoding methods with * ones that deal with the old coding. * Otherwise the predictor versions set * above will call the compatibility routines * through the dec_decode method. */ tif->tif_decoderow = LZWDecodeCompat; tif->tif_decodestrip = LZWDecodeCompat; tif->tif_decodetile = LZWDecodeCompat; /* * If doing horizontal differencing, must * re-setup the predictor logic since we * switched the basic decoder methods... */ (*tif->tif_setupdecode)(tif); sp->dec_decode = LZWDecodeCompat; } sp->lzw_maxcode = MAXCODE(BITS_MIN); #else /* !LZW_COMPAT */ if (!sp->dec_decode) { TIFFError(tif->tif_name, "Old-style LZW codes not supported"); sp->dec_decode = LZWDecode; } return (0); #endif/* !LZW_COMPAT */ } else { sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; sp->dec_decode = LZWDecode; } sp->lzw_nbits = BITS_MIN; sp->lzw_nextbits = 0; sp->lzw_nextdata = 0; sp->dec_restart = 0; sp->dec_nbitsmask = MAXCODE(BITS_MIN); #ifdef LZW_CHECKEOS sp->dec_bitsleft = tif->tif_rawcc << 3; #endif sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; /* * Zero entries that are not yet filled in. We do * this to guard against bogus input data that causes * us to index into undefined entries. If you can * come up with a way to safely bounds-check input codes * while decoding then you can remove this operation. */ _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); sp->dec_oldcodep = &sp->dec_codetab[-1]; sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; return (1); } /* * Decode a "hunk of data". */ #define GetNextCode(sp, bp, code) { \ nextdata = (nextdata<<8) | *(bp)++; \ nextbits += 8; \ if (nextbits < nbits) { \ nextdata = (nextdata<<8) | *(bp)++; \ nextbits += 8; \ } \ code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ nextbits -= nbits; \ } static void codeLoop(TIFF* tif) { TIFFError(tif->tif_name, "LZWDecode: Bogus encoding, loop in the code table; scanline %d", tif->tif_row); } static int LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) { LZWDecodeState *sp = DecoderState(tif); char *op = (char*) op0; long occ = (long) occ0; char *tp; u_char *bp; hcode_t code; int len; long nbits, nextbits, nextdata, nbitsmask; code_t *codep, *free_entp, *maxcodep, *oldcodep; (void) s; assert(sp != NULL); /* * Restart interrupted output operation. */ if (sp->dec_restart) { long residue; codep = sp->dec_codep; residue = codep->length - sp->dec_restart; if (residue > occ) { /* * Residue from previous decode is sufficient * to satisfy decode request. Skip to the * start of the decoded string, place decoded * values in the output buffer, and return. */ sp->dec_restart += occ; do { codep = codep->next; } while (--residue > occ && codep); if (codep) { tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ && codep); } return (1); } /* * Residue satisfies only part of the decode request. */ op += residue, occ -= residue; tp = op; do { int t; --tp; t = codep->value; codep = codep->next; *tp = t; } while (--residue && codep); sp->dec_restart = 0; } bp = (u_char *)tif->tif_rawcp; nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; nbitsmask = sp->dec_nbitsmask; oldcodep = sp->dec_oldcodep; free_entp = sp->dec_free_entp; maxcodep = sp->dec_maxcodep; while (occ > 0) { NextCode(tif, sp, bp, code, GetNextCode); if (code == CODE_EOI) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask-1; NextCode(tif, sp, bp, code, GetNextCode); if (code == CODE_EOI) break; *op++ = code, occ--; oldcodep = sp->dec_codetab + code; continue; } codep = sp->dec_codetab + code; /* * Add the new entry to the code table. */ assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); free_entp->next = oldcodep; free_entp->firstchar = free_entp->next->firstchar; free_entp->length = free_entp->next->length+1; free_entp->value = (codep < free_entp) ? codep->firstchar : free_entp->firstchar; if (++free_entp > maxcodep) { if (++nbits > BITS_MAX) /* should not happen */ nbits = BITS_MAX; nbitsmask = MAXCODE(nbits); maxcodep = sp->dec_codetab + nbitsmask-1; } oldcodep = codep; if (code >= 256) { /* * Code maps to a string, copy string * value to output (written in reverse). */ if (codep->length > occ) { /* * String is too long for decode buffer, * locate portion that will fit, copy to * the decode buffer, and setup restart * logic for the next decoding call. */ sp->dec_codep = codep; do { codep = codep->next; } while (codep && codep->length > occ); if (codep) { sp->dec_restart = occ; tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ && codep); if (codep) codeLoop(tif); } break; } len = codep->length; tp = op + len; do { int t; --tp; t = codep->value; codep = codep->next; *tp = t; } while (codep && tp > op); if (codep) { codeLoop(tif); break; } op += len, occ -= len; } else *op++ = code, occ--; } tif->tif_rawcp = (tidata_t) bp; sp->lzw_nbits = (u_short) nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->dec_nbitsmask = nbitsmask; sp->dec_oldcodep = oldcodep; sp->dec_free_entp = free_entp; sp->dec_maxcodep = maxcodep; if (occ > 0) { TIFFError(tif->tif_name, "LZWDecode: Not enough data at scanline %d (short %d bytes)", tif->tif_row, occ); return (0); } return (1); } #ifdef LZW_COMPAT /* * Decode a "hunk of data" for old images. */ #define GetNextCodeCompat(sp, bp, code) { \ nextdata |= (u_long) *(bp)++ << nextbits; \ nextbits += 8; \ if (nextbits < nbits) { \ nextdata |= (u_long) *(bp)++ << nextbits; \ nextbits += 8; \ } \ code = (hcode_t)(nextdata & nbitsmask); \ nextdata >>= nbits; \ nextbits -= nbits; \ } static int LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) { LZWDecodeState *sp = DecoderState(tif); char *op = (char*) op0; long occ = (long) occ0; char *tp; u_char *bp; int code, nbits; long nextbits, nextdata, nbitsmask; code_t *codep, *free_entp, *maxcodep, *oldcodep; (void) s; assert(sp != NULL); /* * Restart interrupted output operation. */ if (sp->dec_restart) { long residue; codep = sp->dec_codep; residue = codep->length - sp->dec_restart; if (residue > occ) { /* * Residue from previous decode is sufficient * to satisfy decode request. Skip to the * start of the decoded string, place decoded * values in the output buffer, and return. */ sp->dec_restart += occ; do { codep = codep->next; } while (--residue > occ); tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); return (1); } /* * Residue satisfies only part of the decode request. */ op += residue, occ -= residue; tp = op; do { *--tp = codep->value; codep = codep->next; } while (--residue); sp->dec_restart = 0; } bp = (u_char *)tif->tif_rawcp; nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; nbitsmask = sp->dec_nbitsmask; oldcodep = sp->dec_oldcodep; free_entp = sp->dec_free_entp; maxcodep = sp->dec_maxcodep; while (occ > 0) { NextCode(tif, sp, bp, code, GetNextCodeCompat); if (code == CODE_EOI) break; if (code == CODE_CLEAR) { free_entp = sp->dec_codetab + CODE_FIRST; nbits = BITS_MIN; nbitsmask = MAXCODE(BITS_MIN); maxcodep = sp->dec_codetab + nbitsmask; NextCode(tif, sp, bp, code, GetNextCodeCompat); if (code == CODE_EOI) break; *op++ = code, occ--; oldcodep = sp->dec_codetab + code; continue; } codep = sp->dec_codetab + code; /* * Add the new entry to the code table. */ assert(&sp->dec_codetab[0] <= free_entp && free_entp < &sp->dec_codetab[CSIZE]); free_entp->next = oldcodep; free_entp->firstchar = free_entp->next->firstchar; free_entp->length = free_entp->next->length+1; free_entp->value = (codep < free_entp) ? codep->firstchar : free_entp->firstchar; if (++free_entp > maxcodep) { if (++nbits > BITS_MAX) /* should not happen */ nbits = BITS_MAX; nbitsmask = MAXCODE(nbits); maxcodep = sp->dec_codetab + nbitsmask; } oldcodep = codep; if (code >= 256) { /* * Code maps to a string, copy string * value to output (written in reverse). */ if (codep->length > occ) { /* * String is too long for decode buffer, * locate portion that will fit, copy to * the decode buffer, and setup restart * logic for the next decoding call. */ sp->dec_codep = codep; do { codep = codep->next; } while (codep->length > occ); sp->dec_restart = occ; tp = op + occ; do { *--tp = codep->value; codep = codep->next; } while (--occ); break; } op += codep->length, occ -= codep->length; tp = op; do { *--tp = codep->value; } while (codep = codep->next); } else *op++ = code, occ--; } tif->tif_rawcp = (tidata_t) bp; sp->lzw_nbits = nbits; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->dec_nbitsmask = nbitsmask; sp->dec_oldcodep = oldcodep; sp->dec_free_entp = free_entp; sp->dec_maxcodep = maxcodep; if (occ > 0) { TIFFError(tif->tif_name, "LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)", tif->tif_row, occ); return (0); } return (1); } #endif /* LZW_COMPAT */ /* * LZW Encoding. */ static int LZWSetupEncode(TIFF* tif) { LZWEncodeState* sp = EncoderState(tif); static char module[] = "LZWSetupEncode"; assert(sp != NULL); sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); if (sp->enc_hashtab == NULL) { TIFFError(module, "No space for LZW hash table"); return (0); } return (1); } /* * Reset encoding state at the start of a strip. */ static int LZWPreEncode(TIFF* tif, tsample_t s) { LZWEncodeState *sp = EncoderState(tif); (void) s; assert(sp != NULL); sp->lzw_nbits = BITS_MIN; sp->lzw_maxcode = MAXCODE(BITS_MIN); sp->lzw_free_ent = CODE_FIRST; sp->lzw_nextbits = 0; sp->lzw_nextdata = 0; sp->enc_checkpoint = CHECK_GAP; sp->enc_ratio = 0; sp->enc_incount = 0; sp->enc_outcount = 0; /* * The 4 here insures there is space for 2 max-sized * codes in LZWEncode and LZWPostDecode. */ sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; cl_hash(sp); /* clear hash table */ sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ return (1); } #define CALCRATIO(sp, rat) { \ if (incount > 0x007fffff) { /* NB: shift will overflow */\ rat = outcount >> 8; \ rat = (rat == 0 ? 0x7fffffff : incount/rat); \ } else \ rat = (incount<<8) / outcount; \ } #define PutNextCode(op, c) { \ nextdata = (nextdata << nbits) | c; \ nextbits += nbits; \ *op++ = (u_char)(nextdata >> (nextbits-8)); \ nextbits -= 8; \ if (nextbits >= 8) { \ *op++ = (u_char)(nextdata >> (nextbits-8)); \ nextbits -= 8; \ } \ outcount += nbits; \ } /* * Encode a chunk of pixels. * * Uses an open addressing double hashing (no chaining) on the * prefix code/next character combination. We do a variant of * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's * relatively-prime secondary probe. Here, the modular division * first probe is gives way to a faster exclusive-or manipulation. * Also do block compression with an adaptive reset, whereby the * code table is cleared when the compression ratio decreases, * but after the table fills. The variable-length output codes * are re-sized at this point, and a CODE_CLEAR is generated * for the decoder. */ static int LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { register LZWEncodeState *sp = EncoderState(tif); register long fcode; register hash_t *hp; register int h, c; hcode_t ent; long disp; long incount, outcount, checkpoint; long nextdata, nextbits; int free_ent, maxcode, nbits; tidata_t op, limit; (void) s; if (sp == NULL) return (0); /* * Load local state. */ incount = sp->enc_incount; outcount = sp->enc_outcount; checkpoint = sp->enc_checkpoint; nextdata = sp->lzw_nextdata; nextbits = sp->lzw_nextbits; free_ent = sp->lzw_free_ent; maxcode = sp->lzw_maxcode; nbits = sp->lzw_nbits; op = tif->tif_rawcp; limit = sp->enc_rawlimit; ent = sp->enc_oldcode; if (ent == (hcode_t) -1 && cc > 0) { /* * NB: This is safe because it can only happen * at the start of a strip where we know there * is space in the data buffer. */ PutNextCode(op, CODE_CLEAR); ent = *bp++; cc--; incount++; } while (cc > 0) { c = *bp++; cc--; incount++; fcode = ((long)c << BITS_MAX) + ent; h = (c << HSHIFT) ^ ent; /* xor hashing */ #ifdef _WINDOWS /* * Check hash index for an overflow. */ if (h >= HSIZE) h -= HSIZE; #endif hp = &sp->enc_hashtab[h]; if (hp->hash == fcode) { ent = hp->code; continue; } if (hp->hash >= 0) { /* * Primary hash failed, check secondary hash. */ disp = HSIZE - h; if (h == 0) disp = 1; do { #ifndef _WINDOWS if ((hp -= disp) < sp->enc_hashtab) hp += HSIZE; #else /* * Avoid pointer arithmetic 'cuz of * wraparound problems with segments. */ if ((h -= disp) < 0) h += HSIZE; hp = &sp->enc_hashtab[h]; #endif if (hp->hash == fcode) { ent = hp->code; goto hit; } } while (hp->hash >= 0); } /* * New entry, emit code and add to table. */ /* * Verify there is space in the buffer for the code * and any potential Clear code that might be emitted * below. The value of limit is setup so that there * are at least 4 bytes free--room for 2 codes. */ if (op > limit) { tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); TIFFFlushData1(tif); op = tif->tif_rawdata; } PutNextCode(op, ent); ent = c; hp->code = free_ent++; hp->hash = fcode; if (free_ent == CODE_MAX-1) { /* table is full, emit clear code and reset */ cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else { /* * If the next entry is going to be too big for * the code size, then increase it, if possible. */ if (free_ent > maxcode) { nbits++; assert(nbits <= BITS_MAX); maxcode = (int) MAXCODE(nbits); } else if (incount >= checkpoint) { long rat; /* * Check compression ratio and, if things seem * to be slipping, clear the hash table and * reset state. The compression ratio is a * 24+8-bit fractional number. */ checkpoint = incount+CHECK_GAP; CALCRATIO(sp, rat); if (rat <= sp->enc_ratio) { cl_hash(sp); sp->enc_ratio = 0; incount = 0; outcount = 0; free_ent = CODE_FIRST; PutNextCode(op, CODE_CLEAR); nbits = BITS_MIN; maxcode = MAXCODE(BITS_MIN); } else sp->enc_ratio = rat; } } hit: ; } /* * Restore global state. */ sp->enc_incount = incount; sp->enc_outcount = outcount; sp->enc_checkpoint = checkpoint; sp->enc_oldcode = ent; sp->lzw_nextdata = nextdata; sp->lzw_nextbits = nextbits; sp->lzw_free_ent = free_ent; sp->lzw_maxcode = maxcode; sp->lzw_nbits = nbits; tif->tif_rawcp = op; return (1); } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ static int LZWPostEncode(TIFF* tif) { register LZWEncodeState *sp = EncoderState(tif); tidata_t op = tif->tif_rawcp; long nextbits = sp->lzw_nextbits; long nextdata = sp->lzw_nextdata; long outcount = sp->enc_outcount; int nbits = sp->lzw_nbits; if (op > sp->enc_rawlimit) { tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); TIFFFlushData1(tif); op = tif->tif_rawdata; } if (sp->enc_oldcode != (hcode_t) -1) { PutNextCode(op, sp->enc_oldcode); sp->enc_oldcode = (hcode_t) -1; } PutNextCode(op, CODE_EOI); if (nextbits > 0) *op++ = (u_char)(nextdata << (8-nextbits)); tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); return (1); } /* * Reset encoding hash table. */ static void cl_hash(LZWEncodeState* sp) { register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; register long i = HSIZE-8; do { i -= 8; hp[-7].hash = -1; hp[-6].hash = -1; hp[-5].hash = -1; hp[-4].hash = -1; hp[-3].hash = -1; hp[-2].hash = -1; hp[-1].hash = -1; hp[ 0].hash = -1; hp -= 8; } while (i >= 0); for (i += 8; i > 0; i--, hp--) hp->hash = -1; } static void LZWCleanup(TIFF* tif) { if (tif->tif_data) { if (tif->tif_mode == O_RDONLY) { if (DecoderState(tif)->dec_codetab) _TIFFfree(DecoderState(tif)->dec_codetab); } else { if (EncoderState(tif)->enc_hashtab) _TIFFfree(EncoderState(tif)->enc_hashtab); } _TIFFfree(tif->tif_data); tif->tif_data = NULL; } } int TIFFInitLZW(TIFF* tif, int scheme) { assert(scheme == COMPRESSION_LZW); /* * Allocate state block so tag methods have storage to record values. */ if (tif->tif_mode == O_RDONLY) { tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWDecodeState)); if (tif->tif_data == NULL) goto bad; DecoderState(tif)->dec_codetab = NULL; DecoderState(tif)->dec_decode = NULL; } else { tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWEncodeState)); if (tif->tif_data == NULL) goto bad; EncoderState(tif)->enc_hashtab = NULL; } /* * Install codec methods. */ tif->tif_setupdecode = LZWSetupDecode; tif->tif_predecode = LZWPreDecode; tif->tif_decoderow = LZWDecode; tif->tif_decodestrip = LZWDecode; tif->tif_decodetile = LZWDecode; tif->tif_setupencode = LZWSetupEncode; tif->tif_preencode = LZWPreEncode; tif->tif_postencode = LZWPostEncode; tif->tif_encoderow = LZWEncode; tif->tif_encodestrip = LZWEncode; tif->tif_encodetile = LZWEncode; tif->tif_cleanup = LZWCleanup; /* * Setup predictor setup. */ (void) TIFFPredictorInit(tif); return (1); bad: TIFFError("TIFFInitLZW", "No space for LZW state block"); return (0); } /* * Copyright (c) 1985, 1986 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * James A. Woods, derived from original work by Spencer Thomas * and Joseph Orost. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #endif /* LZW_SUPPORT */ elated to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRAtiff-v3.4beta018/libtiff/tif_msdos.c000444 004341 000024 00000007770 06003062746 017141 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_msdos.c,v 1.13 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 MSDOS-specific Routines. */ #if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) #include /* for open, close, etc. function prototypes */ #include #endif #include "tiffiop.h" static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { return (read((int) fd, buf, size)); } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return (write((int) fd, buf, size)); } static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { return (lseek((int) fd, (off_t) off, whence)); } static int _tiffCloseProc(thandle_t fd) { return (close((int) fd)); } #include static toff_t _tiffSizeProc(thandle_t fd) { struct stat sb; return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); } static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { } /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (void*) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m, fd; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); fd = open(name, m|O_BINARY, 0666); if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF*)0); } return (TIFFFdOpen(fd, name, mode)); } #ifdef __GNUC__ extern char* malloc(); extern char* realloc(); #else #include #endif tdata_t _TIFFmalloc(tsize_t s) { return (malloc((size_t) s)); } void _TIFFfree(tdata_t p) { free(p); } tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { return (realloc(p, (size_t) s)); } void _TIFFmemset(tdata_t p, int v, tsize_t c) { memset(p, v, (size_t) c); } void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) { memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { return (memcmp(p1, p2, (size_t) c)); } static void msdosWarningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler; static void msdosErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler; ngHandletiff-v3.4beta018/libtiff/tif_next.c000444 004341 000024 00000007243 06003062747 016766 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_next.c,v 1.26 1995/06/30 15:29:02 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" #ifdef NEXT_SUPPORT /* * TIFF Library. * * NeXT 2-bit Grey Scale Compression Algorithm Support */ #define SETPIXEL(op, v) { \ switch (npixels++ & 3) { \ case 0: op[0] = (v) << 6; break; \ case 1: op[0] |= (v) << 4; break; \ case 2: op[0] |= (v) << 2; break; \ case 3: *op++ |= (v); break; \ } \ } #define LITERALROW 0x00 #define LITERALSPAN 0x40 #define WHITE ((1<<2)-1) static int NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { register u_char *bp, *op; register tsize_t cc; register int n; tidata_t row; tsize_t scanline; (void) s; /* * Each scanline is assumed to start off as all * white (we assume a PhotometricInterpretation * of ``min-is-black''). */ for (op = buf, cc = occ; cc-- > 0;) *op++ = 0xff; bp = (u_char *)tif->tif_rawcp; cc = tif->tif_rawcc; scanline = tif->tif_scanlinesize; for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) { n = *bp++, cc--; switch (n) { case LITERALROW: /* * The entire scanline is given as literal values. */ if (cc < scanline) goto bad; _TIFFmemcpy(row, bp, scanline); bp += scanline; cc -= scanline; break; case LITERALSPAN: { int off; /* * The scanline has a literal span * that begins at some offset. */ off = (bp[0] * 256) + bp[1]; n = (bp[2] * 256) + bp[3]; if (cc < 4+n) goto bad; _TIFFmemcpy(row+off, bp+4, n); bp += 4+n; cc -= 4+n; break; } default: { register int npixels = 0, grey; u_long imagewidth = tif->tif_dir.td_imagewidth; /* * The scanline is composed of a sequence * of constant color ``runs''. We shift * into ``run mode'' and interpret bytes * as codes of the form * until we've filled the scanline. */ op = row; for (;;) { grey = (n>>6) & 0x3; n &= 0x3f; while (n-- > 0) SETPIXEL(op, grey); if (npixels >= imagewidth) break; if (cc == 0) goto bad; n = *bp++, cc--; } break; } } } tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcc = cc; return (1); bad: TIFFError(tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", (long) tif->tif_row); return (0); } int TIFFInitNeXT(TIFF* tif, int scheme) { (void) scheme; tif->tif_decoderow = NeXTDecode; tif->tif_decodestrip = NeXTDecode; tif->tif_decodetile = NeXTDecode; return (1); } #endif /* NEXT_SUPPORT */ if (npixels >= imagewidth) break; if (cc == 0) goto bad; n = *bp++, cc--; } break; } } } tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcc = cc; return (1); bad: TIFFError(tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", (long) tif->tif_row); return (0); } int TIFFInitNeXT(TIFF* tif, int scheme) {tiff-v3.4beta018/libtiff/tif_open.c000444 004341 000024 00000023251 06003062747 016746 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_open.c,v 1.58 1995/07/17 01:27:01 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" static const long typemask[13] = { 0L, /* TIFF_NOTYPE */ 0x000000ffL, /* TIFF_BYTE */ 0xffffffffL, /* TIFF_ASCII */ 0x0000ffffL, /* TIFF_SHORT */ 0xffffffffL, /* TIFF_LONG */ 0xffffffffL, /* TIFF_RATIONAL */ 0x000000ffL, /* TIFF_SBYTE */ 0x000000ffL, /* TIFF_UNDEFINED */ 0x0000ffffL, /* TIFF_SSHORT */ 0xffffffffL, /* TIFF_SLONG */ 0xffffffffL, /* TIFF_SRATIONAL */ 0xffffffffL, /* TIFF_FLOAT */ 0xffffffffL, /* TIFF_DOUBLE */ }; static const int bigTypeshift[13] = { 0, /* TIFF_NOTYPE */ 24, /* TIFF_BYTE */ 0, /* TIFF_ASCII */ 16, /* TIFF_SHORT */ 0, /* TIFF_LONG */ 0, /* TIFF_RATIONAL */ 24, /* TIFF_SBYTE */ 24, /* TIFF_UNDEFINED */ 16, /* TIFF_SSHORT */ 0, /* TIFF_SLONG */ 0, /* TIFF_SRATIONAL */ 0, /* TIFF_FLOAT */ 0, /* TIFF_DOUBLE */ }; static const int litTypeshift[13] = { 0, /* TIFF_NOTYPE */ 0, /* TIFF_BYTE */ 0, /* TIFF_ASCII */ 0, /* TIFF_SHORT */ 0, /* TIFF_LONG */ 0, /* TIFF_RATIONAL */ 0, /* TIFF_SBYTE */ 0, /* TIFF_UNDEFINED */ 0, /* TIFF_SSHORT */ 0, /* TIFF_SLONG */ 0, /* TIFF_SRATIONAL */ 0, /* TIFF_FLOAT */ 0, /* TIFF_DOUBLE */ }; /* * Initialize the bit fill order, the * shift & mask tables, and the byte * swapping state according to the file * contents and the machine architecture. */ static void TIFFInitOrder(register TIFF* tif, int magic, int bigendian) { #ifdef notdef /* * NB: too many applications assume that data is returned * by the library in MSB2LSB bit order to change the * default bit order to reflect the native cpu. This * may change in the future in which case applications * will need to check the value of the FillOrder tag. */ tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | HOST_FILLORDER; #else tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | FILLORDER_MSB2LSB; #endif tif->tif_typemask = typemask; if (magic == TIFF_BIGENDIAN) { tif->tif_typeshift = bigTypeshift; if (!bigendian) tif->tif_flags |= TIFF_SWAB; } else { tif->tif_typeshift = litTypeshift; if (bigendian) tif->tif_flags |= TIFF_SWAB; } } int _TIFFgetMode(const char* mode, const char* module) { int m = -1; switch (mode[0]) { case 'r': m = O_RDONLY; if (mode[1] == '+') m = O_RDWR; break; case 'w': case 'a': m = O_RDWR|O_CREAT; if (mode[0] == 'w') m |= O_TRUNC; break; default: TIFFError(module, "\"%s\": Bad mode", mode); break; } return (m); } TIFF* TIFFClientOpen( const char* name, const char* mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc ) { static const char module[] = "TIFFClientOpen"; TIFF *tif; int m, bigendian; m = _TIFFgetMode(mode, module); if (m == -1) goto bad2; tif = (TIFF *)_TIFFmalloc(sizeof (TIFF) + strlen(name) + 1); if (tif == NULL) { TIFFError(module, "%s: Out of memory (TIFF structure)", name); goto bad2; } _TIFFmemset(tif, 0, sizeof (*tif)); tif->tif_name = (char *)tif + sizeof (TIFF); strcpy(tif->tif_name, name); tif->tif_mode = m &~ (O_CREAT|O_TRUNC); tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ tif->tif_curoff = 0; tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ tif->tif_row = (uint32)-1; /* read/write pre-increment */ tif->tif_clientdata = clientdata; tif->tif_readproc = readproc; tif->tif_writeproc = writeproc; tif->tif_seekproc = seekproc; tif->tif_closeproc = closeproc; tif->tif_sizeproc = sizeproc; tif->tif_mapproc = mapproc; tif->tif_unmapproc = unmapproc; { union { int i; char c[4]; } u; u.i = 1; bigendian = u.c[0] == 0; } #ifdef ENDIANHACK_SUPPORT /* * Numerous vendors, typically on the PC, do not correctly * support TIFF; they only support the Intel little-endian * byte order. If this hack is enabled, then applications * can open a file with a specific byte-order by specifying * either "wl" (for litt-endian byte order) or "wb" for * (big-endian byte order). This support is not configured * by default because it supports the violation of the TIFF * spec that says that readers *MUST* support both byte orders. * * It is strongly recommended that you not use this feature * except to deal with busted apps that write invalid TIFF. * And even in those cases you should bang on the vendors to * fix their software. */ if ((m&O_CREAT) && ((bigendian && mode[1] == 'l') || (!bigendian && mode[1] == 'b'))) tif->tif_flags |= TIFF_SWAB; #endif /* * Read in TIFF header. */ if (!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { if (tif->tif_mode == O_RDONLY) { TIFFError(name, "Cannot read TIFF header"); goto bad; } /* * Setup header and write. */ tif->tif_header.tiff_magic = tif->tif_flags & TIFF_SWAB ? (bigendian ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN) : (bigendian ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN); tif->tif_header.tiff_version = TIFF_VERSION; tif->tif_header.tiff_diroff = 0; /* filled in later */ if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { TIFFError(name, "Error writing TIFF header"); goto bad; } /* * Setup the byte order handling. */ TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); /* * Setup default directory. */ if (!TIFFDefaultDirectory(tif)) goto bad; tif->tif_diroff = 0; return (tif); } /* * Setup the byte order handling. */ if (tif->tif_header.tiff_magic != TIFF_BIGENDIAN && tif->tif_header.tiff_magic != TIFF_LITTLEENDIAN) { TIFFError(name, "Not a TIFF file, bad magic number %d (0x%x)", tif->tif_header.tiff_magic, tif->tif_header.tiff_magic); goto bad; } TIFFInitOrder(tif, tif->tif_header.tiff_magic, bigendian); /* * Swap header if required. */ if (tif->tif_flags & TIFF_SWAB) { TIFFSwabShort(&tif->tif_header.tiff_version); TIFFSwabLong(&tif->tif_header.tiff_diroff); } /* * Now check version (if needed, it's been byte-swapped). * Note that this isn't actually a version number, it's a * magic number that doesn't change (stupid). */ if (tif->tif_header.tiff_version != TIFF_VERSION) { TIFFError(name, "Not a TIFF file, bad version number %d (0x%x)", tif->tif_header.tiff_version, tif->tif_header.tiff_version); goto bad; } tif->tif_flags |= TIFF_MYBUFFER; tif->tif_rawcp = tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; /* * Setup initial directory. */ switch (mode[0]) { case 'r': tif->tif_nextdiroff = tif->tif_header.tiff_diroff; if (TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) tif->tif_flags |= TIFF_MAPPED; if (TIFFReadDirectory(tif)) { tif->tif_rawcc = -1; tif->tif_flags |= TIFF_BUFFERSETUP; return (tif); } break; case 'a': /* * New directories are automatically append * to the end of the directory chain when they * are written out (see TIFFWriteDirectory). */ if (!TIFFDefaultDirectory(tif)) goto bad; return (tif); } bad: tif->tif_mode = O_RDONLY; /* XXX avoid flush */ TIFFClose(tif); return ((TIFF*)0); bad2: (void) (*closeproc)(clientdata); return ((TIFF*)0); } /* * Query functions to access private data. */ /* * Return open file's name. */ const char * TIFFFileName(TIFF* tif) { return (tif->tif_name); } /* * Return open file's I/O descriptor. */ int TIFFFileno(TIFF* tif) { return (tif->tif_fd); } /* * Return read/write mode. */ int TIFFGetMode(TIFF* tif) { return (tif->tif_mode); } /* * Return nonzero if file is organized in * tiles; zero if organized as strips. */ int TIFFIsTiled(TIFF* tif) { return (isTiled(tif)); } /* * Return current row being read/written. */ uint32 TIFFCurrentRow(TIFF* tif) { return (tif->tif_row); } /* * Return index of the current directory. */ tdir_t TIFFCurrentDirectory(TIFF* tif) { return (tif->tif_curdir); } /* * Return current strip. */ tstrip_t TIFFCurrentStrip(TIFF* tif) { return (tif->tif_curstrip); } /* * Return current tile. */ ttile_t TIFFCurrentTile(TIFF* tif) { return (tif->tif_curtile); } /* * Return nonzero if the file has byte-swapped data. */ int TIFFIsByteSwapped(TIFF* tif) { return ((tif->tif_flags & TIFF_SWAB) != 0); } /* * Return nonzero if the data is returned up-sampled. */ int TIFFIsUpSampled(TIFF* tif) { return (isUpSampled(tif)); } /* * Return nonzero if the data is returned in MSB-to-LSB bit order. */ int TIFFIsMSB2LSB(TIFF* tif) { return (isFillOrder(tif, FILLORDER_MSB2LSB)); } urn current tile. */ ttile_t TIFFCurrentTile(TIFF* tif) { return (tif->tif_curtile); } /* * Return nonzero if the file has byte-swapped data. */ int TIFFIsByteSwapped(TIFF* tif) { return ((tif->tif_flags & TIFF_SWAB) != 0); } /* * Return nonzero if the data is returned up-sampled. */ int TIFFIsUpSampled(TIFF* tif) { return (isUpSamtiff-v3.4beta018/libtiff/tif_packbits.c000444 004341 000024 00000014553 06003062750 017604 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_packbits.c,v 1.47 1995/06/30 15:29:02 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" #ifdef PACKBITS_SUPPORT /* * TIFF Library. * * PackBits Compression Algorithm Support */ #include #include static int PackBitsPreEncode(TIFF* tif, tsample_t s) { (void) s; /* * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) tif->tif_data = (tidata_t) TIFFTileRowSize(tif); else tif->tif_data = (tidata_t) TIFFScanlineSize(tif); return (1); } /* * NB: tidata is the type representing *(tidata_t); * if tidata_t is made signed then this type must * be adjusted accordingly. */ typedef unsigned char tidata; /* * Encode a run of pixels. */ static int PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) { u_char* bp = (u_char*) buf; tidata_t op, ep, lastliteral; long n, slop; int b; enum { BASE, LITERAL, RUN, LITERAL_RUN } state; (void) s; op = tif->tif_rawcp; ep = tif->tif_rawdata + tif->tif_rawdatasize; state = BASE; lastliteral = 0; while (cc > 0) { /* * Find the longest string of identical bytes. */ b = *bp++, cc--, n = 1; for (; cc > 0 && b == *bp; cc--, bp++) n++; again: if (op + 2 >= ep) { /* insure space for new data */ /* * Be careful about writing the last * literal. Must write up to that point * and then copy the remainder to the * front of the buffer. */ if (state == LITERAL || state == LITERAL_RUN) { slop = op - lastliteral; tif->tif_rawcc += lastliteral - tif->tif_rawcp; if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; while (slop-- > 0) *op++ = *lastliteral++; lastliteral = tif->tif_rawcp; } else { tif->tif_rawcc += op - tif->tif_rawcp; if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; } } switch (state) { case BASE: /* initial state, set run/literal */ if (n > 1) { state = RUN; if (n > 128) { *op++ = (tidata) -127; *op++ = b; n -= 128; goto again; } *op++ = (tidataval_t)(-(n-1)); *op++ = b; } else { lastliteral = op; *op++ = 0; *op++ = b; state = LITERAL; } break; case LITERAL: /* last object was literal string */ if (n > 1) { state = LITERAL_RUN; if (n > 128) { *op++ = (tidata) -127; *op++ = b; n -= 128; goto again; } *op++ = (tidataval_t)(-(n-1)); /* encode run */ *op++ = b; } else { /* extend literal */ if (++(*lastliteral) == 127) state = BASE; *op++ = b; } break; case RUN: /* last object was run */ if (n > 1) { if (n > 128) { *op++ = (tidata) -127; *op++ = b; n -= 128; goto again; } *op++ = (tidataval_t)(-(n-1)); *op++ = b; } else { lastliteral = op; *op++ = 0; *op++ = b; state = LITERAL; } break; case LITERAL_RUN: /* literal followed by a run */ /* * Check to see if previous run should * be converted to a literal, in which * case we convert literal-run-literal * to a single literal. */ if (n == 1 && op[-2] == (tidata) -1 && *lastliteral < 126) { state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); op[-2] = op[-1]; /* replicate */ } else state = RUN; goto again; } } tif->tif_rawcc += op - tif->tif_rawcp; tif->tif_rawcp = op; return (1); } /* * Encode a rectangular chunk of pixels. We break it up * into row-sized pieces to insure that encoded runs do * not span rows. Otherwise, there can be problems with * the decoder if data is read, for example, by scanlines * when it was encoded by strips. */ static int PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { tsize_t rowsize = (tsize_t) tif->tif_data; assert(rowsize > 0); while ((long)cc > 0) { if (PackBitsEncode(tif, bp, rowsize, s) < 0) return (-1); bp += rowsize; cc -= rowsize; } return (1); } static int PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) { char *bp; tsize_t cc; (void) s; bp = (char*) tif->tif_rawcp; cc = tif->tif_rawcc; while (cc > 0 && (long)occ > 0) { long n; int b; n = (long) *bp++, cc--; /* * Watch out for compilers that * don't sign extend chars... */ if (n >= 128) n -= 256; if (n < 0) { /* replicate next byte -n+1 times */ cc--; if (n == -128) /* nop */ continue; n = -n + 1; occ -= n; for (b = *bp++; n-- > 0;) *op++ = b; } else { /* copy next n+1 bytes literally */ _TIFFmemcpy(op, bp, ++n); op += n; occ -= n; bp += n; cc -= n; } } tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcc = cc; if (occ > 0) { TIFFError(tif->tif_name, "PackBitsDecode: Not enough data for scanline %ld", (long) tif->tif_row); return (0); } /* check for buffer overruns? */ return (1); } int TIFFInitPackBits(TIFF* tif, int scheme) { (void) scheme; tif->tif_decoderow = PackBitsDecode; tif->tif_decodestrip = PackBitsDecode; tif->tif_decodetile = PackBitsDecode; tif->tif_preencode = PackBitsPreEncode; tif->tif_encoderow = PackBitsEncode; tif->tif_encodestrip = PackBitsEncodeChunk; tif->tif_encodetile = PackBitsEncodeChunk; return (1); } #endif /* PACKBITS_SUPPORT */ data for scanline %ld", (long) tif->tif_row); return (0); } /* check for buffer overruns? */ return (1); } int TIFFInitPackBits(TIFF* titiff-v3.4beta018/libtiff/tif_predict.h000444 004341 000024 00000004605 06003062750 017440 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_predict.h,v 1.1 1995/06/29 17:20:19 sam Exp $ */ /* * Copyright (c) 1995 Sam Leffler * Copyright (c) 1995 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. */ #ifndef _TIFFPREDICT_ #define _TIFFPREDICT_ /* * ``Library-private'' Support for the Predictor Tag */ /* * Codecs that want to support the Predictor tag must place * this structure first in their private state block so that * the predictor code can cast tif_data to find its state. */ typedef struct { int predictor; /* predictor tag value */ int stride; /* sample stride over data */ tsize_t rowsize; /* tile/strip row size */ TIFFPostMethod pfunc; /* horizontal differencer/accumulator */ TIFFCodeMethod coderow; /* parent codec encode/decode row */ TIFFCodeMethod codestrip; /* parent codec encode/decode strip */ TIFFCodeMethod codetile; /* parent codec encode/decode tile */ TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ TIFFPrintMethod printdir; /* super-class method */ TIFFBoolMethod setupdecode; /* super-class method */ TIFFBoolMethod setupencode; /* super-class method */ } TIFFPredictorState; #if defined(__cplusplus) extern "C" { #endif extern int TIFFPredictorInit(TIFF*); #if defined(__cplusplus) } #endif #endif /* _TIFFPREDICT_ */ decode strip */ TIFFCodeMethod codetile; /* parent codec encode/decode tile */ TIFFVGetMethod vgetparent; /* super-class tiff-v3.4beta018/libtiff/tif_predict.c000444 004341 000024 00000027506 06003062750 017440 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_predict.c,v 1.3 1995/07/01 00:12:45 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Predictor Tag Support (used by multiple codecs). */ #include "tiffiop.h" #include "tif_predict.h" #include #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) static void horAcc8(TIFF*, tidata_t, tsize_t); static void horAcc16(TIFF*, tidata_t, tsize_t); static void swabHorAcc16(TIFF*, tidata_t, tsize_t); static void horDiff8(TIFF*, tidata_t, tsize_t); static void horDiff16(TIFF*, tidata_t, tsize_t); static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); static int PredictorSetup(TIFF* tif) { TIFFPredictorState* sp = PredictorState(tif); TIFFDirectory* td = &tif->tif_dir; if (sp->predictor == 1) /* no differencing */ return (1); if (sp->predictor != 2) { TIFFError(tif->tif_name, "\"Predictor\" value %d not supported", sp->predictor); return (0); } if (td->td_bitspersample != 8 && td->td_bitspersample != 16) { TIFFError(tif->tif_name, "Horizontal differencing \"Predictor\" not supported with %d-bit samples", td->td_bitspersample); return (0); } sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); /* * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) sp->rowsize = TIFFTileRowSize(tif); else sp->rowsize = TIFFScanlineSize(tif); return (1); } static int PredictorSetupDecode(TIFF* tif) { TIFFPredictorState* sp = PredictorState(tif); TIFFDirectory* td = &tif->tif_dir; if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) return (0); if (sp->predictor == 2) { switch (td->td_bitspersample) { case 8: sp->pfunc = horAcc8; break; case 16: sp->pfunc = horAcc16; break; } /* * Override default decoding method with * one that does the predictor stuff. */ sp->coderow = tif->tif_decoderow; tif->tif_decoderow = PredictorDecodeRow; sp->codestrip = tif->tif_decodestrip; tif->tif_decodestrip = PredictorDecodeTile; sp->codetile = tif->tif_decodetile; tif->tif_decodetile = PredictorDecodeTile; /* * If the data is horizontally differenced * 16-bit data that requires byte-swapping, * then it must be byte swapped before the * accumulation step. We do this with a * special-purpose routine and override the * normal post decoding logic that the library * setup when the directory was read. */ if (tif->tif_flags&TIFF_SWAB) { if (sp->pfunc == horAcc16) { sp->pfunc = swabHorAcc16; tif->tif_postdecode = _TIFFNoPostDecode; } /* else handle 32-bit case... */ } } return (1); } static int PredictorSetupEncode(TIFF* tif) { TIFFPredictorState* sp = PredictorState(tif); TIFFDirectory* td = &tif->tif_dir; if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) return (0); if (sp->predictor == 2) { switch (td->td_bitspersample) { case 8: sp->pfunc = horDiff8; break; case 16: sp->pfunc = horDiff16; break; } /* * Override default encoding method with * one that does the predictor stuff. */ sp->coderow = tif->tif_encoderow; tif->tif_encoderow = PredictorEncodeRow; sp->codestrip = tif->tif_encodestrip; tif->tif_encodestrip = PredictorEncodeTile; sp->codetile = tif->tif_encodetile; tif->tif_encodetile = PredictorEncodeTile; } return (1); } #define REPEAT4(n, op) \ switch (n) { \ default: { int i; for (i = n-4; i > 0; i--) { op; } } \ case 4: op; \ case 3: op; \ case 2: op; \ 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) { TIFFPredictorState* sp = PredictorState(tif); u_int stride = sp->stride; char* cp = (char*) cp0; if (cc > stride) { cc -= stride; /* * Pipeline the most common cases. */ if (stride == 3) { u_int cr = cp[0]; u_int cg = cp[1]; u_int cb = cp[2]; do { cc -= 3, cp += 3; cp[0] = (cr += cp[0]); cp[1] = (cg += cp[1]); cp[2] = (cb += cp[2]); } while ((int32) cc > 0); } else if (stride == 4) { u_int cr = cp[0]; u_int cg = cp[1]; u_int cb = cp[2]; u_int ca = cp[3]; do { cc -= 4, cp += 4; cp[0] = (cr += cp[0]); cp[1] = (cg += cp[1]); cp[2] = (cb += cp[2]); cp[3] = (ca += cp[3]); } while ((int32) cc > 0); } else { do { XREPEAT4(stride, cp[stride] += *cp; cp++) cc -= stride; } while ((int32) cc > 0); } } } static void swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); u_int stride = sp->stride; uint16* wp = (uint16*) cp0; tsize_t wc = cc / 2; if (wc > stride) { TIFFSwabArrayOfShort(wp, wc); wc -= stride; do { REPEAT4(stride, wp[stride] += wp[0]; wp++) wc -= stride; } while ((int32) wc > 0); } } static void horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) { u_int stride = PredictorState(tif)->stride; uint16* wp = (uint16*) cp0; tsize_t wc = cc / 2; if (wc > stride) { wc -= stride; do { REPEAT4(stride, wp[stride] += wp[0]; wp++) wc -= stride; } while ((int32) wc > 0); } } /* * Decode a scanline and apply the predictor routine. */ static int PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); assert(sp->coderow != NULL); assert(sp->pfunc != NULL); if ((*sp->coderow)(tif, op0, occ0, s)) { (*sp->pfunc)(tif, op0, occ0); return (1); } else return (0); } /* * Decode a tile/strip and apply the predictor routine. * Note that horizontal differencing must be done on a * row-by-row basis. The width of a "row" has already * been calculated at pre-decode time according to the * strip/tile dimensions. */ static int PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); assert(sp->codetile != NULL); if ((*sp->codetile)(tif, op0, occ0, s)) { tsize_t rowsize = sp->rowsize; assert(rowsize > 0); assert(sp->pfunc != NULL); while ((long)occ0 > 0) { (*sp->pfunc)(tif, op0, (tsize_t) rowsize); occ0 -= rowsize; op0 += rowsize; } return (1); } else return (0); } static void horDiff8(TIFF* tif, tidata_t cp0, tsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); u_int stride = sp->stride; char* cp = (char*) cp0; if (cc > stride) { cc -= stride; /* * Pipeline the most common cases. */ if (stride == 3) { int r1, g1, b1; int r2 = cp[0]; int g2 = cp[1]; int b2 = cp[2]; do { r1 = cp[3]; cp[3] = r1-r2; r2 = r1; g1 = cp[4]; cp[4] = g1-g2; g2 = g1; b1 = cp[5]; cp[5] = b1-b2; b2 = b1; cp += 3; } while ((int32)(cc -= 3) > 0); } else if (stride == 4) { int r1, g1, b1, a1; int r2 = cp[0]; int g2 = cp[1]; int b2 = cp[2]; int a2 = cp[3]; do { r1 = cp[4]; cp[4] = r1-r2; r2 = r1; g1 = cp[5]; cp[5] = g1-g2; g2 = g1; b1 = cp[6]; cp[6] = b1-b2; b2 = b1; a1 = cp[7]; cp[7] = a1-a2; a2 = a1; cp += 4; } while ((int32)(cc -= 4) > 0); } else { cp += cc - 1; do { REPEAT4(stride, cp[stride] -= cp[0]; cp--) } while ((int32)(cc -= stride) > 0); } } } static void horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); u_int stride = sp->stride; int16 *wp = (int16*) cp0; tsize_t wc = cc/2; if (wc > stride) { wc -= stride; wp += wc - 1; do { REPEAT4(stride, wp[stride] -= wp[0]; wp--) wc -= stride; } while ((int32) wc > 0); } } static int PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { TIFFPredictorState *sp = PredictorState(tif); assert(sp != NULL); assert(sp->pfunc != NULL); assert(sp->coderow != NULL); /* XXX horizontal differencing alters user's data XXX */ (*sp->pfunc)(tif, bp, cc); return ((*sp->coderow)(tif, bp, cc, s)); } static int PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) { TIFFPredictorState *sp = PredictorState(tif); tsize_t cc = cc0, rowsize; u_char* bp = bp0; assert(sp != NULL); assert(sp->pfunc != NULL); assert(sp->codetile != NULL); rowsize = sp->rowsize; assert(rowsize > 0); while ((long)cc > 0) { (*sp->pfunc)(tif, bp, (tsize_t) rowsize); cc -= rowsize; bp += rowsize; } return ((*sp->codetile)(tif, bp0, cc0, s)); } #define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ static const TIFFFieldInfo predictFieldInfo[] = { { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR, FALSE, FALSE, "Predictor" }, }; #define N(a) (sizeof (a) / sizeof (a[0])) static int PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); switch (tag) { case TIFFTAG_PREDICTOR: sp->predictor = (uint16) va_arg(ap, int); TIFFSetFieldBit(tif, FIELD_PREDICTOR); break; default: return (*sp->vsetparent)(tif, tag, ap); } tif->tif_flags |= TIFF_DIRTYDIRECT; return (1); } static int PredictorVGetField(TIFF* tif, ttag_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); switch (tag) { case TIFFTAG_PREDICTOR: *va_arg(ap, uint16*) = sp->predictor; break; default: return (*sp->vgetparent)(tif, tag, ap); } return (1); } static void PredictorPrintDir(TIFF* tif, FILE* fd, long flags) { TIFFPredictorState* sp = PredictorState(tif); (void) flags; if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { fprintf(fd, " Predictor: "); switch (sp->predictor) { case 1: fprintf(fd, "none "); break; case 2: fprintf(fd, "horizontal differencing "); break; } fprintf(fd, "%u (0x%x)\n", sp->predictor, sp->predictor); } if (sp->printdir) (*sp->printdir)(tif, fd, flags); } int TIFFPredictorInit(TIFF* tif) { TIFFPredictorState* sp = PredictorState(tif); /* * Merge codec-specific tag information and * override parent get/set field methods. */ _TIFFMergeFieldInfo(tif, predictFieldInfo, N(predictFieldInfo)); sp->vgetparent = tif->tif_vgetfield; tif->tif_vgetfield = PredictorVGetField;/* hook for predictor tag */ sp->vsetparent = tif->tif_vsetfield; tif->tif_vsetfield = PredictorVSetField;/* hook for predictor tag */ sp->printdir = tif->tif_printdir; tif->tif_printdir = PredictorPrintDir; /* hook for predictor tag */ sp->setupdecode = tif->tif_setupdecode; tif->tif_setupdecode = PredictorSetupDecode; sp->setupencode = tif->tif_setupencode; tif->tif_setupencode = PredictorSetupEncode; sp->predictor = 1; /* default value */ sp->pfunc = NULL; /* no predictor routine */ return (1); } r predictor tag */ sp->vsetparent = tif->tif_vsetfield; tif->tif_vsetfield = PredictorVSetField;/* hook for predictor tag */ sp->printdir = tif->tif_printdir; tif->tif_printdir = Pretiff-v3.4beta018/libtiff/tif_print.c000444 004341 000024 00000035373 06003062751 017144 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_print.c,v 1.64 1995/07/19 00:39:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Directory Printing Support */ #include "tiffiop.h" #include #include static const char *photoNames[] = { "min-is-white", /* PHOTOMETRIC_MINISWHITE */ "min-is-black", /* PHOTOMETRIC_MINISBLACK */ "RGB color", /* PHOTOMETRIC_RGB */ "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ "transparency mask", /* PHOTOMETRIC_MASK */ "separated", /* PHOTOMETRIC_SEPARATED */ "YCbCr", /* PHOTOMETRIC_YCBCR */ "7 (0x7)", "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ }; #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) static const char *orientNames[] = { "0 (0x0)", "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ }; #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) /* * Print the contents of the current directory * to the specified stdio file stream. */ void TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) { register TIFFDirectory *td; char *sep; uint16 i; long l, n; fprintf(fd, "TIFF Directory at offset 0x%x\n", tif->tif_diroff); td = &tif->tif_dir; if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { fprintf(fd, "%sreduced-resolution image", sep); sep = "/"; } if (td->td_subfiletype & FILETYPE_PAGE) { fprintf(fd, "%smulti-page document", sep); sep = "/"; } if (td->td_subfiletype & FILETYPE_MASK) fprintf(fd, "%stransparency mask", sep); fprintf(fd, " (%u = 0x%x)\n", td->td_subfiletype, td->td_subfiletype); } if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { fprintf(fd, " Image Width: %lu Image Length: %lu", (u_long) td->td_imagewidth, (u_long) td->td_imagelength); if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) fprintf(fd, " Image Depth: %lu", (u_long) td->td_imagedepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { fprintf(fd, " Tile Width: %lu Tile Length: %lu", (u_long) td->td_tilewidth, (u_long) td->td_tilelength); if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) fprintf(fd, " Tile Depth: %lu", (u_long) td->td_tiledepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { fprintf(fd, " Resolution: %g, %g", td->td_xresolution, td->td_yresolution); if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { switch (td->td_resolutionunit) { case RESUNIT_NONE: fprintf(fd, " (unitless)"); break; case RESUNIT_INCH: fprintf(fd, " pixels/inch"); break; case RESUNIT_CENTIMETER: fprintf(fd, " pixels/cm"); break; default: fprintf(fd, " (unit %u = 0x%x)", td->td_resolutionunit, td->td_resolutionunit); break; } } fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_POSITION)) fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { fprintf(fd, " Sample Format: "); switch (td->td_sampleformat) { case SAMPLEFORMAT_VOID: fprintf(fd, "void\n"); break; case SAMPLEFORMAT_INT: fprintf(fd, "signed integer\n"); break; case SAMPLEFORMAT_UINT: fprintf(fd, "unsigned integer\n"); break; case SAMPLEFORMAT_IEEEFP: fprintf(fd, "IEEE floating point\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_sampleformat, td->td_sampleformat); break; } } if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { fprintf(fd, " Compression Scheme: "); switch (td->td_compression) { case COMPRESSION_NONE: fprintf(fd, "none\n"); break; case COMPRESSION_CCITTRLE: fprintf(fd, "CCITT modified Huffman encoding\n"); break; case COMPRESSION_CCITTFAX3: fprintf(fd, "CCITT Group 3 facsimile encoding\n"); break; case COMPRESSION_CCITTFAX4: fprintf(fd, "CCITT Group 4 facsimile encoding\n"); break; case COMPRESSION_CCITTRLEW: fprintf(fd, "CCITT modified Huffman encoding %s\n", "w/ word alignment"); break; case COMPRESSION_PACKBITS: fprintf(fd, "Macintosh PackBits encoding\n"); break; case COMPRESSION_THUNDERSCAN: fprintf(fd, "ThunderScan 4-bit encoding\n"); break; case COMPRESSION_LZW: fprintf(fd, "Lempel-Ziv & Welch encoding\n"); break; case COMPRESSION_NEXT: fprintf(fd, "NeXT 2-bit encoding\n"); break; case COMPRESSION_OJPEG: fprintf(fd, "Old-style JPEG encoding\n"); break; case COMPRESSION_JPEG: fprintf(fd, "JPEG encoding\n"); break; case COMPRESSION_JBIG: fprintf(fd, "JBIG encoding\n"); break; case COMPRESSION_DEFLATE: fprintf(fd, "Deflate encoding (experimental)\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_compression, td->td_compression); break; } } if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { 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); } if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); sep = ""; for (i = 0; i < td->td_extrasamples; i++) { switch (td->td_sampleinfo[i]) { case EXTRASAMPLE_UNSPECIFIED: fprintf(fd, "%sunspecified", sep); break; case EXTRASAMPLE_ASSOCALPHA: fprintf(fd, "%sassoc-alpha", sep); break; case EXTRASAMPLE_UNASSALPHA: fprintf(fd, "%sunassoc-alpha", sep); break; default: fprintf(fd, "%s%u (0x%x)", sep, td->td_sampleinfo[i], td->td_sampleinfo[i]); break; } sep = ", "; } fprintf(fd, ">\n"); } #ifdef CMYK_SUPPORT if (TIFFFieldSet(tif,FIELD_INKSET)) { fprintf(fd, " Ink Set: "); switch (td->td_inkset) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_inkset, td->td_inkset); break; } } if (TIFFFieldSet(tif,FIELD_INKNAMES)) { char* cp; fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; for (cp = td->td_inknames; i > 0; cp = strchr(cp, '\0')) { fprintf(fd, "%s", sep); _TIFFprintAscii(fd, cp); sep = ", "; } } if (TIFFFieldSet(tif,FIELD_DOTRANGE)) fprintf(fd, " Dot Range: %u-%u\n", td->td_dotrange[0], td->td_dotrange[1]); if (TIFFFieldSet(tif,FIELD_TARGETPRINTER)) _TIFFprintAsciiTag(fd, "Target Printer", td->td_targetprinter); #endif if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { fprintf(fd, " Thresholding: "); switch (td->td_threshholding) { case THRESHHOLD_BILEVEL: fprintf(fd, "bilevel art scan\n"); break; case THRESHHOLD_HALFTONE: fprintf(fd, "halftone or dithered scan\n"); break; case THRESHHOLD_ERRORDIFFUSE: fprintf(fd, "error diffused\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_threshholding, td->td_threshholding); break; } } if (TIFFFieldSet(tif,FIELD_FILLORDER)) { fprintf(fd, " FillOrder: "); switch (td->td_fillorder) { case FILLORDER_MSB2LSB: fprintf(fd, "msb-to-lsb\n"); break; case FILLORDER_LSB2MSB: fprintf(fd, "lsb-to-msb\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_fillorder, td->td_fillorder); break; } } #ifdef YCBCR_SUPPORT if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) fprintf(fd, " YCbCr Subsampling: %u, %u\n", td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { fprintf(fd, " YCbCr Positioning: "); switch (td->td_ycbcrpositioning) { case YCBCRPOSITION_CENTERED: fprintf(fd, "centered\n"); break; case YCBCRPOSITION_COSITED: fprintf(fd, "cosited\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_ycbcrpositioning, td->td_ycbcrpositioning); break; } } if (TIFFFieldSet(tif,FIELD_YCBCRCOEFFICIENTS)) fprintf(fd, " YCbCr Coefficients: %g, %g, %g\n", td->td_ycbcrcoeffs[0], td->td_ycbcrcoeffs[1], td->td_ycbcrcoeffs[2]); #endif if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) fprintf(fd, " Halftone Hints: light %u dark %u\n", td->td_halftonehints[0], td->td_halftonehints[1]); if (TIFFFieldSet(tif,FIELD_ARTIST)) _TIFFprintAsciiTag(fd, "Artist", td->td_artist); if (TIFFFieldSet(tif,FIELD_DATETIME)) _TIFFprintAsciiTag(fd, "Date & Time", td->td_datetime); if (TIFFFieldSet(tif,FIELD_HOSTCOMPUTER)) _TIFFprintAsciiTag(fd, "Host Computer", td->td_hostcomputer); if (TIFFFieldSet(tif,FIELD_SOFTWARE)) _TIFFprintAsciiTag(fd, "Software", td->td_software); if (TIFFFieldSet(tif,FIELD_DOCUMENTNAME)) _TIFFprintAsciiTag(fd, "Document Name", td->td_documentname); if (TIFFFieldSet(tif,FIELD_IMAGEDESCRIPTION)) _TIFFprintAsciiTag(fd, "Image Description", td->td_imagedescription); if (TIFFFieldSet(tif,FIELD_MAKE)) _TIFFprintAsciiTag(fd, "Make", td->td_make); if (TIFFFieldSet(tif,FIELD_MODEL)) _TIFFprintAsciiTag(fd, "Model", td->td_model); if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { fprintf(fd, " Orientation: "); if (td->td_orientation < NORIENTNAMES) fprintf(fd, "%s\n", orientNames[td->td_orientation]); else fprintf(fd, "%u (0x%x)\n", td->td_orientation, td->td_orientation); } if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { fprintf(fd, " Rows/Strip: "); if (td->td_rowsperstrip == (uint32) -1) fprintf(fd, "(infinite)\n"); else fprintf(fd, "%lu\n", (u_long) td->td_rowsperstrip); } if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) fprintf(fd, " SMin Sample Value: %g\n", td->td_sminsamplevalue); if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) fprintf(fd, " SMax Sample Value: %g\n", td->td_smaxsamplevalue); if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { fprintf(fd, " Planar Configuration: "); switch (td->td_planarconfig) { case PLANARCONFIG_CONTIG: fprintf(fd, "single image plane\n"); break; case PLANARCONFIG_SEPARATE: fprintf(fd, "separate image planes\n"); break; default: fprintf(fd, "%u (0x%x)\n", td->td_planarconfig, td->td_planarconfig); break; } } if (TIFFFieldSet(tif,FIELD_PAGENAME)) _TIFFprintAsciiTag(fd, "Page Name", td->td_pagename); if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) fprintf(fd, " Page Number: %u-%u\n", td->td_pagenumber[0], td->td_pagenumber[1]); if (TIFFFieldSet(tif,FIELD_COLORMAP)) { fprintf(fd, " Color Map: "); if (flags & TIFFPRINT_COLORMAP) { fprintf(fd, "\n"); n = 1L<td_bitspersample; for (l = 0; l < n; l++) fprintf(fd, " %5lu: %5u %5u %5u\n", l, td->td_colormap[0][l], td->td_colormap[1][l], td->td_colormap[2][l]); } else fprintf(fd, "(present)\n"); } #ifdef COLORIMETRY_SUPPORT if (TIFFFieldSet(tif,FIELD_WHITEPOINT)) fprintf(fd, " White Point: %g-%g\n", td->td_whitepoint[0], td->td_whitepoint[1]); if (TIFFFieldSet(tif,FIELD_PRIMARYCHROMAS)) fprintf(fd, " Primary Chromaticities: %g,%g %g,%g %g,%g\n", td->td_primarychromas[0], td->td_primarychromas[1], td->td_primarychromas[2], td->td_primarychromas[3], td->td_primarychromas[4], td->td_primarychromas[5]); if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) { fprintf(fd, " Reference Black/White:\n"); for (i = 0; i < td->td_samplesperpixel; i++) fprintf(fd, " %2d: %5g %5g\n", i, td->td_refblackwhite[2*i+0], td->td_refblackwhite[2*i+1]); } if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { fprintf(fd, " Transfer Function: "); if (flags & TIFFPRINT_CURVES) { fprintf(fd, "\n"); n = 1L<td_bitspersample; for (l = 0; l < n; l++) { fprintf(fd, " %2lu: %5u", l, td->td_transferfunction[0][l]); for (i = 1; i < td->td_samplesperpixel; i++) fprintf(fd, " %5u", td->td_transferfunction[i][l]); fputc('\n', fd); } } else fprintf(fd, "(present)\n"); } #endif #if SUBIFD_SUPPORT if (TIFFFieldSet(tif, FIELD_SUBIFD)) { fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) fprintf(fd, " %5u", td->td_subifd[i]); fputc('\n', fd); } #endif if (tif->tif_printdir) (*tif->tif_printdir)(tif, fd, flags); if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { tstrip_t s; fprintf(fd, " %u %s:\n", td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) fprintf(fd, " %3lu: [%8lu, %8lu]\n", (u_long) s, (u_long) td->td_stripoffset[s], (u_long) td->td_stripbytecount[s]); } } void _TIFFprintAscii(FILE* fd, const char* cp) { for (; *cp != '\0'; cp++) { const char* tp; if (isprint(*cp)) { fputc(*cp, fd); continue; } for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) if (*tp++ == *cp) break; if (*tp) fprintf(fd, "\\%c", *tp); else fprintf(fd, "\\%03o", *cp & 0xff); } } void _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) { fprintf(fd, " %s: \"", name); _TIFFprintAscii(fd, value); fprintf(fd, "\"\n"); } td->td_stripbytecount[s]); } } void _TIFFprintAscii(FILE* fd, const char* cp) { for (; *cp != '\0'; cp++) { const char* tp; if (isprint(*cp)) { fputc(*cp, fd); continue; } for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) if (*tp++ == *cp) breaktiff-v3.4beta018/libtiff/tif_read.c000444 004341 000024 00000041407 06003062751 016716 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_read.c,v 1.69 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * Scanline-oriented Read Support */ #include "tiffiop.h" #include #include static int TIFFFillStrip(TIFF*, tstrip_t); static int TIFFFillTile(TIFF*, ttile_t); static int TIFFStartStrip(TIFF*, tstrip_t); static int TIFFStartTile(TIFF*, ttile_t); static int TIFFCheckRead(TIFF*, int); #define NOSTRIP ((tstrip_t) -1) /* undefined state */ #define NOTILE ((ttile_t) -1) /* undefined state */ /* * Seek to a random row+sample in a file. */ static int TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) { register TIFFDirectory *td = &tif->tif_dir; tstrip_t strip; if (row >= td->td_imagelength) { /* out of range */ TIFFError(tif->tif_name, "%lu: Row out of range, max %lu", (u_long) row, (u_long) td->td_imagelength); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%lu: Sample out of range, max %lu", (u_long) sample, (u_long) td->td_samplesperpixel); return (0); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; if (strip != tif->tif_curstrip) { /* different strip, refill */ if (!TIFFFillStrip(tif, strip)) return (0); } else if (row < tif->tif_row) { /* * Moving backwards within the same strip: backup * to the start and then decode forward (below). * * NB: If you're planning on lots of random access within a * strip, it's better to just read and decode the entire * strip, and then access the decoded data in a random fashion. */ if (!TIFFStartStrip(tif, strip)) return (0); } if (row != tif->tif_row) { /* * Seek forward to the desired row. */ if (!(*tif->tif_seek)(tif, row - tif->tif_row)) return (0); tif->tif_row = row; } return (1); } int TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) { int e; if (!TIFFCheckRead(tif, 0)) return (-1); if (e = TIFFSeek(tif, row, sample)) { /* * Decompress desired row into user buffer. */ e = (*tif->tif_decoderow) (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); tif->tif_row++; if (e) (*tif->tif_postdecode)(tif, (tidata_t) buf, tif->tif_scanlinesize); } return (e ? 1 : -1); } /* * Read a strip of data and decompress the specified * amount into the user-supplied buffer. */ tsize_t TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) { TIFFDirectory *td = &tif->tif_dir; uint32 nrows; tsize_t stripsize; if (!TIFFCheckRead(tif, 0)) return (-1); if (strip >= td->td_nstrips) { TIFFError(tif->tif_name, "%ld: Strip out of range, max %ld", (long) strip, (long) td->td_nstrips); return (-1); } /* * Calculate the strip size according to the number of * rows in the strip (check for truncated last strip). */ if (strip != td->td_nstrips-1 || (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) nrows = td->td_rowsperstrip; stripsize = TIFFVStripSize(tif, nrows); if (size == (tsize_t) -1) size = stripsize; else if (size > stripsize) size = stripsize; if (TIFFFillStrip(tif, strip) && (*tif->tif_decodestrip)(tif, (tidata_t) buf, size, (tsample_t)(strip / td->td_stripsperimage))) { (*tif->tif_postdecode)(tif, (tidata_t) buf, size); return (size); } else return ((tsize_t) -1); } static tsize_t TIFFReadRawStrip1(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size, const char* module) { TIFFDirectory *td = &tif->tif_dir; if (!isMapped(tif)) { if (!SeekOK(tif, td->td_stripoffset[strip])) { TIFFError(module, "%s: Seek error at scanline %lu, strip %lu", tif->tif_name, (u_long) tif->tif_row, (u_long) strip); return (-1); } if (!ReadOK(tif, buf, size)) { TIFFError(module, "%s: Read error at scanline %lu", tif->tif_name, (u_long) tif->tif_row); return (-1); } } else { if (td->td_stripoffset[strip] + size > tif->tif_size) { TIFFError(module, "%s: Seek error at scanline %lu, strip %lu", tif->tif_name, (u_long) tif->tif_row, (u_long) strip); return (-1); } _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[strip], size); } return (size); } /* * Read a strip of data from the file. */ tsize_t TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) { static const char module[] = "TIFFReadRawStrip"; TIFFDirectory *td = &tif->tif_dir; tsize_t bytecount; if (!TIFFCheckRead(tif, 0)) return ((tsize_t) -1); if (strip >= td->td_nstrips) { TIFFError(tif->tif_name, "%lu: Strip out of range, max %lu", (u_long) strip, (u_long) td->td_nstrips); return ((tsize_t) -1); } bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { TIFFError(tif->tif_name, "%lu: Invalid strip byte count, strip %lu", (u_long) bytecount, (u_long) strip); return ((tsize_t) -1); } if (size != (tsize_t)-1 && size < bytecount) bytecount = size; return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); } /* * Read the specified strip and setup for decoding. * The data buffer is expanded, as necessary, to * hold the strip's data. */ static int TIFFFillStrip(TIFF* tif, tstrip_t strip) { static const char module[] = "TIFFFillStrip"; TIFFDirectory *td = &tif->tif_dir; tsize_t bytecount; bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { TIFFError(tif->tif_name, "%lu: Invalid strip byte count, strip %lu", (u_long) bytecount, (u_long) strip); return (0); } if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) || (tif->tif_flags & TIFF_NOBITREV))) { /* * The image is mapped into memory and we either don't * need to flip bits or the compression routine is going * to handle this operation itself. In this case, avoid * copying the raw data and instead just reference the * data from the memory mapped file image. This assumes * that the decompression routines do not modify the * contents of the raw data buffer (if they try to, * the application will get a fault since the file is * mapped read-only). */ if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) _TIFFfree(tif->tif_rawdata); tif->tif_flags &= ~TIFF_MYBUFFER; if (td->td_stripoffset[strip] + bytecount > tif->tif_size) { /* * This error message might seem strange, but it's * what would happen if a read were done instead. */ TIFFError(module, "%s: Read error on strip %lu", tif->tif_name, (u_long) strip); tif->tif_curstrip = NOSTRIP; return (0); } tif->tif_rawdatasize = bytecount; tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip]; } else { /* * Expand raw data buffer, if needed, to * hold data strip coming from file * (perhaps should set upper bound on * the size of a buffer we'll use?). */ if (bytecount > tif->tif_rawdatasize) { tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFError(module, "%s: Data buffer too small to hold strip %lu", tif->tif_name, (u_long) strip); return (0); } if (!TIFFReadBufferSetup(tif, 0, TIFFroundup(bytecount, 1024))) return (0); } if (TIFFReadRawStrip1(tif, strip, (u_char *)tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits(tif->tif_rawdata, bytecount); } return (TIFFStartStrip(tif, strip)); } /* * Tile-oriented Read Support * Contributed by Nancy Cam (Silicon Graphics). */ /* * Read and decompress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ tsize_t TIFFReadTile(TIFF* tif, tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return (-1); return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); } /* * Read a tile of data and decompress the specified * amount into the user-supplied buffer. */ tsize_t TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) { TIFFDirectory *td = &tif->tif_dir; tsize_t tilesize = tif->tif_tilesize; if (!TIFFCheckRead(tif, 1)) return (-1); if (tile >= td->td_nstrips) { TIFFError(tif->tif_name, "%ld: Tile out of range, max %ld", (long) tile, (u_long) td->td_nstrips); return (-1); } if (size == (tsize_t) -1) size = tilesize; else if (size > tilesize) size = tilesize; if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { (*tif->tif_postdecode)(tif, (tidata_t) buf, size); return (size); } else return (-1); } static tsize_t TIFFReadRawTile1(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size, const char* module) { TIFFDirectory *td = &tif->tif_dir; if (!isMapped(tif)) { if (!SeekOK(tif, td->td_stripoffset[tile])) { TIFFError(module, "%s: Seek error at row %ld, col %ld, tile %ld", tif->tif_name, (long) tif->tif_row, (long) tif->tif_col, (long) tile); return ((tsize_t) -1); } if (!ReadOK(tif, buf, size)) { TIFFError(module, "%s: Read error at row %ld, col %ld", tif->tif_name, (long) tif->tif_row, (long) tif->tif_col); return ((tsize_t) -1); } } else { if (td->td_stripoffset[tile] + size > tif->tif_size) { TIFFError(module, "%s: Seek error at row %ld, col %ld, tile %ld", tif->tif_name, (long) tif->tif_row, (long) tif->tif_col, (long) tile); return ((tsize_t) -1); } _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); } return (size); } /* * Read a tile of data from the file. */ tsize_t TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) { static const char module[] = "TIFFReadRawTile"; TIFFDirectory *td = &tif->tif_dir; tsize_t bytecount; if (!TIFFCheckRead(tif, 1)) return ((tsize_t) -1); if (tile >= td->td_nstrips) { TIFFError(tif->tif_name, "%lu: Tile out of range, max %lu", (u_long) tile, (u_long) td->td_nstrips); return ((tsize_t) -1); } bytecount = td->td_stripbytecount[tile]; if (size != (tsize_t) -1 && size < bytecount) bytecount = size; return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); } /* * Read the specified tile and setup for decoding. * The data buffer is expanded, as necessary, to * hold the tile's data. */ static int TIFFFillTile(TIFF* tif, ttile_t tile) { static const char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; tsize_t bytecount; bytecount = td->td_stripbytecount[tile]; if (bytecount <= 0) { TIFFError(tif->tif_name, "%lu: Invalid tile byte count, tile %lu", (u_long) bytecount, (u_long) tile); return (0); } if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) || (tif->tif_flags & TIFF_NOBITREV))) { /* * The image is mapped into memory and we either don't * need to flip bits or the compression routine is going * to handle this operation itself. In this case, avoid * copying the raw data and instead just reference the * data from the memory mapped file image. This assumes * that the decompression routines do not modify the * contents of the raw data buffer (if they try to, * the application will get a fault since the file is * mapped read-only). */ if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) _TIFFfree(tif->tif_rawdata); tif->tif_flags &= ~TIFF_MYBUFFER; if (td->td_stripoffset[tile] + bytecount > tif->tif_size) { tif->tif_curtile = NOTILE; return (0); } tif->tif_rawdatasize = bytecount; tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile]; } else { /* * Expand raw data buffer, if needed, to * hold data tile coming from file * (perhaps should set upper bound on * the size of a buffer we'll use?). */ if (bytecount > tif->tif_rawdatasize) { tif->tif_curtile = NOTILE; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFError(module, "%s: Data buffer too small to hold tile %ld", tif->tif_name, (long) tile); return (0); } if (!TIFFReadBufferSetup(tif, 0, TIFFroundup(bytecount, 1024))) return (0); } if (TIFFReadRawTile1(tif, tile, (u_char *)tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits(tif->tif_rawdata, bytecount); } return (TIFFStartTile(tif, tile)); } /* * Setup the raw data buffer in preparation for * reading a strip of raw data. If the buffer * is specified as zero, then a buffer of appropriate * size is allocated by the library. Otherwise, * the client must guarantee that the buffer is * large enough to hold any individual strip of * raw data. */ int TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) { static const char module[] = "TIFFReadBufferSetup"; if (tif->tif_rawdata) { if (tif->tif_flags & TIFF_MYBUFFER) _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; } if (bp) { tif->tif_rawdatasize = size; tif->tif_rawdata = (tidata_t) bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { tif->tif_rawdatasize = TIFFroundup(size, 1024); tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } if (tif->tif_rawdata == NULL) { TIFFError(module, "%s: No space for data buffer at scanline %ld", tif->tif_name, (long) tif->tif_row); tif->tif_rawdatasize = 0; return (0); } return (1); } /* * Set state to appear as if a * strip has just been read in. */ static int TIFFStartStrip(TIFF* tif, tstrip_t strip) { TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) return (0); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; tif->tif_rawcp = tif->tif_rawdata; tif->tif_rawcc = td->td_stripbytecount[strip]; return ((*tif->tif_predecode)(tif, (tsample_t)(strip / td->td_stripsperimage))); } /* * Set state to appear as if a * tile has just been read in. */ static int TIFFStartTile(TIFF* tif, ttile_t tile) { TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) return (0); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_curtile = tile; tif->tif_row = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * td->td_tilelength; tif->tif_col = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * td->td_tilewidth; tif->tif_rawcp = tif->tif_rawdata; tif->tif_rawcc = td->td_stripbytecount[tile]; return ((*tif->tif_predecode)(tif, (tsample_t)(tile/td->td_stripsperimage))); } static int TIFFCheckRead(TIFF* tif, int tiles) { if (tif->tif_mode == O_WRONLY) { TIFFError(tif->tif_name, "File not open for reading"); return (0); } if (tiles ^ isTiled(tif)) { TIFFError(tif->tif_name, tiles ? "Can not read tiles from a stripped image" : "Can not read scanlines from a tiled image"); return (0); } return (1); } void _TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) { (void) tif; (void) buf; (void) cc; } void _TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) { (void) tif; assert((cc & 1) == 0); TIFFSwabArrayOfShort((uint16*) buf, cc/2); } void _TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) { (void) tif; assert((cc & 3) == 0); TIFFSwabArrayOfLong((uint32*) buf, cc/4); } void _TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) { (void) tif; assert((cc & 7) == 0); TIFFSwabArrayOfDouble((double*) buf, cc/8); } { (void) tif; (void) buf; (void) cc; } void _TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) { (void) tif; assert((cc & 1) == 0); TIFFSwabArrayOfShort((uint16*) buf, cc/2); } void _TIFFSwab32BitData(TIFF* tif, tidata_t buf,tiff-v3.4beta018/libtiff/tif_strip.c000444 004341 000024 00000013010 06003062752 017132 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_strip.c,v 1.23 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Strip-organized Image Support Routines. */ #include "tiffiop.h" /* * Compute which strip a (row,sample) value is in. */ tstrip_t TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) { TIFFDirectory *td = &tif->tif_dir; tstrip_t strip; strip = row / td->td_rowsperstrip; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%u: Sample out of range, max %u", sample, td->td_samplesperpixel); return ((tstrip_t) 0); } strip += sample*td->td_stripsperimage; } return (strip); } /* * Compute how many strips are in an image. */ tstrip_t TIFFNumberOfStrips(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; tstrip_t nstrips; nstrips = (td->td_rowsperstrip == (uint32) -1 ? (td->td_imagelength != 0 ? 1 : 0) : TIFFhowmany(td->td_imagelength, td->td_rowsperstrip)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) nstrips *= td->td_samplesperpixel; return (nstrips); } /* * Compute the # bytes in a variable height, row-aligned strip. */ tsize_t TIFFVStripSize(TIFF* tif, uint32 nrows) { TIFFDirectory *td = &tif->tif_dir; if (nrows == (uint32) -1) nrows = td->td_imagelength; #ifdef YCBCR_SUPPORT if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_photometric == PHOTOMETRIC_YCBCR && !isUpSampled(tif)) { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. * Must also roundup width and height when calculating * since images that are not a multiple of the * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ tsize_t w = TIFFroundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); tsize_t scanline = TIFFhowmany(w*td->td_bitspersample, 8); tsize_t samplingarea = td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ return ((tsize_t) (nrows*scanline + 2*(nrows*scanline / samplingarea))); } else #endif return ((tsize_t)(nrows * TIFFScanlineSize(tif))); } /* * Compute the # bytes in a (row-aligned) strip. * * Note that if RowsPerStrip is larger than the * recorded ImageLength, then the strip size is * truncated to reflect the actual space required * to hold the strip. */ tsize_t TIFFStripSize(TIFF* tif) { TIFFDirectory* td = &tif->tif_dir; uint32 rps = td->td_rowsperstrip; if (rps > td->td_imagelength) rps = td->td_imagelength; return (TIFFVStripSize(tif, rps)); } /* * Compute a default strip size based on the image * characteristics and a requested value. If the * request is <1 then we choose a strip size according * to certain heuristics. */ uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request) { return (*tif->tif_defstripsize)(tif, request); } uint32 _TIFFDefaultStripSize(TIFF* tif, uint32 s) { if ((int32) s < 1) { /* * If RowsPerStrip is unspecified, try to break the * image up into strips that are approximately 8Kbytes. */ tsize_t scanline = TIFFScanlineSize(tif); s = (uint32)(8*1024) / (scanline == 0 ? 1 : scanline); } return (s); } /* * Return the number of bytes to read/write in a call to * one of the scanline-oriented i/o routines. Note that * this number may be 1/samples-per-pixel if data is * stored as separate planes. */ tsize_t TIFFScanlineSize(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; tsize_t scanline; scanline = td->td_bitspersample * td->td_imagewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) scanline *= td->td_samplesperpixel; return ((tsize_t) TIFFhowmany(scanline, 8)); } /* * Return the number of bytes required to store a complete * decoded and packed raster scanline (as opposed to the * I/O size returned by TIFFScanlineSize which may be less * if data is store as separate planes). */ tsize_t TIFFRasterScanlineSize(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; tsize_t scanline; scanline = td->td_bitspersample * td->td_imagewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) { scanline *= td->td_samplesperpixel; return ((tsize_t) TIFFhowmany(scanline, 8)); } else return ((tsize_t) TIFFhowmany(scanline, 8)*td->td_samplesperpixel); } er scanline (as opposed to the * I/O size returned by TIFFScanlineSize which may be less * if data is store as separate planes). */ tsize_t TIFFRasterScanlineSize(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; tsize_t scanline; scanline = td->td_bitspersample * td->td_imagewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) { scanline *= td->td_samplesperpixel; return ((tsize_t) TIFFhowmany(scanline, 8)); } else return ((tsize_t) TIFFhowmany(scanline, 8)*td->td_samplesperpitiff-v3.4beta018/libtiff/tif_swab.c000444 004341 000024 00000016064 06003062752 016741 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_swab.c,v 1.21 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 Bit & Byte Swapping Support. * * XXX We assume short = 16-bits and long = 32-bits XXX */ #include "tiffiop.h" #ifndef TIFFSwabShort void TIFFSwabShort(uint16* wp) { register u_char* cp = (u_char*) wp; int t; t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif #ifndef TIFFSwabLong void TIFFSwabLong(uint32* lp) { register u_char* cp = (u_char*) lp; int t; t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } #endif #ifndef TIFFSwabArrayOfShort void TIFFSwabArrayOfShort(uint16* wp, register u_long n) { register u_char* cp; register int t; /* XXX unroll loop some */ while (n-- > 0) { cp = (u_char*) wp; t = cp[1]; cp[1] = cp[0]; cp[0] = t; wp++; } } #endif #ifndef TIFFSwabArrayOfLong void TIFFSwabArrayOfLong(register uint32* lp, register u_long n) { register unsigned char *cp; register int t; /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; lp++; } } #endif #ifndef TIFFSwabDouble void TIFFSwabDouble(double *dp) { register uint32* lp = (uint32*) dp; uint32 t; TIFFSwabArrayOfLong(lp, 2); t = lp[0]; lp[0] = lp[1]; lp[1] = t; } #endif #ifndef TIFFSwabArrayOfDouble void TIFFSwabArrayOfDouble(double* dp, register u_long n) { register uint32* lp = (uint32*) dp; register uint32 t; TIFFSwabArrayOfLong(lp, n + n); while (n-- > 0) { t = lp[0]; lp[0] = lp[1]; lp[1] = t; lp += 2; } } #endif /* * Bit reversal tables. TIFFBitRevTable[] gives * the bit reversed value of . Used in various * places in the library when the FillOrder requires * bit reversal of byte values (e.g. CCITT Fax 3 * encoding/decoding). TIFFNoBitRevTable is provided * for algorithms that want an equivalent table that * do not reverse bit values. */ static const unsigned char TIFFBitRevTable[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff }; static const unsigned char TIFFNoBitRevTable[256] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; const unsigned char* TIFFGetBitRevTable(int reversed) { return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); } void TIFFReverseBits(register u_char* cp, register u_long n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; cp[1] = TIFFBitRevTable[cp[1]]; cp[2] = TIFFBitRevTable[cp[2]]; cp[3] = TIFFBitRevTable[cp[3]]; cp[4] = TIFFBitRevTable[cp[4]]; cp[5] = TIFFBitRevTable[cp[5]]; cp[6] = TIFFBitRevTable[cp[6]]; cp[7] = TIFFBitRevTable[cp[7]]; cp += 8; } while (n-- > 0) *cp = TIFFBitRevTable[*cp], cp++; } Table(int reversed) { return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); } void TIFFReverseBits(register u_char* cp, register u_long n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; cp[1] = TIFFBitRevTable[cp[1]]; cp[2] = TIFFBitRevTable[cp[2]]; cp[3] = TIFFBitRevTable[cp[3]]; cp[4] = TIFFBitRevTable[cp[4]]; cp[5] = TIFFBitRevTable[cp[5]]; cp[6] = TIFFBitRevTable[cp[6]]; cp[7] = TIFFBitRevTable[cp[7]]; cp += 8; } whtiff-v3.4beta018/libtiff/tif_thunder.c000444 004341 000024 00000011342 06003062753 017451 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_thunder.c,v 1.28 1995/06/30 15:29:02 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" #ifdef THUNDER_SUPPORT /* * TIFF Library. * * ThunderScan 4-bit Compression Algorithm Support */ /* * ThunderScan uses an encoding scheme designed for * 4-bit pixel values. Data is encoded in bytes, with * each byte split into a 2-bit code word and a 6-bit * data value. The encoding gives raw data, runs of * pixels, or pixel values encoded as a delta from the * previous pixel value. For the latter, either 2-bit * or 3-bit delta values are used, with the deltas packed * into a single byte. */ #define THUNDER_DATA 0x3f /* mask for 6-bit data */ #define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ /* code values */ #define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ #define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ #define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ #define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ #define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ #define THUNDER_RAW 0xc0 /* raw data encoded */ static const int twobitdeltas[4] = { 0, 1, 0, -1 }; static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; #define SETPIXEL(op, v) { \ lastpixel = (v) & 0xf; \ if (npixels++ & 1) \ *op++ |= lastpixel; \ else \ op[0] = lastpixel << 4; \ } static int ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) { register u_char *bp; register tsize_t cc; u_int lastpixel; tsize_t npixels; bp = (u_char *)tif->tif_rawcp; cc = tif->tif_rawcc; lastpixel = 0; npixels = 0; while (cc > 0 && npixels < maxpixels) { int n, delta; n = *bp++, cc--; switch (n & THUNDER_CODE) { case THUNDER_RUN: /* pixel run */ /* * Replicate the last pixel n times, * where n is the lower-order 6 bits. */ if (npixels & 1) { op[0] |= lastpixel; lastpixel = *op++; npixels++; n--; } else lastpixel |= lastpixel << 4; npixels += n; for (; n > 0; n -= 2) *op++ = lastpixel; if (n == -1) *--op &= 0xf0; lastpixel &= 0xf; break; case THUNDER_2BITDELTAS: /* 2-bit deltas */ if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); if ((delta = (n & 3)) != DELTA2_SKIP) SETPIXEL(op, lastpixel + twobitdeltas[delta]); break; case THUNDER_3BITDELTAS: /* 3-bit deltas */ if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) SETPIXEL(op, lastpixel + threebitdeltas[delta]); if ((delta = (n & 7)) != DELTA3_SKIP) SETPIXEL(op, lastpixel + threebitdeltas[delta]); break; case THUNDER_RAW: /* raw data */ SETPIXEL(op, n); break; } } tif->tif_rawcp = (tidata_t) bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { TIFFError(tif->tif_name, "ThunderDecode: %s data at scanline %ld (%lu != %lu)", npixels < maxpixels ? "Not enough" : "Too much", (long) tif->tif_row, (long) npixels, (long) maxpixels); return (0); } return (1); } static int ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { tidata_t row = buf; (void) s; while ((long)occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); occ -= tif->tif_scanlinesize; row += tif->tif_scanlinesize; } return (1); } int TIFFInitThunderScan(TIFF* tif, int scheme) { (void) scheme; tif->tif_decoderow = ThunderDecodeRow; tif->tif_decodestrip = ThunderDecodeRow; return (1); } #endif /* THUNDER_SUPPORT */ 0); } return (1); } static int ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) { tidata_t row = buf; (void) s; while ((long)occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); occ -= tif->tif_scanlinesize; row += tif->titiff-v3.4beta018/libtiff/tif_tile.c000444 004341 000024 00000013677 06003062753 016752 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_tile.c,v 1.24 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Tiled Image Support Routines. */ #include "tiffiop.h" /* * Compute which tile an (x,y,z,s) value is in. */ ttile_t TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; ttile_t tile = 1; if (td->td_imagedepth == 1) z = 0; if (dx == (uint32) -1) dx = td->td_imagewidth; if (dy == (uint32) -1) dy = td->td_imagelength; if (dz == (uint32) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); uint32 ypt = TIFFhowmany(td->td_imagelength, dy); uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx; else tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx + s; } return (tile); } /* * Check an (x,y,z,s) coordinate * against the image bounds. */ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) { TIFFDirectory *td = &tif->tif_dir; if (x >= td->td_imagewidth) { TIFFError(tif->tif_name, "Col %ld out of range, max %lu", (long) x, (u_long) td->td_imagewidth); return (0); } if (y >= td->td_imagelength) { TIFFError(tif->tif_name, "Row %ld out of range, max %lu", (long) y, (u_long) td->td_imagelength); return (0); } if (z >= td->td_imagedepth) { TIFFError(tif->tif_name, "Depth %ld out of range, max %lu", (long) z, (u_long) td->td_imagedepth); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "Sample %d out of range, max %u", (int) s, td->td_samplesperpixel); return (0); } return (1); } /* * Compute how many tiles are in an image. */ ttile_t TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; ttile_t ntiles; if (dx == (uint32) -1) dx = td->td_imagewidth; if (dy == (uint32) -1) dy = td->td_imagelength; if (dz == (uint32) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : (TIFFhowmany(td->td_imagewidth, dx) * TIFFhowmany(td->td_imagelength, dy) * TIFFhowmany(td->td_imagedepth, dz)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) ntiles *= td->td_samplesperpixel; return (ntiles); } /* * Compute the # bytes in each row of a tile. */ tsize_t TIFFTileRowSize(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; tsize_t rowsize; if (td->td_tilelength == 0 || td->td_tilewidth == 0) return ((tsize_t) 0); rowsize = td->td_bitspersample * td->td_tilewidth; if (td->td_planarconfig == PLANARCONFIG_CONTIG) rowsize *= td->td_samplesperpixel; return ((tsize_t) TIFFhowmany(rowsize, 8)); } /* * Compute the # bytes in a variable length, row-aligned tile. */ tsize_t TIFFVTileSize(TIFF* tif, uint32 nrows) { TIFFDirectory *td = &tif->tif_dir; tsize_t tilesize; if (td->td_tilelength == 0 || td->td_tilewidth == 0 || td->td_tiledepth == 0) return ((tsize_t) 0); #ifdef YCBCR_SUPPORT if (td->td_planarconfig == PLANARCONFIG_CONTIG && td->td_photometric == PHOTOMETRIC_YCBCR && !isUpSampled(tif)) { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. * Must also roundup width and height when calculating * since images that are not a multiple of the * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ tsize_t w = TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); tsize_t rowsize = TIFFhowmany(w*td->td_bitspersample, 8); tsize_t samplingarea = td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ tilesize = nrows*rowsize + 2*(nrows*rowsize / samplingarea); } else #endif tilesize = nrows * TIFFTileRowSize(tif); return ((tsize_t)(tilesize * td->td_tiledepth)); } /* * Compute the # bytes in a row-aligned tile. */ tsize_t TIFFTileSize(TIFF* tif) { return (TIFFVTileSize(tif, tif->tif_dir.td_tilelength)); } /* * Compute a default tile size based on the image * characteristics and a requested value. If a * request is <1 then we choose a size according * to certain heuristics. */ void TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { (*tif->tif_deftilesize)(tif, tw, th); } void _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { (void) tif; if (*(int32*) tw < 1) *tw = 256; if (*(int32*) th < 1) *th = 256; } ize(TIFF* tif) { return (TIFFVTileSize(tif, tif->tif_dir.td_tiletiff-v3.4beta018/libtiff/tif_unix.c000444 004341 000024 00000011104 06003062754 016760 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_unix.c,v 1.15 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 UNIX-specific Routines. */ #include "tiffiop.h" #include #include #include static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { return ((tsize_t) read((int) fd, buf, (size_t) size)); } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return ((tsize_t) write((int) fd, buf, (size_t) size)); } static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { return ((toff_t) lseek((int) fd, (off_t) off, whence)); } static int _tiffCloseProc(thandle_t fd) { return (close((int) fd)); } #include static toff_t _tiffSizeProc(thandle_t fd) { #ifdef _AM29K long fsize; return ((fsize = lseek((int) fd, 0, SEEK_END)) < 0 ? 0 : fsize); #else struct stat sb; return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); #endif } #ifdef HAVE_MMAP #include static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { toff_t size = _tiffSizeProc(fd); if (size != (toff_t) -1) { *pbase = (tdata_t) mmap(0, size, PROT_READ, MAP_SHARED, (int) fd, 0); if (*pbase != (tdata_t) -1) { *psize = size; return (1); } } return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { (void) fd; (void) munmap(base, (off_t) size); } #else /* !HAVE_MMAP */ static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { (void) fd; (void) pbase; (void) psize; return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { (void) fd; (void) base; (void) size; } #endif /* !HAVE_MMAP */ /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (thandle_t) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m, fd; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); #ifdef _AM29K fd = open(name, m); #else fd = open(name, m, 0666); #endif if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF *)0); } return (TIFFFdOpen(fd, name, mode)); } void* _TIFFmalloc(tsize_t s) { return (malloc((size_t) s)); } void _TIFFfree(tdata_t p) { free(p); } void* _TIFFrealloc(tdata_t p, tsize_t s) { return (realloc(p, (size_t) s)); } void _TIFFmemset(tdata_t p, int v, tsize_t c) { memset(p, v, (size_t) c); } void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) { memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { return (memcmp(p1, p2, (size_t) c)); } static void unixWarningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; static void unixErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; rningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; static void unixErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stdertiff-v3.4beta018/libtiff/tif_version.c000444 004341 000024 00000002665 06003062754 017476 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_version.c,v 1.15 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1992-1995 Sam Leffler * Copyright (c) 1992-1995 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. */ #include "tiffiop.h" #include "version.h" static const char TIFFVersion[] = VERSION; const char* TIFFGetVersion(void) { return (TIFFVersion); } LER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT tiff-v3.4beta018/libtiff/tif_vms.c000444 004341 000024 00000032344 06003062755 016614 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_vms.c,v 1.19 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 VMS-specific Routines. */ #include #include #include "tiffiop.h" #if !HAVE_IEEEFP #include #endif #ifdef VAXC #define NOSHARE noshare #else #define NOSHARE #endif #ifdef __alpha /* Dummy entry point for backwards compatibility */ void TIFFModeCCITTFax3(void){} #endif static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { return (read((int) fd, buf, size)); } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return (write((int) fd, buf, size)); } static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { return ((toff_t) lseek((int) fd, (off_t) off, whence)); } static int _tiffCloseProc(thandle_t fd) { return (close((int) fd)); } #include static toff_t _tiffSizeProc(thandle_t fd) { struct stat sb; return (toff_t) (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); } #ifdef HAVE_MMAP #include #include #include /* * Table for storing information on current open sections. * (Should really be a linked list) */ #define MAX_MAPPED 100 static int no_mapped = 0; static struct { char *base; char *top; unsigned short channel; } map_table[MAX_MAPPED]; /* * This routine maps a file into a private section. Note that this * method of accessing a file is by far the fastest under VMS. * The routine may fail (i.e. return 0) for several reasons, for * example: * - There is no more room for storing the info on sections. * - The process is out of open file quota, channels, ... * - fd does not describe an opened file. * - The file is already opened for write access by this process * or another process * - There is no free "hole" in virtual memory that fits the * size of the file */ static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { char name[256]; struct FAB fab; unsigned short channel; char *inadr[2], *retadr[2]; unsigned long status; long size; if (no_mapped >= MAX_MAPPED) return(0); /* * We cannot use a file descriptor, we * must open the file once more. */ if (getname((int)fd, name, 1) == NULL) return(0); /* prepare the FAB for a user file open */ fab = cc$rms_fab; fab.fab$l_fop |= FAB$V_UFO; fab.fab$b_fac = FAB$M_GET; fab.fab$b_shr = FAB$M_SHRGET; fab.fab$l_fna = name; fab.fab$b_fns = strlen(name); status = sys$open(&fab); /* open file & get channel number */ if ((status&1) == 0) return(0); channel = (unsigned short)fab.fab$l_stv; inadr[0] = inadr[1] = (char *)0; /* just an address in P0 space */ /* * Map the blocks of the file up to * the EOF block into virtual memory. */ size = _tiffSizeProc(fd); status = sys$crmpsc(inadr, retadr, 0, SEC$M_EXPREG, 0,0,0, channel, TIFFhowmany(size,512), 0,0,0); if ((status&1) == 0){ sys$dassgn(channel); return(0); } *pbase = (tdata_t) retadr[0]; /* starting virtual address */ /* * Use the size of the file up to the * EOF mark for UNIX compatibility. */ *psize = (toff_t) size; /* Record the section in the table */ map_table[no_mapped].base = retadr[0]; map_table[no_mapped].top = retadr[1]; map_table[no_mapped].channel = channel; no_mapped++; return(1); } /* * This routine unmaps a section from the virtual address space of * the process, but only if the base was the one returned from a * call to TIFFMapFileContents. */ static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { char *inadr[2]; int i, j; /* Find the section in the table */ for (i = 0;i < no_mapped; i++) { if (map_table[i].base == (char *) base) { /* Unmap the section */ inadr[0] = (char *) base; inadr[1] = map_table[i].top; sys$deltva(inadr, 0, 0); sys$dassgn(map_table[i].channel); /* Remove this section from the list */ for (j = i+1; j < no_mapped; j++) map_table[j-1] = map_table[j]; no_mapped--; return; } } } #else /* !HAVE_MMAP */ static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { } #endif /* !HAVE_MMAP */ /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (thandle_t) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m, fd; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); if (m&O_TRUNC){ /* * There is a bug in open in VAXC. If you use * open w/ m=O_RDWR|O_CREAT|O_TRUNC the * wrong thing happens. On the other hand * creat does the right thing. */ fd = creat((char *) /* bug in stdio.h */ name, 0666, "alq = 128", "deq = 64", "mbc = 32", "fop = tef"); } else if (m&O_RDWR) { fd = open(name, m, 0666, "deq = 64", "mbc = 32", "fop = tef", "ctx = stm"); } else fd = open(name, m, 0666, "mbc = 32", "ctx = stm"); if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF*)0); } return (TIFFFdOpen(fd, name, mode)); } tdata_t _TIFFmalloc(tsize_t s) { return (malloc((size_t) s)); } void _TIFFfree(tdata_t p) { free(p); } tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { return (realloc(p, (size_t) s)); } void _TIFFmemset(tdata_t p, int v, tsize_t c) { memset(p, v, (size_t) c); } void _TIFFmemcpy(tdata_t d, const void* s, tsize_t c) { memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) { return (memcmp(p1, p2, (size_t) c)); } /* * On the VAX, we need to make those global, writable pointers * non-shareable, otherwise they would be made shareable by default. * On the AXP, this brain damage has been corrected. * * I (Karsten Spang, krs@kampsax.dk) have dug around in the GCC * manual and the GAS code and have come up with the following * construct, but I don't have GCC on my VAX, so it is untested. * Please tell me if it does not work. */ static void vmsWarningHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); fprintf(stderr, "Warning, "); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } NOSHARE TIFFErrorHandler _TIFFwarningHandler = vmsWarningHandler #if defined(VAX) && defined(__GNUC__) asm("_$$PsectAttributes_NOSHR$$_TIFFwarningHandler") #endif ; static void vmsErrorHandler(const char* module, const char* fmt, va_list ap) { if (module != NULL) fprintf(stderr, "%s: ", module); vfprintf(stderr, fmt, ap); fprintf(stderr, ".\n"); } NOSHARE TIFFErrorHandler _TIFFerrorHandler = vmsErrorHandler #if defined(VAX) && defined(__GNUC__) asm("_$$PsectAttributes_NOSHR$$_TIFFerrorHandler") #endif ; #if !HAVE_IEEEFP /* IEEE floting point handling */ typedef struct ieeedouble { u_long mant : 20, exp : 11, sign : 1; u_long mant2; } ieeedouble; typedef struct ieeefloat { u_long mant : 23, exp : 8, sign : 1; } ieeefloat; typedef struct { u_long mant1 : 7, exp : 8, sign : 1, mant2 : 16, mant3 : 16, mant4 : 16; } nativedouble; typedef struct { u_long mant1 : 7, exp : 8, sign : 1, mant2 : 16; } nativefloat; typedef union { ieeedouble ieee; nativedouble native; char b[8]; uint32 l[2]; double d; } double_t; typedef union { ieeefloat ieee; nativefloat native; char b[4]; uint32 l; float f; } float_t; #if defined(VAXC) || defined(DECC) #pragma inline(ieeetod,dtoieee) #endif /* * Convert an IEEE double precision number to native double precision. * The source is contained in two longwords, the second holding the sign, * exponent and the higher order bits of the mantissa, and the first * holding the rest of the mantissa as follows: * (Note: It is assumed that the number has been eight-byte swapped to * LSB first.) * * First longword: * 32 least significant bits of mantissa * Second longword: * 0-19: 20 most significant bits of mantissa * 20-30: exponent * 31: sign * The exponent is stored as excess 1023. * The most significant bit of the mantissa is implied 1, and not stored. * If the exponent and mantissa are zero, the number is zero. * If the exponent is 0 (i.e. -1023) and the mantissa is non-zero, it is an * unnormalized number with the most significant bit NOT implied. * If the exponent is 2047, the number is invalid, in case the mantissa is zero, * this means overflow (+/- depending of the sign bit), otherwise * it simply means invalid number. * * If the number is too large for the machine or was specified as overflow, * +/-HUGE_VAL is returned. */ INLINE static void ieeetod(double *dp) { double_t source; long sign,exp,mant; double dmant; source.d = *dp; sign = source.ieee.sign; exp = source.ieee.exp; mant = source.ieee.mant; if (exp == 2047) { if (mant) /* Not a Number (NAN) */ *dp = HUGE_VAL; else /* +/- infinity */ *dp = (sign ? -HUGE_VAL : HUGE_VAL); return; } if (!exp) { if (!(mant || source.ieee.mant2)) { /* zero */ *dp=0; return; } else { /* Unnormalized number */ /* NB: not -1023, the 1 bit is not implied */ exp= -1022; } } else { mant |= 1<<20; exp -= 1023; } dmant = (((double) mant) + ((double) source.ieee.mant2) / (((double) (1<<16)) * ((double) (1<<16)))) / (double) (1<<20); dmant = ldexp(dmant, exp); if (sign) dmant= -dmant; *dp = dmant; } INLINE static void dtoieee(double *dp) { double_t num; double x; int exp; num.d = *dp; if (!num.d) { /* Zero is just binary all zeros */ num.l[0] = num.l[1] = 0; return; } if (num.d < 0) { /* Sign is encoded separately */ num.d = -num.d; num.ieee.sign = 1; } else { num.ieee.sign = 0; } /* Now separate the absolute value into mantissa and exponent */ x = frexp(num.d, &exp); /* * Handle cases where the value is outside the * range for IEEE floating point numbers. * (Overflow cannot happen on a VAX, but underflow * can happen for G float.) */ if (exp < -1022) { /* Unnormalized number */ x = ldexp(x, -1023-exp); exp = 0; } else if (exp > 1023) { /* +/- infinity */ x = 0; exp = 2047; } else { /* Get rid of most significant bit */ x *= 2; x -= 1; exp += 1023; } num.ieee.exp = exp; x *= (double) (1<<20); num.ieee.mant = (long) x; x -= (double) num.ieee.mant; num.ieee.mant2 = (long) (x*((double) (1<<16)*(double) (1<<16))); if (!(num.ieee.mant || num.ieee.exp || num.ieee.mant2)) { /* Avoid negative zero */ num.ieee.sign = 0; } *dp = num.d; } /* * Beware, these do not handle over/under-flow * during conversion from ieee to native format. */ #define NATIVE2IEEEFLOAT(fp) { \ float_t t; \ if (t.ieee.exp = (fp)->native.exp) \ t.ieee.exp += -129 + 127; \ t.ieee.sign = (fp)->native.sign; \ t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ *(fp) = t; \ } #define IEEEFLOAT2NATIVE(fp) { \ float_t t; int v = (fp)->ieee.exp; \ if (v) v += -127 + 129; /* alter bias of exponent */\ t.native.exp = v; /* implicit truncation of exponent */\ t.native.sign = (fp)->ieee.sign; \ v = (fp)->ieee.mant; \ t.native.mant1 = v >> 16; \ t.native.mant2 = v;\ *(fp) = t; \ } #define IEEEDOUBLE2NATIVE(dp) ieeetod(dp) #define NATIVE2IEEEDOUBLE(dp) dtoieee(dp) /* * These unions are used during floating point * conversions. The above macros define the * conversion operations. */ void TIFFCvtIEEEFloatToNative(TIFF* tif, u_int n, float* f) { float_t* fp = (float_t*) f; while (n-- > 0) { IEEEFLOAT2NATIVE(fp); fp++; } } void TIFFCvtNativeToIEEEFloat(TIFF* tif, u_int n, float* f) { float_t* fp = (float_t*) f; while (n-- > 0) { NATIVE2IEEEFLOAT(fp); fp++; } } void TIFFCvtIEEEDoubleToNative(TIFF* tif, u_int n, float* f) { float_t* fp = (float_t*) f; while (n-- > 0) { IEEEDOUBLE2NATIVE(fp); fp++; } } void TIFFCvtNativeToIEEEDouble(TIFF* tif, u_int n, float* f) { float_t* fp = (float_t*) f; while (n-- > 0) { NATIVE2IEEEDOUBLE(fp); fp++; } } #endif while (n-- > 0) { IEEEFLOAT2NATIVE(fp); fp++; } } void TIFFCvtNativeToIEEEFloat(TIFF* tif, u_int n, float* f) { float_t* fp = (float_t*) f; while (n-- > 0) { NATIVE2IEEEFLOAT(fp); fp++; } } void TIFFCvtIEEEDoubleToNative(TIFF* tif, u_int n, float* f) { float_t* fp = (ftiff-v3.4beta018/libtiff/tif_warning.c000444 004341 000024 00000003260 06003062755 017447 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_warning.c,v 1.20 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include "tiffiop.h" TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler) { TIFFErrorHandler prev = _TIFFwarningHandler; _TIFFwarningHandler = handler; return (prev); } void TIFFWarning(const char* module, const char* fmt, ...) { if (_TIFFwarningHandler) { va_list ap; va_start(ap, fmt); (*_TIFFwarningHandler)(module, fmt, ap); va_end(ap); } } ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. */ #include "tiffiop.h" TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler) { TIFFErrorHandler prev = _TIFFwarningHandler; _TIFFwarningHandler = handler; return (prev); } void TIFFWtiff-v3.4beta018/libtiff/tif_win3.c000444 004341 000024 00000012541 06003062756 016665 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_win3.c,v 1.5 1995/06/06 23:49:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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 Windows 3.x-specific Routines. */ #include "tiffiop.h" #if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER) #include /* for open, close, etc. function prototypes */ #endif #include #include #include static tsize_t _tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) { return (_hread(fd, buf, size)); } static tsize_t _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { return (_hwrite(fd, buf, size)); } static toff_t _tiffSeekProc(thandle_t fd, toff_t off, int whence) { return (_llseek(fd, (off_t) off, whence)); } static int _tiffCloseProc(thandle_t fd) { return (_lclose(fd)); } #include static toff_t _tiffSizeProc(thandle_t fd) { struct stat sb; return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size); } static int _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) { return (0); } static void _tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) { } /* * Open a TIFF file descriptor for read/writing. */ TIFF* TIFFFdOpen(int fd, const char* name, const char* mode) { TIFF* tif; tif = TIFFClientOpen(name, mode, (void*) fd, _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); if (tif) tif->tif_fd = fd; return (tif); } /* * Open a TIFF file for read/writing. */ TIFF* TIFFOpen(const char* name, const char* mode) { static const char module[] = "TIFFOpen"; int m, fd; OFSTRUCT of; int mm = 0; m = _TIFFgetMode(mode, module); if (m == -1) return ((TIFF*)0); if (m & O_CREAT) { if ((m & O_TRUNC) || OpenFile(name, &of, OF_EXIST) != HFILE_ERROR) mm |= OF_CREATE; } if (m & O_WRONLY) mm |= OF_WRITE; if (m & O_RDWR) mm |= OF_READWRITE; fd = OpenFile(name, &of, mm); if (fd < 0) { TIFFError(module, "%s: Cannot open", name); return ((TIFF*)0); } return (TIFFFdOpen(fd, name, mode)); } tdata_t _TIFFmalloc(tsize_t s) { return (tdata_t) GlobalAllocPtr(GHND, (DWORD) s); } void _TIFFfree(tdata_t p) { GlobalFreePtr(p); } tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { return (tdata_t) GlobalReAllocPtr(p, (DWORD) s, GHND); } void _TIFFmemset(tdata_t p, int v, tsize_t c) { char* pp = (char*) p; while (c > 0) { tsize_t chunk = 0x10000 - ((uint32) pp & 0xffff);/* What's left in segment */ if (chunk > 0xff00) /* No more than 0xff00 */ chunk = 0xff00; if (chunk > c) /* No more than needed */ chunk = c; memset(pp, v, chunk); pp = (char*) (chunk + (char huge*) pp); c -= chunk; } } void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) { if (c > 0xFFFF) hmemcpy((void _huge*) d, (void _huge*) s, c); else (void) memcpy(d, s, (size_t) c); } int _TIFFmemcmp(const tdata_t d, const tdata_t s, tsize_t c) { char* dd = (char*) d; char* ss = (char*) s; tsize_t chunks, chunkd, chunk; int result; while (c > 0) { chunks = 0x10000 - ((uint32) ss & 0xffff); /* What's left in segment */ chunkd = 0x10000 - ((uint32) dd & 0xffff); /* What's left in segment */ chunk = c; /* Get the largest of */ if (chunk > chunks) /* c, chunks, chunkd, */ chunk = chunks; /* 0xff00 */ if (chunk > chunkd) chunk = chunkd; if (chunk > 0xff00) chunk = 0xff00; result = memcmp(dd, ss, chunk); if (result != 0) return (result); dd = (char*) (chunk + (char huge*) dd); ss = (char*) (chunk + (char huge*) ss); c -= chunk; } return (0); } static void win3WarningHandler(const char* module, const char* fmt, va_list ap) { char e[512] = { '\0' }; if (module != NULL) strcat(strcpy(e, module), ":"); vsprintf(e+strlen(e), fmt, ap); strcat(e, "."); MessageBox(GetActiveWindow(), e, "LibTIFF Warning", MB_OK|MB_ICONEXCLAMATION); } TIFFErrorHandler _TIFFwarningHandler = win3WarningHandler; static void win3ErrorHandler(const char* module, const char* fmt, va_list ap) { char e[512] = { '\0' }; if (module != NULL) strcat(strcpy(e, module), ":"); vsprintf(e+strlen(e), fmt, ap); strcat(e, "."); MessageBox(GetActiveWindow(), e, "LibTIFF Error", MB_OK|MB_ICONSTOP); } TIFFErrorHandler _TIFFerrorHandler = win3ErrorHandler; fmt, ap); strcat(e, "."); MessageBox(GetActiveWindow(), e, "LibTIFF Warning", MB_OK|MB_ICONEXCLAMATION); } TIFFErrorHandler _TIFFwarningHandler = win3Watiff-v3.4beta018/libtiff/tif_write.c000444 004341 000024 00000043550 06003062756 017143 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_write.c,v 1.70 1995/07/18 17:55:31 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. * * Scanline-oriented Write Support */ #include "tiffiop.h" #include #include #define STRIPINCR 20 /* expansion factor on strip array */ #define WRITECHECKSTRIPS(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) #define WRITECHECKTILES(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) #define BUFFERCHECK(tif) \ (((tif)->tif_flags & TIFF_BUFFERSETUP) || \ TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1)) static int TIFFWriteCheck(TIFF*, int, const char*); static int TIFFGrowStrips(TIFF*, int, const char*); static int TIFFAppendToStrip(TIFF*, tstrip_t, tidata_t, tsize_t); static int TIFFSetupStrips(TIFF*); int TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; tstrip_t strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); /* * Handle delayed allocation of data buffer. This * permits it to be sized more intelligently (using * directory information). */ if (!BUFFERCHECK(tif)) return (-1); td = &tif->tif_dir; /* * Extend image length if needed * (but only for PlanarConfig=1). */ if (row >= td->td_imagelength) { /* extend image */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { TIFFError(tif->tif_name, "Can not change \"ImageLength\" when using separate planes"); return (-1); } td->td_imagelength = row+1; imagegrew = 1; } /* * Calculate strip and check for crossings. */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFError(tif->tif_name, "%d: Sample out of range, max %d", sample, td->td_samplesperpixel); return (-1); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; if (strip != tif->tif_curstrip) { /* * Changing strips -- flush any data present. */ if (!TIFFFlushData(tif)) return (-1); tif->tif_curstrip = strip; /* * Watch out for a growing image. The value of * strips/image will initially be 1 (since it * can't be deduced until the imagelength is known). */ if (strip >= td->td_stripsperimage && imagegrew) td->td_stripsperimage = TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) return (-1); tif->tif_flags |= TIFF_CODERSETUP; } if (!(*tif->tif_preencode)(tif, sample)) return (-1); tif->tif_flags |= TIFF_POSTENCODE; } /* * Check strip array to make sure there's space. * We don't support dynamically growing files that * have data organized in separate bitplanes because * it's too painful. In that case we require that * the imagelength be set properly before the first * write (so that the strips array will be fully * allocated above). */ if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) return (-1); /* * Ensure the write is either sequential or at the * beginning of a strip (or that we can randomly * access the data -- i.e. no encoding). */ if (row != tif->tif_row) { if (row < tif->tif_row) { /* * Moving backwards within the same strip: * backup to the start and then decode * forward (below). */ tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; tif->tif_rawcp = tif->tif_rawdata; } /* * Seek forward to the desired row. */ if (!(*tif->tif_seek)(tif, row - tif->tif_row)) return (-1); tif->tif_row = row; } status = (*tif->tif_encoderow)(tif, (tidata_t) buf, tif->tif_scanlinesize, sample); tif->tif_row++; return (status); } /* * Encode the supplied data and write it to the * specified strip. There must be space for the * data; we don't check if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ tsize_t TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; tsample_t sample; if (!WRITECHECKSTRIPS(tif, module)) return ((tsize_t) -1); if (strip >= td->td_nstrips) { TIFFError(module, "%s: Strip %lu out of range, max %lu", tif->tif_name, (u_long) strip, (u_long) td->td_nstrips); return ((tsize_t) -1); } /* * Handle delayed allocation of data buffer. This * permits it to be sized according to the directory * info. */ if (!BUFFERCHECK(tif)) return ((tsize_t) -1); tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) return ((tsize_t) -1); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_flags &= ~TIFF_POSTENCODE; sample = (tsample_t)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tsize_t) -1); if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample)) return ((tsize_t) 0); if (!(*tif->tif_postencode)(tif)) return (-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); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); } /* * Write the supplied data to the specified strip. * There must be space for the data; we don't check * if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ tsize_t TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) { static const char module[] = "TIFFWriteRawStrip"; if (!WRITECHECKSTRIPS(tif, module)) return ((tsize_t) -1); if (strip >= tif->tif_dir.td_nstrips) { TIFFError(module, "%s: Strip %lu out of range, max %lu", tif->tif_name, (u_long) strip, (u_long) tif->tif_dir.td_nstrips); return ((tsize_t) -1); } return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ? cc : (tsize_t) -1); } /* * Write and compress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ tsize_t TIFFWriteTile(TIFF* tif, tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) { if (!TIFFCheckTile(tif, x, y, z, s)) return (-1); /* * NB: A tile size of -1 is used instead of tif_tilesize knowing * that TIFFWriteEncodedTile will clamp this to the tile size. * This is done because the tile size may not be defined until * after the output buffer is setup in TIFFWriteBufferSetup. */ return (TIFFWriteEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); } /* * Encode the supplied data and write it to the * specified tile. There must be space for the * data. The function clamps individual writes * to a tile to the tile size, but does not (and * can not) check that multiple writes to the same * tile do not write more than tile size data. * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ tsize_t TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; tsample_t sample; if (!WRITECHECKTILES(tif, module)) return ((tsize_t) -1); td = &tif->tif_dir; if (tile >= td->td_nstrips) { TIFFError(module, "%s: Tile %lu out of range, max %lu", tif->tif_name, (u_long) tile, (u_long) td->td_nstrips); return ((tsize_t) -1); } /* * Handle delayed allocation of data buffer. This * permits it to be sized more intelligently (using * directory information). */ if (!BUFFERCHECK(tif)) return ((tsize_t) -1); tif->tif_curtile = tile; /* * Compute tiles per row & per column to compute * current row and column */ tif->tif_row = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * td->td_tilelength; tif->tif_col = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * td->td_tilewidth; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) return ((tsize_t) -1); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_flags &= ~TIFF_POSTENCODE; sample = (tsample_t)(tile/td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tsize_t) -1); /* * Clamp write amount to the tile size. This is mostly * done so that callers can pass in some large number * (e.g. -1) and have the tile size used instead. */ if ((uint32) cc > tif->tif_tilesize) cc = tif->tif_tilesize; if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) return ((tsize_t) 0); if (!(*tif->tif_postencode)(tif)) return ((tsize_t) -1); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc)) return ((tsize_t) -1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); } /* * Write the supplied data to the specified strip. * There must be space for the data; we don't check * if strips overlap! * * NB: Image length must be setup before writing; this * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ tsize_t TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) { static const char module[] = "TIFFWriteRawTile"; if (!WRITECHECKTILES(tif, module)) return ((tsize_t) -1); if (tile >= tif->tif_dir.td_nstrips) { TIFFError(module, "%s: Tile %lu out of range, max %lu", tif->tif_name, (u_long) tile, (u_long) tif->tif_dir.td_nstrips); return ((tsize_t) -1); } return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? cc : (tsize_t) -1); } #define isUnspecified(td, v) \ (td->v == (uint32) -1 || (td)->td_imagelength == 0) static int TIFFSetupStrips(TIFF* tif) { TIFFDirectory* td = &tif->tif_dir; if (isTiled(tif)) td->td_stripsperimage = isUnspecified(td, td_tilelength) ? td->td_samplesperpixel : TIFFNumberOfTiles(tif); else td->td_stripsperimage = isUnspecified(td, td_rowsperstrip) ? td->td_samplesperpixel : TIFFNumberOfStrips(tif); td->td_nstrips = td->td_stripsperimage; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; td->td_stripoffset = (uint32 *) _TIFFmalloc(td->td_nstrips * sizeof (uint32)); td->td_stripbytecount = (uint32 *) _TIFFmalloc(td->td_nstrips * sizeof (uint32)); if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) return (0); /* * Place data at the end-of-file * (by setting offsets to zero). */ _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); } #undef isUnspecified /* * Verify file is writable and that the directory * information is setup properly. In doing the latter * we also "freeze" the state of the directory so * that important information is not changed. */ static int TIFFWriteCheck(TIFF* tif, int tiles, const char* module) { if (tif->tif_mode == O_RDONLY) { TIFFError(module, "%s: File not open for writing", tif->tif_name); return (0); } if (tiles ^ isTiled(tif)) { TIFFError(tif->tif_name, tiles ? "Can not write tiles to a stripped image" : "Can not write scanlines to a tiled image"); return (0); } /* * On the first write verify all the required information * has been setup and initialize any data structures that * had to wait until directory information was set. * Note that a lot of our work is assumed to remain valid * because we disallow any of the important parameters * from changing after we start writing (i.e. once * TIFF_BEENWRITING is set, TIFFSetField will only allow * the image's length to be changed). */ if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { TIFFError(module, "%s: Must set \"ImageWidth\" before writing data", tif->tif_name); return (0); } if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { TIFFError(module, "%s: Must set \"PlanarConfiguration\" before writing data", tif->tif_name); return (0); } if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { tif->tif_dir.td_nstrips = 0; TIFFError(module, "%s: No space for %s arrays", tif->tif_name, isTiled(tif) ? "tile" : "strip"); return (0); } tif->tif_tilesize = TIFFTileSize(tif); tif->tif_scanlinesize = TIFFScanlineSize(tif); tif->tif_flags |= TIFF_BEENWRITING; return (1); } /* * Setup the raw data buffer used for encoding. */ int TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) { static const char module[] = "TIFFWriteBufferSetup"; if (tif->tif_rawdata) { if (tif->tif_flags & TIFF_MYBUFFER) { _TIFFfree(tif->tif_rawdata); tif->tif_flags &= ~TIFF_MYBUFFER; } tif->tif_rawdata = NULL; } if (size == (tsize_t) -1) { size = (isTiled(tif) ? tif->tif_tilesize : tif->tif_scanlinesize); /* * Make raw data buffer at least 8K */ if (size < 8*1024) size = 8*1024; bp = NULL; /* NB: force malloc */ } if (bp == NULL) { bp = _TIFFmalloc(size); if (bp == NULL) { TIFFError(module, "%s: No space for output buffer", tif->tif_name); return (0); } tif->tif_flags |= TIFF_MYBUFFER; } else tif->tif_flags &= ~TIFF_MYBUFFER; tif->tif_rawdata = (tidata_t) bp; tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; tif->tif_flags |= TIFF_BUFFERSETUP; return (1); } /* * Grow the strip data structures by delta strips. */ static int TIFFGrowStrips(TIFF* tif, int delta, const char* module) { TIFFDirectory *td = &tif->tif_dir; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); td->td_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, (td->td_nstrips + delta) * sizeof (uint32)); td->td_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, (td->td_nstrips + delta) * sizeof (uint32)); if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) { td->td_nstrips = 0; TIFFError(module, "%s: No space to expand strip arrays", tif->tif_name); return (0); } _TIFFmemset(td->td_stripoffset+td->td_nstrips, 0, delta*sizeof (uint32)); _TIFFmemset(td->td_stripbytecount+td->td_nstrips, 0, delta*sizeof (uint32)); td->td_nstrips += delta; return (1); } /* * Append the data to the specified strip. * * NB: We don't check that there's space in the * file (i.e. that strips do not overlap). */ static int TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) { TIFFDirectory *td = &tif->tif_dir; static const char module[] = "TIFFAppendToStrip"; if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { /* * No current offset, set the current strip. */ if (td->td_stripoffset[strip] != 0) { if (!SeekOK(tif, td->td_stripoffset[strip])) { TIFFError(module, "%s: Seek error at scanline %lu", tif->tif_name, (u_long) tif->tif_row); return (0); } } else td->td_stripoffset[strip] = TIFFSeekFile(tif, (toff_t) 0, SEEK_END); tif->tif_curoff = td->td_stripoffset[strip]; } if (!WriteOK(tif, data, cc)) { TIFFError(module, "%s: Write error at scanline %lu", tif->tif_name, (u_long) tif->tif_row); return (0); } tif->tif_curoff += cc; td->td_stripbytecount[strip] += cc; return (1); } /* * Internal version of TIFFFlushData that can be * called by ``encodestrip routines'' w/o concern * for infinite recursion. */ int TIFFFlushData1(TIFF* tif) { if (tif->tif_rawcc > 0) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits((u_char *)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, tif->tif_rawdata, tif->tif_rawcc)) return (0); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; } return (1); } /* * Set the current write offset. This should only be * used to set the offset to a known previous location * (very carefully), or to 0 so that the next write gets * appended to the end of the file. */ void TIFFSetWriteOffset(TIFF* tif, toff_t off) { tif->tif_curoff = off; } cc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, tif->tif_rawdata, tif->tif_rawcc)) return (0); tiff-v3.4beta018/libtiff/tif_zip.c000444 004341 000024 00000016646 06003062757 016622 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/libtiff/RCS/tif_zip.c,v 1.4 1995/07/17 14:38:12 sam Exp $ */ /* * Copyright (c) 1995 Sam Leffler * Copyright (c) 1995 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. */ #include "tiffiop.h" #ifdef ZIP_SUPPORT /* * TIFF Library. * * ZIP (i.e. Deflate) Compression Support * * This file is simply an interface to the libgz library written by * Jean-loup Gailly and Mark Adler. Use version 0.92 or later of * the library. The data format used by the zlib library is described * in the files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available * in the directory ftp://ftp.uu.net/pub/archiving/zip/doc. The library * was last found at ftp://ftp.uu.net/graphics/png/code/zlib-0.93.tar.gz. */ #include "tif_predict.h" #include "zlib.h" #include "zutil.h" #include #include /* * State block for each open TIFF * file using ZIP compression/decompression. */ typedef struct { TIFFPredictorState predict; z_stream stream; } ZIPState; #define DecoderState(tif) ((ZIPState*) (tif)->tif_data) #define EncoderState(tif) ((ZIPState*) (tif)->tif_data) static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); static int ZIPSetupDecode(TIFF* tif) { ZIPState* sp = DecoderState(tif); static char module[] = "ZIPSetupDecode"; assert(sp != NULL); if (inflateInit2(&sp->stream, -DEF_WBITS) != Z_OK) { TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); return (0); } else return (1); } /* * Setup state for decoding a strip. */ static int ZIPPreDecode(TIFF* tif, tsample_t s) { ZIPState* sp = DecoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_in = tif->tif_rawdata; sp->stream.avail_in = tif->tif_rawcc; return (inflateReset(&sp->stream) == Z_OK); } static int ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) { ZIPState* sp = DecoderState(tif); static char module[] = "ZIPDecode"; (void) s; assert(sp != NULL); sp->stream.next_out = op; sp->stream.avail_out = occ; do { int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); if (state == Z_STREAM_END) break; if (state == Z_DATA_ERROR) { TIFFError(module, "%s: Decoding error at scanline %d, %s", tif->tif_name, tif->tif_row, sp->stream.msg); if (inflateSync(&sp->stream) != Z_OK) return (0); continue; } if (state != Z_OK) { TIFFError(module, "%s: libgz error: %s", tif->tif_name, sp->stream.msg); return (0); } } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFError(module, "%s: Not enough data at scanline %d (short %d bytes)", tif->tif_name, tif->tif_row, sp->stream.avail_out); return (0); } return (1); } static int ZIPSetupEncode(TIFF* tif) { ZIPState* sp = EncoderState(tif); static char module[] = "ZIPSetupEncode"; assert(sp != NULL); /* * We use the undocumented feature of a negiatve window * bits to suppress writing the header in the output * stream. This is necessary when the resulting image * is made up of multiple strips or tiles as otherwise * libgz will not write a header for each strip/tile and * the decoder will fail. */ if (deflateInit2(&sp->stream, Z_DEFAULT_COMPRESSION, DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0) != Z_OK) { TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg); return (0); } else return (1); } /* * Reset encoding state at the start of a strip. */ static int ZIPPreEncode(TIFF* tif, tsample_t s) { ZIPState *sp = EncoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_out = tif->tif_rawdata; sp->stream.avail_out = tif->tif_rawdatasize; return (deflateReset(&sp->stream) == Z_OK); } /* * Encode a chunk of pixels. */ static int ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) { ZIPState *sp = EncoderState(tif); static char module[] = "ZIPEncode"; (void) s; sp->stream.next_in = bp; sp->stream.avail_in = cc; do { if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { TIFFError(module, "%s: Encoder error: %s", tif->tif_name, sp->stream.msg); return (0); } if (sp->stream.avail_out == 0) { tif->tif_rawcc = tif->tif_rawdatasize; TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; sp->stream.avail_out = tif->tif_rawdatasize; } } while (sp->stream.avail_in > 0); return (1); } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ static int ZIPPostEncode(TIFF* tif) { ZIPState *sp = EncoderState(tif); static char module[] = "ZIPPostEncode"; int state; sp->stream.avail_in = 0; do { state = deflate(&sp->stream, Z_FINISH); switch (state) { case Z_STREAM_END: case Z_OK: if (sp->stream.avail_out != tif->tif_rawdatasize) { tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out; TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; sp->stream.avail_out = tif->tif_rawdatasize; } break; default: TIFFError(module, "%s: libgz error: %s", tif->tif_name, sp->stream.msg); return (0); } } while (state != Z_STREAM_END); return (1); } static void ZIPCleanup(TIFF* tif) { ZIPState* sp = (ZIPState*) tif->tif_data; if (sp) { if (tif->tif_mode == O_RDONLY) inflateEnd(&sp->stream); else deflateEnd(&sp->stream); _TIFFfree(sp); tif->tif_data = NULL; } } int TIFFInitZIP(TIFF* tif, int scheme) { ZIPState* sp; assert(scheme == COMPRESSION_DEFLATE); /* * Allocate state block so tag methods have storage to record values. */ tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (ZIPState)); if (tif->tif_data == NULL) goto bad; sp = (ZIPState*) tif->tif_data; sp->stream.zalloc = NULL; sp->stream.zfree = NULL; sp->stream.opaque = NULL; sp->stream.data_type = Z_BINARY; /* * Install codec methods. */ tif->tif_setupdecode = ZIPSetupDecode; tif->tif_predecode = ZIPPreDecode; tif->tif_decoderow = ZIPDecode; tif->tif_decodestrip = ZIPDecode; tif->tif_decodetile = ZIPDecode; tif->tif_setupencode = ZIPSetupEncode; tif->tif_preencode = ZIPPreEncode; tif->tif_postencode = ZIPPostEncode; tif->tif_encoderow = ZIPEncode; tif->tif_encodestrip = ZIPEncode; tif->tif_encodetile = ZIPEncode; tif->tif_cleanup = ZIPCleanup; /* * Setup predictor setup. */ (void) TIFFPredictorInit(tif); return (1); bad: TIFFError("TIFFInitZIP", "No space for ZIP state block"); return (0); } #endif /* ZIP_SUPORT */ ZIPDecode; tif->tif_decodestrip = ZIPDecode; tif->tif_decodetile = ZIPDecode; tif->tif_tiff-v3.4beta018/port/Makefile.in000444 004341 000024 00000003643 06003062757 016415 0ustar00samuser000000 000000 #! smake # $Header: /usr/people/sam/tiff/port/RCS/Makefile.in,v 1.2 1995/05/24 01:54:38 sam Exp $ # # @WARNING@ # # Tag Image File Format Library # # Copyright (c) 1995 Sam Leffler # Copyright (c) 1995 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. # DEPTH = .. SRCDIR = ${DEPTH}/${TOPSRCDIR}/port VPATH = ../@SRCDIR@/port # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = CC = @CCOMPILER@ AR = @AR@ AROPTS = @AROPTS@ RANLIB = @RANLIB@ IPATH = -I. -I${DEPTH} -I${SRCDIR} COPTS = @GCOPTS@ OPTIMIZER=-O CFLAGS = @ENVOPTS@ ${COPTS} ${OPTIMIZER} ${IPATH} CFILES = @PORTFUNCS@ OBJECTS = ${CFILES:.c=.o} TARGETS = libport.a default all: ${TARGETS} libport.a: ${OBJECTS} @rm -f $@; ${AR} ${AROPTS} $@ ${OBJECTS} ${RANLIB} $@ ${PORT}/libport.a: libport.a install: default clean: rm -f ${TARGETS} ${OBJS} core a.out TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = CC = @CCOMPILER@ AR = @ARtiff-v3.4beta018/port/getopt.c000444 004341 000024 00000007277 06003062757 016025 0ustar00samuser000000 000000 /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getopt.c 4.13 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ #include #include /* * get option letter from argument vector */ int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ optopt; /* character checked for validity */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define EMSG "" int getopt(int nargc, char** nargv, char* ostr) { static char *place = EMSG; /* option letter processing */ register char *oli; /* option letter list index */ char *p; if (!*place) { /* update scanning pointer */ if (optind >= nargc || *(place = nargv[optind]) != '-') { place = EMSG; return(EOF); } if (place[1] && *++place == '-') { /* found "--" */ ++optind; place = EMSG; return(EOF); } } /* option letter okay? */ if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) { /* * if the user didn't specify '-' as an option, * assume it means EOF. */ if (optopt == (int)'-') return(EOF); if (!*place) ++optind; if (opterr) { if (!(p = strrchr(*nargv, '/'))) p = *nargv; else ++p; (void)fprintf(stderr, "%s: illegal option -- %c\n", p, optopt); } return(BADCH); } if (*++oli != ':') { /* don't need argument */ optarg = NULL; if (!*place) ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (!(p = strrchr(*nargv, '/'))) p = *nargv; else ++p; if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", p, optopt); return(BADCH); } else /* white space */ optarg = nargv[optind]; place = EMSG; ++optind; } return(optopt); /* dump back option letter */ } ++optind; } else { /* need an argument */ if (*place) /* no white space */ optarg = place; else if (nargc <= ++optind) { /* no arg */ place = EMSG; if (!(p = strrchr(*nargv, '/'))) p = *nargv; else ++p; if (opterr) (void)fprintf(stderr, "%s: option requires an argument tiff-v3.4beta018/port/install.sh.in000444 004341 000024 00000015037 06003062760 016751 0ustar00samuser000000 000000 #! @SCRIPT_SH@ # $Header: /usr/people/sam/tiff/port/RCS/install.sh.in,v 1.18 1995/04/17 23:52:02 sam Exp $ # # @WARNING@ # # HylaFAX Facsimile Software # # Copyright (c) 1990-1995 Sam Leffler # Copyright (c) 1991-1995 Silicon Graphics, Inc. # HylaFAX is a trademark of Silicon Graphics # # 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. # # # Warning, this file was automatically created by the HylaFAX configure script # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # # # Shell script to emulate Silicon Graphics install program. # We emulate the non-standard interface used by install so # that we can build SGI inst packages on SGI systems. Note # that we cannot emulate everything because we don't maintain # a history of installed software; thus we cannot tell when # configuration files have been modified and save old copies. # # NB: we don't do chown/chmod/chgrp by default; it must be # explicitly set on the command line. # # # install [options] files ... # # Options are: # # -o save existing target foo as OLDfoo # -O remove existing target foo, if it fails save as OLDfoo # -m mode set mode of installed target # -u uid set uid of installed target # -g gid set gid of installed target # -root path set ROOT directory for target pathnames # -dir create directories # -fifo create FIFO special files # -ln path create hard link # -lns path create symbolic link # -src path source pathname different from target # -f dir install files in the target directory ROOT/dir # -F dir like -f, but create directories that do not exist # -v echo actions # -idb stuff specify package and, optionally, do special work # preopts= postopts= SaveFirst=no HasSource=yes RemoveFirst=no NoUpdate=no Suggested=no Updated=no CMD=cp SRC= FILES= DESTDIR= CHMOD=":" CHOWN=":" CHGRP=":" RM="rm -f" MV="mv @MV_F@" ECHO=echo VERBOSE=":" STRIP="@STRIP@" CMP=cmp TARGETS= while [ x"$1" != x ] do arg=$1 case $arg in -m) shift; CHMOD="@CHMOD@ $1";; -u) shift; CHOWN="@CHOWN@ $1";; -g) shift; CHGRP="@CHGRP@ $1";; -o) SaveFirst=yes;; -O) RemoveFirst=yes; SaveFirst=yes;; -root) shift; ROOT=$1;; -dir) CMD=mkdir; HasSource=no; RM=":"; STRIP=":" ;; -fifo) CMD=@MKFIFO@; HasSource=no; x=`echo $CMD | @SED@ 's;.*/;;'`; test $x = mknod && postopts="p"; STRIP=":" ;; -ln) shift; CMD=@LN@; SRC="$1" STRIP=":" ;; -lns) shift; CMD=@LN@; preopts="@LN_S@"; SRC="$1" STRIP=":" ;; -src) shift; SRC="$1";; -[fF]) shift; DESTDIR="$1";; -idb) shift; opt="$1" case "$opt" in *config\(update\)*) Updated=yes;; *config\(suggest\)*) Suggested=yes;; *config\(noupdate\)*) NoUpdate=yes;; *nostrip*) STRIP=":";; esac ;; # these are skipped/not handled -new|-rawidb|-blk|-chr) shift;; -v) VERBOSE=$ECHO;; -*) ;; *) TARGETS="$TARGETS $arg";; esac shift done # # Install the specified target. # install() { src=$1 target=$2 if [ $RemoveFirst = yes -a -f $target ]; then $VERBOSE "$RM $target" $RM $target fi if [ $SaveFirst = yes -a -f $target ]; then bf=`echo $src | @SED@ 's;.*/;;'` $VERBOSE "$MV $target $ROOT/$DESTDIR/OLD$bf" $MV $target $ROOT/$DESTDIR/OLD$bf fi if [ -z "$SRC" -a $HasSource = yes ]; then $VERBOSE "$CMD $preopts $src $target $postopts" $CMD $preopts $f $target $postopts else $VERBOSE "$CMD $preopts $SRC $target $postopts" $CMD $preopts $SRC $target $postopts fi if [ $? -eq 0 ]; then $VERBOSE "$CHOWN $target" $CHOWN $target $VERBOSE "$CHGRP $target" $CHGRP $target $VERBOSE "$CHMOD $target" $CHMOD $target if [ $STRIP != ":" -a -x $ROOT/$DESTDIR/$f ]; then $STRIP $target >/dev/null 2>&1 || true $VERBOSE "$STRIP $target" fi fi } if [ $Suggested = yes ]; then # # A suggested file. If an existing target does # not exist, then install it. Otherwise, install # it as target.N if it's different from the current # installed target. # # NB: cannot be used with a special file 'cuz we # use test -f to see if the file exists. # for f in $TARGETS; do t=$ROOT/$DESTDIR/$f if [ -f $t ]; then if [ -z "$SRC" -a $HasSource = yes ]; then $CMP -s $f $t || { $ECHO "*** Warning, target has local changes, installing $f as $t.N" install $f $t.N; } else $CMP -s $SRC $t || { $ECHO "*** Warning, target has local changes, installing $f as $t.N" install $f $t.N } fi else install $f $t fi done elif [ $Updated = yes ]; then # # A file to be updated. If an existing target does # not exist, then install it. Otherwise, install # it as target and save the old version as target.O # if the old version is different from the current # installed target. # # NB: cannot be used with a special file 'cuz we # use test -f to see if the file exists. # for f in $TARGETS; do t=$ROOT/$DESTDIR/$f if [ -f $t ]; then if [ -z "$SRC" -a $HasSource = yes ]; then $CMP -s $f $t || $MV $t $t.O else $CMP -s $SRC $t || $MV $t $t.O fi fi install $f $t done elif [ $NoUpdate = yes ]; then # # A file that is never to be updated; the target # is created only if it does not exist. # # NB: cannot be used with a special file 'cuz we # use test -f to see if the file exists. # for f in $TARGETS; do t=$ROOT/$DESTDIR/$f test -f $t || install $f $t done else # # Normal case, a target that should be installed # with the existing copy, optionally, saved first. # for f in $TARGETS; do install $f $ROOT/$DESTDIR/$f done fi te = yes ]; then # # A file that is never to be updated; the target # is created only if it does not exist. # # NB: cannot be used with a special file 'cuz we # use test -f to see if the file exists. # for f in $TARGETS; do t=$ROOT/$DESTDIR/$f test -f $t || install $f $t done else # # Normal case, a target that should be installed # with the existing copy, optionally, saved first. # for f in $TARGETS; do install $ftiff-v3.4beta018/port/irix/so_locations000444 004341 000024 00000000134 06003062760 017724 0ustar00samuser000000 000000 libtiff.so \ :st = .text 0x5ff70000, 0x00030000:\ :st = .data 0x5ffd0000, 0x00030000:\ ed; the target # is created only if it does not exist. # # NB: cannot be used with a special file 'cuz we # use test -f to see if the file exists. # for f in $TARGETS; t=$ROOT/$DESµ¢0@«T tesFˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆ†ÁDˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úžoptily, saved first. ÿ¸¸ÿ¸Ò/ÿ­›p@<à; do install $ftiff-v3.4beta018/port/strcasecmp.c000444 004341 000024 00000007754 06003062761 016662 0ustar00samuser000000 000000 #include "port.h" /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that: (1) source distributions retain this entire copyright * notice and comment, and (2) distributions including binaries display * the following acknowledgement: ``This product includes software * developed by the University of California, Berkeley and its contributors'' * in the documentation or other materials provided with the distribution * and in all advertising materials mentioning features or use of this * software. Neither the name of the University nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)strcasecmp.c 5.9 (Berkeley) 6/1/90"; #endif /* LIBC_SCCS and not lint */ /* * This array is designed for mapping upper and lower case letter * together for a case independent comparison. The mappings are * based upon ascii character sequences. */ static const u_char charmap[] = { '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; int strcasecmp(s1, s2) const char *s1, *s2; { register const u_char *cm = charmap, *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; while (cm[*us1] == cm[*us2++]) if (*us1++ == '\0') return (0); return (cm[*us1] - cm[*--us2]); } int strncasecmp(s1, s2, n) const char *s1, *s2; register size_t n; { if (n != 0) { register const u_char *cm = charmap, *us1 = (const u_char *)s1, *us2 = (const u_char *)s2; do { if (cm[*us1] != cm[*us2++]) return (cm[*us1] - cm[*--us2]); if (*us1++ == '\0') break; } while (--n != 0); } return (0); } charmap, *us1 = tiff-v3.4beta018/port/strtoul.c000440 004341 000024 00000006460 06003062761 016217 0ustar00samuser000000 000000 /* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)strtoul.c 5.3 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include /* * Convert a string to an unsigned long integer. * * Ignores `locale' stuff. Assumes that the upper and lower case * alphabets and digits are each contiguous. */ unsigned long strtoul(nptr, endptr, base) const char *nptr; char **endptr; register int base; { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * See strtol for comments as to the logic used. */ do { c = *s++; } while (isspace(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = ULONG_MAX; errno = ERANGE; } else if (neg) acc = -acc; if (endptr != 0) *endptr = any ? s - 1 : (char *)nptr; return (acc); } igned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (isdigit(c)) c -= '0'; else if (isalpha(c)) c -= isupper(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= bastiff-v3.4beta018/tools/Makefile.in000444 004341 000024 00000015073 06003062762 016565 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/tools/RCS/Makefile.in,v 1.13 1995/07/05 21:09:52 sam Exp $ # # @WARNING@ # # TIFF Library Tools # # Copyright (c) 1988-1995 Sam Leffler # Copyright (c) 1991-1995 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 Stanford 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. # DEPTH = .. SRCDIR = ${DEPTH}/@SRCDIR@/tools JPEGDIR = ${DEPTH}/@DIR_JPEG@ ZIPDIR = ${DEPTH}/@DIR_LIBGZ@ PORT = ${DEPTH}/port # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = CC = @CCOMPILER@ INSTALL = @INSTALL@ # COPTS = @GCOPTS@ OPTIMIZER=-O IPATH = -I. -I${DEPTH} -I${SRCDIR} -I${DEPTH}/@SRCDIR@/libtiff CFLAGS = @ENVOPTS@ ${COPTS} ${OPTIMIZER} ${IPATH} # LIBTIFF = ../libtiff/libtiff.@DSOSUF@ LIBJPEG = @LIBJPEG@ LIBGZ = @LIBGZ@ LIBS = ${LIBTIFF} ${LIBJPEG} ${LIBGZ} @LIBPORT@ @MACHDEPLIBS@ # OBJS= \ fax2tiff.o \ fax2ps.o \ gif2tiff.o \ pal2rgb.o \ ppm2tiff.o \ rgb2ycbcr.o \ ras2tiff.o \ thumbnail.o \ tiff2bw.o \ tiff2ps.o \ tiffcmp.o \ tiffcp.o \ tiffdither.o \ tiffdump.o \ tiffinfo.o \ tiffmedian.o \ tiffsplit.o \ ${NULL} TARGETS =\ fax2tiff \ fax2ps \ gif2tiff \ pal2rgb \ ppm2tiff \ rgb2ycbcr \ thumbnail \ ras2tiff \ tiff2bw \ tiff2ps \ tiffcmp \ tiffcp \ tiffdither \ tiffdump \ tiffinfo \ tiffmedian \ tiffsplit \ ${NULL} all: ${TARGETS} @if [ "@LIBIMAGE@" = yes ]; then \ ${MAKE} sgi2tiff; \ fi @if [ "@LIBGL@" = yes ]; then \ ${MAKE} tiffgt tiffsv; \ fi install: all ${INSTALL} -idb tiff.sw.tools -m 755 -dir @DIR_BIN@ ${INSTALL} -idb tiff.sw.tools -m 755 -F @DIR_BIN@ -O ${TARGETS} @if [ "@LIBIMAGE@" = yes ]; then \ ${INSTALL} -idb tiff.sw.tools -m 755 -F @DIR_BIN@ -O sgi2tiff; \ fi @if [ "@LIBGL@" = yes ]; then \ ${INSTALL} -idb tiff.sw.tools -m 755 -F @DIR_BIN@ -O tiffgt tiffsv;\ fi clean: rm -f ${TARGETS} ${OBJS} sgigt.o tiffgt sgisv.o tiffsv \ sgi2tiff.o sgi2tiff core a.out ycbcr # # System-independent tools # tiffinfo: tiffinfo.o ${LIBTIFF} ${CC} -o tiffinfo ${CFLAGS} tiffinfo.o ${LIBS} tiffinfo.o: ${SRCDIR}/tiffinfo.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffinfo.c tiffcmp:tiffcmp.o ${LIBTIFF} ${CC} -o tiffcmp ${CFLAGS} tiffcmp.o ${LIBS} tiffcmp.o: ${SRCDIR}/tiffcmp.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffcmp.c tiffcp: tiffcp.o ${LIBTIFF} ${CC} -o tiffcp ${CFLAGS} tiffcp.o ${LIBS} tiffcp.o: ${SRCDIR}/tiffcp.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffcp.c tiffdump: tiffdump.o ${CC} -o tiffdump ${CFLAGS} tiffdump.o ${LIBS} tiffdump.o: ${SRCDIR}/tiffdump.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffdump.c tiffmedian: tiffmedian.o ${LIBTIFF} ${CC} -o tiffmedian ${CFLAGS} tiffmedian.o ${LIBS} tiffmedian.o: ${SRCDIR}/tiffmedian.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffmedian.c tiffsplit: tiffsplit.o ${LIBTIFF} ${CC} -o tiffsplit ${CFLAGS} tiffsplit.o ${LIBS} tiffsplit.o: ${SRCDIR}/tiffsplit.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffsplit.c tiff2ps: tiff2ps.o ${LIBTIFF} ${CC} -o tiff2ps ${CFLAGS} tiff2ps.o ${LIBS} tiff2ps.o: ${SRCDIR}/tiff2ps.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiff2ps.c # # Junky stuff... programs that are more examples of how # to use the library than full-blown useful tools. # # convert RGB image to B&W tiff2bw: tiff2bw.o ${LIBTIFF} ${CC} -o tiff2bw ${CFLAGS} tiff2bw.o ${LIBS} tiff2bw.o: ${SRCDIR}/tiff2bw.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiff2bw.c # convert B&W image to bilevel w/ FS dithering tiffdither: tiffdither.o ${LIBTIFF} ${CC} -o tiffdither ${CFLAGS} tiffdither.o ${LIBS} tiffdither.o: ${SRCDIR}/tiffdither.c ${CC} -c ${CFLAGS} ${SRCDIR}/tiffdither.c # simple Sun rasterfile converter ras2tiff: ras2tiff.o ${LIBTIFF} ${CC} -o ras2tiff ${CFLAGS} ras2tiff.o ${LIBS} ras2tiff.o: ${SRCDIR}/ras2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/ras2tiff.c # simple GIF converter gif2tiff: gif2tiff.o ${LIBTIFF} ${CC} -o gif2tiff ${CFLAGS} gif2tiff.o ${LIBS} gif2tiff.o: ${SRCDIR}/gif2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/gif2tiff.c # very limited PBM converter ppm2tiff: ppm2tiff.o ${LIBTIFF} ${CC} -o ppm2tiff ${CFLAGS} ppm2tiff.o ${LIBS} ppm2tiff.o: ${SRCDIR}/ppm2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/ppm2tiff.c # Group 3/4 FAX file converter fax2tiff: fax2tiff.o ${LIBTIFF} ${CC} -o fax2tiff ${CFLAGS} fax2tiff.o ${LIBS} fax2tiff.o: ${SRCDIR}/fax2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/fax2tiff.c # Group 3/4 FAX to encoded PS converter fax2ps: fax2ps.o ${LIBTIFF} ${CC} -o fax2ps ${CFLAGS} fax2ps.o ${LIBS} fax2ps.o: ${SRCDIR}/fax2ps.c ${CC} -c ${CFLAGS} ${SRCDIR}/fax2ps.c # convert Palette image to RGB pal2rgb: pal2rgb.o ${LIBTIFF} ${CC} -o pal2rgb ${CFLAGS} pal2rgb.o ${LIBS} pal2rgb.o: ${SRCDIR}/pal2rgb.c ${CC} -c ${CFLAGS} ${SRCDIR}/pal2rgb.c # convert RGB image to YCbCr rgb2ycbcr: rgb2ycbcr.o ${LIBTIFF} ${CC} -o rgb2ycbcr ${CFLAGS} rgb2ycbcr.o ${LIBS} rgb2ycbcr.o: ${SRCDIR}/rgb2ycbcr.c ${CC} -c ${CFLAGS} ${SRCDIR}/rgb2ycbcr.c # generate thumbnail images from fax (example of SubIFD usage) thumbnail: thumbnail.o ${LIBTIFF} ${CC} -o thumbnail ${CFLAGS} thumbnail.o ${LIBS} thumbnail.o: ${SRCDIR}/thumbnail.c ${CC} -c ${CFLAGS} ${SRCDIR}/thumbnail.c # # System-specific tools. # # # sgi2tiff converts SGI RGB images to TIFF; it requires # the SGI image library -limage. # sgi2tiff: sgi2tiff.o ${LIBTIFF} ${CC} -o sgi2tiff ${CFLAGS} sgi2tiff.o -limage ${LIBS} sgi2tiff.o: ${SRCDIR}/sgi2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/sgi2tiff.c # SGI versions of tiffgt & tiffsv that require -lgl tiffgt: sgigt.o ${LIBTIFF} ${CC} -o tiffgt ${CFLAGS} sgigt.o ${LIBS} -lgutil -lgl_s sgigt.o: ${SRCDIR}/sgigt.c ${CC} -c ${CFLAGS} ${SRCDIR}/sgigt.c tiffsv: sgisv.o ${LIBTIFF} ${CC} -o tiffsv ${CFLAGS} sgisv.o ${LIBS} -lgutil -lgl_s sgisv.o: ${SRCDIR}/sgisv.c ${CC} -c ${CFLAGS} ${SRCDIR}/sgisv.c tiff: sgi2tiff.o ${LIBTIFF} ${CC} -o sgi2tiff ${CFLAGS} sgi2tiff.o -limage ${LIBS} sgi2tiff.o: ${SRCDIR}/sgi2tiff.c ${CC} -c ${CFLAGS} ${SRCDIR}/sgi2tiff.c # SGI versions of tiffgt & tiffsv that require -lgl tiffgt: sgigt.o ${LIBTIFF} ${CC} -o tiffgt ${CFLAGS} sgigt.o ${LIBS} -lgutil -lgl_s sgigt.o: ${SRCDIR}/sgigt.c ${CC} -c ${CFLAGS} ${SRCDIR}/sgigt.c tiffsv: sgisv.o ${LIBTIFF} ${CC} -o tiffsv ${CFLAGS} sgisv.o ${LIBS} -lgutil -lgl_s sgisv.tiff-v3.4beta018/tools/Makefile.lcc000444 004341 000024 00000010207 06003062762 016712 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/tools/RCS/Makefile.lcc,v 1.3 1994/12/15 23:51:55 sam Exp $ # # TIFF Library Tools # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler # Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Stanford 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. # NULL= IPATH= -I..\libtiff # # If you don't want the public domain getopt code, then # simply null this out and you'll get whatever is in your # libc (or similar). # GETOPT= getopt.o # # Library-wide configuration defines: # Note that if you change the library-wide configuration, you'll # need to manual force a full rebuild. # CONF_LIBRARY=\ ${NULL} COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i CFLAGS= ${COPTS} ${IPATH} -DBINMODE='"b"' # LIBTIFF=..\libtiff\tiffrnb.lib LIBS= -l${LIBTIFF} -lm MACHALL=ras2tiff.ttp OBJS=\ fax2tiff.o \ gif2tiff.o \ pal2rgb.o \ ppm2tiff.o \ rgb2ycbcr.o \ tiff2bw.o \ tiff2ps.o \ tiffcmp.o \ tiffcp.o \ tiffdither.o \ tiffdump.o \ tiffinfo.o \ tiffmedian.o \ tiffsplit.o \ ras2tiff.o \ ${GETOPT} \ ${NULL} ALL=\ fax2tiff.ttp \ gif2tiff.ttp \ pal2rgb.ttp \ ppm2tiff.ttp \ rgb2ycbcr.ttp \ tiff2bw.ttp \ tiff2ps.ttp \ tiffcmp.ttp \ tiffcp.ttp \ tiffdither.ttp \ tiffdump.ttp \ tiffinfo.ttp \ tiffmedian.ttp \ tiffsplit.ttp \ ${MACHALL} \ ${NULL} all: ${ALL} tiffinfo.ttp: tiffinfo.c ${GETOPT} ${LIBTIFF} ${CC} -o tiffinfo.ttp ${CFLAGS} tiffinfo.c ${GETOPT} ${LIBS} tiffcmp.ttp: tiffcmp.c ${GETOPT} ${LIBTIFF} ${CC} -o tiffcmp.ttp ${CFLAGS} tiffcmp.c ${GETOPT} ${LIBS} tiffcp.ttp: tiffcp.c ${LIBTIFF} ${CC} -o tiffcp.ttp ${CFLAGS} tiffcp.c ${LIBS} tiffdump.ttp: tiffdump.c ${CC} -o tiffdump.ttp ${CFLAGS} tiffdump.c -lm ${LIBS} tiffmedian.ttp: tiffmedian.c ${LIBTIFF} ${CC} -o tiffmedian.ttp ${CFLAGS} tiffmedian.c ${LIBS} tiffsplit.ttp: tiffsplit.c ${LIBTIFF} ${CC} -o tiffsplit.ttp ${CFLAGS} tiffsplit.c ${LIBS} tiff2ps.ttp: tiff2ps.c ${LIBTIFF} ${CC} -o tiff2ps.ttp ${CFLAGS} tiff2ps.c ${LIBS} # junky stuff... # convert RGB image to B&W tiff2bw.ttp: tiff2bw.c ${GETOPT} ${LIBTIFF} ${CC} -o tiff2bw.ttp ${CFLAGS} tiff2bw.c ${GETOPT} ${LIBS} # convert B&W image to bilevel w/ FS dithering tiffdither.ttp: tiffdither.c ${LIBTIFF} ${CC} -o tiffdither.ttp ${CFLAGS} tiffdither.c ${LIBS} # Group 3 FAX file converter fax2tiff.ttp: fax2tiff.c ${GETOPT} ${LIBTIFF} ${CC} -o fax2tiff.ttp ${CFLAGS} ${CONF_LIBRARY} fax2tiff.c ${GETOPT} ${LIBS} # convert Palette image to RGB pal2rgb.ttp: pal2rgb.c ${LIBTIFF} ${CC} -o pal2rgb.ttp ${CFLAGS} pal2rgb.c ${LIBS} # convert RGB image to YCbCr rgb2ycbcr.ttp: rgb2ycbcr.c ${GETOPT} ${LIBTIFF} ${CC} -o rgb2ycbcr.ttp ${CFLAGS} rgb2ycbcr.c ${GETOPT} ${LIBS} # GIF converter gif2tiff.ttp: gif2tiff.c ${LIBTIFF} ${CC} -o gif2tiff.ttp ${CFLAGS} gif2tiff.c ${LIBS} # PBM converter ppm2tiff.ttp: ppm2tiff.c ${LIBTIFF} ${CC} -o ppm2tiff.ttp ${CFLAGS} ppm2tiff.c ${LIBS} # Sun rasterfile converter ras2tiff.ttp: ras2tiff.c ${LIBTIFF} ${CC} -o ras2tiff.ttp ${CFLAGS} ras2tiff.c ${LIBS} # generate thumbnail images from fax thumbnail: thumbnail.c ${LIBTIFF} ${CC} -o thumbnail ${CFLAGS} thumbnail.c ${LIBS} -lm install: all clean: rm -f ${ALL} ${OBJS} ycbcr.ttp } ${LIBS} # GIF converter gif2tiff.ttp: gif2tiff.c ${LIBTIFF} ${CC} -o gif2tiff.ttp ${CFLAGS} gif2tiff.c ${LIBS} # PBM converter ppm2tiff.ttp: ppm2tiff.c ${LIBTIFF} ${CC} -o ppm2tiff.ttp ${CFLAGS} ppm2tiff.c ${LIBS} # Sun rasterfile converter ras2tiff.ttp: ras2tiff.c ${LIBTIFF} ${CC} -o ras2tiff.ttp ${CFLAGS} ras2tiff.c ${LIBS} # generate thumbnail images from fax thumbnatiff-v3.4beta018/tools/fax2tiff.c000444 004341 000024 00000025276 06003062763 016404 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/fax2tiff.c,v 1.37 1995/07/17 01:36:52 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ /* * Convert a CCITT Group 3 FAX file to TIFF Group 3 format. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include /* should have atof & getopt */ #endif #include "tiffiop.h" #ifndef BINMODE #define BINMODE #endif #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif TIFF *faxTIFF; #define XSIZE 1728 u_char rowbuf[TIFFhowmany(XSIZE,8)]; u_char refbuf[TIFFhowmany(XSIZE,8)]; int verbose; int stretch; uint16 badfaxrun; uint32 badfaxlines; int copyFaxFile(TIFF* tifin, TIFF* tifout); static void usage(void); static tsize_t DummyReadProc(thandle_t fd, tdata_t buf, tsize_t size) { (void) fd; (void) buf; (void) size; return (0); } static tsize_t DummyWriteProc(thandle_t fd, tdata_t buf, tsize_t size) { (void) fd; (void) buf; (void) size; return (size); } int main(int argc, char* argv[]) { FILE *in; TIFF *out = NULL; TIFFErrorHandler whandler; int compression = COMPRESSION_CCITTFAX3; int fillorder = FILLORDER_LSB2MSB; uint32 group3options = GROUP3OPT_FILLBITS|GROUP3OPT_2DENCODING; int photometric = PHOTOMETRIC_MINISWHITE; int mode = FAXMODE_CLASSF; int rows; int c; int pn, npages; extern int optind; extern char* optarg; /* smuggle a descriptor out of the library */ faxTIFF = TIFFClientOpen("(FakeInput)", "w", (thandle_t) -1, DummyReadProc, DummyWriteProc, NULL, NULL, NULL, NULL, NULL); if (faxTIFF == NULL) return (EXIT_FAILURE); faxTIFF->tif_mode = O_RDONLY; TIFFSetField(faxTIFF, TIFFTAG_IMAGEWIDTH, XSIZE); TIFFSetField(faxTIFF, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(faxTIFF, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(faxTIFF, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); TIFFSetField(faxTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(faxTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(faxTIFF, TIFFTAG_YRESOLUTION, 196.); TIFFSetField(faxTIFF, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); /* NB: this is normally setup when a directory is read */ faxTIFF->tif_scanlinesize = TIFFScanlineSize(faxTIFF); while ((c = getopt(argc, argv, "R:o:2BLMW14cflmpsvwz")) != -1) switch (c) { /* input-related options */ case '2': /* input is 2d-encoded */ TIFFSetField(faxTIFF, TIFFTAG_GROUP3OPTIONS, GROUP3OPT_2DENCODING); break; case 'B': /* input has 0 mean black */ TIFFSetField(faxTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); break; case 'L': /* input has lsb-to-msb fillorder */ TIFFSetField(faxTIFF, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB); break; case 'M': /* input has msb-to-lsb fillorder */ TIFFSetField(faxTIFF, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); break; case 'R': /* input resolution */ TIFFSetField(faxTIFF, TIFFTAG_YRESOLUTION, atof(optarg)); break; case 'W': /* input has 0 mean white */ TIFFSetField(faxTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); break; /* output-related options */ case '1': /* generate 1d-encoded output */ group3options &= ~GROUP3OPT_2DENCODING; break; case '4': /* generate g4-encoded output */ compression = COMPRESSION_CCITTFAX4; break; case 'c': /* generate "classic" g3 format */ mode = FAXMODE_CLASSIC; break; case 'f': /* generate Class F format */ mode = FAXMODE_CLASSF; break; case 'm': /* output's fillorder is msb-to-lsb */ fillorder = FILLORDER_MSB2LSB; break; case 'o': out = TIFFOpen(optarg, "w"); if (out == NULL) return EXIT_FAILURE; break; case 'p': /* zero pad output scanline EOLs */ group3options &= ~GROUP3OPT_FILLBITS; break; case 's': /* stretch image by dup'ng scanlines */ stretch = 1; break; case 'w': /* undocumented -- for testing */ photometric = PHOTOMETRIC_MINISBLACK; break; case 'z': /* undocumented -- for testing */ compression = COMPRESSION_LZW; break; case 'v': /* -v for info */ verbose++; break; case '?': usage(); /*NOTREACHED*/ } if (out == NULL) { out = TIFFOpen("fax.tif", "w"); if (out == NULL) return (EXIT_FAILURE); } faxTIFF->tif_readproc = out->tif_readproc; /* XXX */ faxTIFF->tif_writeproc = out->tif_writeproc; /* XXX */ faxTIFF->tif_seekproc = out->tif_seekproc; /* XXX */ faxTIFF->tif_closeproc = out->tif_closeproc; /* XXX */ faxTIFF->tif_sizeproc = out->tif_sizeproc; /* XXX */ faxTIFF->tif_mapproc = out->tif_mapproc; /* XXX */ faxTIFF->tif_unmapproc = out->tif_unmapproc; /* XXX */ npages = argc - optind; if (npages < 1) usage(); /* NB: this must be done after directory info is setup */ TIFFSetField(faxTIFF, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX3); for (pn = 0; optind < argc; pn++, optind++) { in = fopen(argv[optind], "r" BINMODE); if (in == NULL) { fprintf(stderr, "%s: %s: Can not open\n", argv[0], argv[optind]); continue; } faxTIFF->tif_fd = fileno(in); faxTIFF->tif_clientdata = (thandle_t) faxTIFF->tif_fd; faxTIFF->tif_name = argv[optind]; TIFFSetField(out, TIFFTAG_IMAGEWIDTH, XSIZE); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(out, TIFFTAG_COMPRESSION, compression); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); if (compression == COMPRESSION_CCITTFAX3) { TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options); TIFFSetField(out, TIFFTAG_FAXMODE, mode); } if (compression == COMPRESSION_CCITTFAX3 || compression == COMPRESSION_CCITTFAX4) TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, -1L); else TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, 0)); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); TIFFSetField(out, TIFFTAG_SOFTWARE, "fax2tiff"); TIFFSetField(out, TIFFTAG_XRESOLUTION, 204.0); if (!stretch) { float yres; TIFFGetField(faxTIFF, TIFFTAG_YRESOLUTION, &yres); TIFFSetField(out, TIFFTAG_YRESOLUTION, yres); } else TIFFSetField(out, TIFFTAG_YRESOLUTION, 196.); TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); TIFFSetField(out, TIFFTAG_PAGENUMBER, pn+1, npages); if (!verbose) whandler = TIFFSetWarningHandler(NULL); rows = copyFaxFile(faxTIFF, out); fclose(in); if (!verbose) (void) TIFFSetWarningHandler(whandler); TIFFSetField(out, TIFFTAG_IMAGELENGTH, rows); if (verbose) { fprintf(stderr, "%s:\n", argv[optind]); fprintf(stderr, "%d rows in input\n", rows); fprintf(stderr, "%d total bad rows\n", badfaxlines); fprintf(stderr, "%d max consecutive bad rows\n", badfaxrun); } if (compression == COMPRESSION_CCITTFAX3 && mode == FAXMODE_CLASSF) { TIFFSetField(out, TIFFTAG_BADFAXLINES, badfaxlines); TIFFSetField(out, TIFFTAG_CLEANFAXDATA, badfaxlines ? CLEANFAXDATA_REGENERATED : CLEANFAXDATA_CLEAN); TIFFSetField(out, TIFFTAG_CONSECUTIVEBADFAXLINES, badfaxrun); } TIFFWriteDirectory(out); } TIFFClose(out); return (EXIT_SUCCESS); } int copyFaxFile(TIFF* tifin, TIFF* tifout) { uint32 row; uint16 badrun; int ok; tifin->tif_rawdatasize = TIFFGetFileSize(tifin); tifin->tif_rawdata = _TIFFmalloc(tifin->tif_rawdatasize); if (!ReadOK(tifin, tifin->tif_rawdata, tifin->tif_rawdatasize)) { TIFFError(tifin->tif_name, "%s: Read error at scanline 0"); return (0); } tifin->tif_rawcp = tifin->tif_rawdata; tifin->tif_rawcc = tifin->tif_rawdatasize; (*tifin->tif_setupdecode)(tifin); (*tifin->tif_predecode)(tifin, (tsample_t) 0); tifin->tif_row = 0; badfaxlines = 0; badfaxrun = 0; _TIFFmemset(refbuf, 0, sizeof (refbuf)); row = 0; badrun = 0; /* current run of bad lines */ while (tifin->tif_rawcc > 0) { ok = (*tifin->tif_decoderow)(tifin, rowbuf, sizeof (rowbuf), 0); if (!ok) { badfaxlines++; badrun++; /* regenerate line from previous good line */ _TIFFmemcpy(rowbuf, refbuf, sizeof (rowbuf)); } else { if (badrun > badfaxrun) badfaxrun = badrun; badrun = 0; _TIFFmemcpy(refbuf, rowbuf, sizeof (rowbuf)); } tifin->tif_row++; if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { fprintf(stderr, "%s: Write error at row %ld.\n", tifout->tif_name, row); break; } row++; if (stretch) { if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { fprintf(stderr, "%s: Write error at row %ld.\n", tifout->tif_name, row); break; } row++; } } if (badrun > badfaxrun) badfaxrun = badrun; _TIFFfree(tifin->tif_rawdata); return (row); } char* stuff[] = { "usage: fax2tiff [options] input.g3...", "where options are:", " -2 input data is 2d encoded", " -B input data has min 0 means black", " -L input data has LSB2MSB bit order (default)", " -M input data has MSB2LSB bit order", " -W input data has min 0 means white (default)", " -R # input data has # resolution (lines/inch) (default is 196)", "", " -o out.tif write output to out.tif", " -1 generate 1d-encoded output (default is G3 2d)", " -4 generate G4-encoded output (default is G3 2D)", " -c generate \"classic\" TIFF format (default is TIFF/F)", " -f generate TIFF Class F (TIFF/F) format (default)", " -m output fill order is MSB2LSB (default is LSB2MSB)", " -p do not byte-align EOL codes in output (default is byte-align)", " -s stretch image by duplicating scanlines", " -v print information about conversion work", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(EXIT_FAILURE); } erate \"classic\" TIFF format (default is TIFF/F)", " -f generate TIFF Class F (TIFF/F) format (default)", " -m output fill order is MSB2LSB (default is LSB2MSB)", " -p do not byte-align EOL codes in output (default is byte-align)", " -s stretch image by duplicating scanlines", " -v print information about conversiotiff-v3.4beta018/tools/fax2ps.c000444 004341 000024 00000027750 06003062763 016075 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/fax2ps.c,v 1.2 1995/06/06 23:21:41 sam Exp $" */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #include #include #include #include "tiffio.h" float defxres = 204.; /* default x resolution (pixels/inch) */ float defyres = 98.; /* default y resolution (lines/inch) */ float pageWidth = 8.5; /* image page width (inches) */ float pageHeight = 11.0; /* image page length (inches) */ int scaleToPage = 0; /* if true, scale raster to page dimensions */ int totalPages = 0; /* total # pages printed */ int row; /* current output row */ int maxline = 512; /* max output line of PostScript */ /* * Turn a bit-mapped scanline into the appropriate sequence * of PostScript characters to be rendered. * * Original version written by Bret D. Whissel, * Florida State University Meteorology Department * March 13-15, 1995. */ static void printruns(unsigned char* buf, uint16* runs, uint16* erun, uint32 lastx) { static struct { char white, black; short width; } WBarr[] = { { 'd', 'n', 512 }, { 'e', 'o', 256 }, { 'f', 'p', 128 }, { 'g', 'q', 64 }, { 'h', 'r', 32 }, { 'i', 's', 16 }, { 'j', 't', 8 }, { 'k', 'u', 4 }, { 'l', 'v', 2 }, { 'm', 'w', 1 } }; static char* svalue = " !\"#$&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abc"; int colormode = 1; /* 0 for white, 1 for black */ int runlength = 0; int n = maxline; int x = 0; int l; (void) buf; printf("%d m(", row++); while (runs < erun) { if (!runlength) { colormode ^= 1; runlength = *runs++; if (x+runlength > lastx) runlength = runs[-1] = lastx-x; x += runlength; if (!colormode && runs == erun) break; /* don't bother printing the final white run */ } /* * If a runlength is greater than 6 pixels, then spit out * black or white characters until the runlength drops to * 6 or less. Once a runlength is <= 6, then combine black * and white runlengths until a 6-pixel pattern is obtained. * Then write out the special character. Six-pixel patterns * were selected since 64 patterns is the largest power of * two less than the 92 "easily printable" PostScript * characters (i.e., no escape codes or octal chars). */ l = 0; while (runlength > 6) { /* Run is greater than six... */ if (runlength >= WBarr[l].width) { if (n == 0) { putchar('\n'); n = maxline; } putchar(colormode ? WBarr[l].black : WBarr[l].white), n--; runlength -= WBarr[l].width; } else l++; } while (runlength > 0 && runlength <= 6) { int bitsleft = 6; int t = 0; while (bitsleft) { if (runlength <= bitsleft) { if (colormode) t |= ((1 << runlength)-1) << (bitsleft-runlength); bitsleft -= runlength; runlength = 0; if (bitsleft) { if (runs >= erun) break; colormode ^= 1; runlength = *runs++; if (x+runlength > lastx) runlength = runs[-1] = lastx-x; x += runlength; } } else { /* runlength exceeds bits left */ if (colormode) t |= ((1 << bitsleft)-1); runlength -= bitsleft; bitsleft = 0; } } if (n == 0) { putchar('\n'); n = maxline; } putchar(svalue[t]), n--; } } printf(")s\n"); } void printTIF(TIFF* tif, int pageNumber) { uint32 w, h; uint16 unit; float xres, yres; tstrip_t s, ns; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres)) { TIFFWarning(TIFFFileName(tif), "No x-resolution, assuming %g dpi", defxres); xres = defxres; } if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres)) { TIFFWarning(TIFFFileName(tif), "No y-resolution, assuming %g lpi", defyres); yres = defyres; /* XXX */ } if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &unit) && unit == RESUNIT_CENTIMETER) { xres *= 25.4; yres *= 25.4; } printf("%%%%Page: \"%d\" %d\n", pageNumber, pageNumber); printf("gsave\n"); if (scaleToPage) { float yscale = pageHeight / (h/yres); float xscale = pageWidth / (w/xres); printf("0 %d translate\n", (int)(yscale*(h/yres)*72.)); printf("%g %g scale\n", (72.*xscale)/xres, -(72.*yscale)/yres); } else { printf("0 %d translate\n", (int)(72.*h/yres)); printf("%g %g scale\n", 72./xres, -72./yres); } printf("0 setgray\n"); TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, printruns); ns = TIFFNumberOfStrips(tif); row = 0; for (s = 0; s < ns; s++) (void) TIFFReadEncodedStrip(tif, s, (tdata_t) NULL, (tsize_t) -1); printf("p\n"); printf("grestore\n"); totalPages++; } #define GetPageNumber(tif) \ TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pn, &ptotal) int findPage(TIFF* tif, int pageNumber) { uint16 pn = (uint16) -1; uint16 ptotal = (uint16) -1; if (GetPageNumber(tif)) { while (pn != pageNumber && TIFFReadDirectory(tif) && GetPageNumber(tif)) ; return (pn == pageNumber); } else return (TIFFSetDirectory(tif, pageNumber-1)); } void fax2ps(TIFF* tif, int npages, int* pages, char* filename) { if (npages > 0) { uint16 pn, ptotal; int i; if (!GetPageNumber(tif)) fprintf(stderr, "%s: No page numbers, counting directories.\n", filename); for (i = 0; i < npages; i++) { if (findPage(tif, pages[i])) printTIF(tif, pages[i]); else fprintf(stderr, "%s: No page number %d\n", filename, pages[i]); } } else { int pageNumber = 1; do printTIF(tif, pageNumber++); while (TIFFReadDirectory(tif)); } } #undef GetPageNumber /* * Create a special PostScript font for printing FAX documents. By taking * advantage of the font-cacheing mechanism, a substantial speed-up in * rendering time is realized. */ static void emitFont(FILE* fd) { static const char* fontPrologue[] = { "/newfont 10 dict def newfont begin /FontType 3 def /FontMatrix [1", "0 0 1 0 0] def /FontBBox [0 0 512 1] def /Encoding 256 array def", "0 1 31{Encoding exch /255 put}for 120 1 255{Encoding exch /255", "put}for Encoding 37 /255 put Encoding 40 /255 put Encoding 41 /255", "put Encoding 92 /255 put /count 0 def /ls{Encoding exch count 3", "string cvs cvn put /count count 1 add def}def 32 1 36{ls}for", "38 1 39{ls}for 42 1 91{ls}for 93 1 99{ls}for /count 100", "def 100 1 119{ls}for /CharDict 5 dict def CharDict begin /white", "{dup 255 eq{pop}{1 dict begin 100 sub neg 512 exch bitshift", "/cw exch def cw 0 0 0 cw 1 setcachedevice end}ifelse}def /black", "{dup 255 eq{pop}{1 dict begin 110 sub neg 512 exch bitshift", "/cw exch def cw 0 0 0 cw 1 setcachedevice 0 0 moveto cw 0 rlineto", "0 1 rlineto cw neg 0 rlineto closepath fill end}ifelse}def /numbuild", "{dup 255 eq{pop}{6 0 0 0 6 1 setcachedevice 0 1 5{0 moveto", "dup 32 and 32 eq{1 0 rlineto 0 1 rlineto -1 0 rlineto closepath", "fill newpath}if 1 bitshift}for pop}ifelse}def /.notdef {}", "def /255 {}def end /BuildChar{exch begin dup 110 ge{Encoding", "exch get 3 string cvs cvi CharDict /black get}{dup 100 ge {Encoding", "exch get 3 string cvs cvi CharDict /white get}{Encoding exch get", "3 string cvs cvi CharDict /numbuild get}ifelse}ifelse exec end", "}def end /Bitfont newfont definefont 1 scalefont setfont", NULL }; int i; for (i = 0; fontPrologue[i] != NULL; i++) fprintf(fd, "%s\n", fontPrologue[i]); } static int pcompar(void* va, void* vb) { int* pa = (int*) va; int* pb = (int*) vb; return (*pa - *pb); } extern double atof(); static void usage(int code); main(int argc, char** argv) { extern int optind; extern char* optarg; int c, pageNumber; int* pages = 0, npages = 0; int dowarnings = 0; /* if 1, enable library warnings */ long t; TIFF* tif; while ((c = getopt(argc, argv, "l:p:x:y:W:H:wS")) != -1) switch (c) { case 'H': /* page height */ pageHeight = atof(optarg); break; case 'S': /* scale to page */ scaleToPage = 1; break; case 'W': /* page width */ pageWidth = atof(optarg); break; case 'p': /* print specific page */ pageNumber = atoi(optarg); if (pageNumber < 1) { fprintf(stderr, "%s: Invalid page number (must be > 0).\n", optarg); usage(-1); } if (pages) pages = (int*) realloc((char*) pages, (npages+1)*sizeof (int)); else pages = (int*) malloc(sizeof (int)); pages[npages++] = pageNumber; break; case 'w': dowarnings = 1; break; case 'x': defxres = atof(optarg); break; case 'y': defyres = atof(optarg); break; case 'l': maxline = atoi(optarg); break; case '?': usage(-1); } if (npages > 0) qsort(pages, npages, sizeof (int), pcompar); if (!dowarnings) TIFFSetWarningHandler(0); printf("%%!PS-Adobe-3.0\n"); printf("%%%%Creator: fax2ps\n"); #ifdef notdef printf("%%%%Title: %s\n", file); #endif t = time(0); printf("%%%%CreationDate: %s", ctime(&t)); printf("%%%%Origin: 0 0\n"); printf("%%%%BoundingBox: 0 0 %u %u\n", (int)(pageHeight*72), (int)(pageWidth*72)); /* XXX */ printf("%%%%Pages: (atend)\n"); printf("%%%%EndComments\n"); printf("%%%%BeginProlog\n"); emitFont(stdout); printf("/d{bind def}def\n"); /* bind and def proc */ printf("/m{0 exch moveto}d\n"); printf("/s{show}d\n"); printf("/p{showpage}d \n"); /* end page */ printf("%%%%EndProlog\n"); if (optind < argc) { do { tif = TIFFOpen(argv[optind], "r"); if (tif) { fax2ps(tif, npages, pages, argv[optind]); TIFFClose(tif); } else fprintf(stderr, "%s: Can not open, or not a TIFF file.\n", argv[optind]); } while (++optind < argc); } else { int n, fd; char temp[1024], buf[16*1024]; strcpy(temp, "/tmp/fax2psXXXXXX"); fd = mkstemp(temp); if (fd == -1) { fprintf(stderr, "Could not create temp file \"%s\"\n", temp); exit(-2); } while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0) write(fd, buf, n); tif = TIFFOpen(temp, "r"); unlink(temp); if (tif) { fax2ps(tif, npages, pages, ""); TIFFClose(tif); } else fprintf(stderr, "%s: Can not open, or not a TIFF file.\n", temp); close(fd); } printf("%%%%Trailer\n"); printf("%%%%Pages: %u\n", totalPages); printf("%%%%EOF\n"); exit(0); } char* stuff[] = { "usage: fax2ps [options] [input.tif ...]", "where options are:", " -w suppress warning messages", " -l chars set maximum output line length for generated PostScript", " -p page# select page to print (can use multiple times)", " -x xres set default horizontal resolution of input data (dpi)", " -y yres set default vertical resolution of input data (lpi)", " -S scale output to page size", " -W width set output page width (inches), default is 8.5", " -H height set output page height (inchest), default is 11", NULL }; static void usage(int code) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(code); } multiple times)", " -x xtiff-v3.4beta018/tools/gif2tiff.c000444 004341 000024 00000031517 06003062764 016367 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/gif2tiff.c,v 1.24 1995/06/30 00:27:07 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ /* * convert a GIF file into a TIFF file. * based on Paul Haeberli's fromgif program which in turn is * based on a GIF file reader by Marcel J.E. Mol March 23 1989 * * if input is 320 by 200 pixel aspect is probably 1.2 * if input is 640 350 pixel aspect is probably 1.37 * */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include "tiffio.h" #ifdef _WINDOWS #define BINMODE "w" #else #define BINMODE #endif #define GIFGAMMA (1.5) /* smaller makes output img brighter */ #define IMAX 0xffff /* max intensity value */ #define EXTRAFUDGE 128 /* some people write BAD .gif files */ #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) unsigned short gamtab[256]; void makegamtab(float gam) { int i; for(i=0; i<256; i++) gamtab[i] = IMAX*pow(i/255.0,gam)+0.5; } char* stuff[] = { "usage: gif2tiff [options] input.gif output.tif", "where options are:", " -r # make each strip have no more than # rows", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } #define COLSIZE 256 unsigned char *stackp; unsigned int prefix[4096]; unsigned char suffix[4096]; unsigned char stack[4096]; int datasize,codesize,codemask; /* Decoder working variables */ int clear,eoi; /* Special code values */ int avail, oldcode; FILE *infile; int global; /* Is there a global color map? */ int globalbits; /* Number of bits of global colors */ unsigned char globalmap[COLSIZE][3];/* RGB values for global color map */ unsigned char *raster; /* Decoded image data */ unsigned long width, height; unsigned short red[COLSIZE]; unsigned short green[COLSIZE]; unsigned short blue[COLSIZE]; char *filename, *imagename; static uint16 compression = COMPRESSION_LZW; static uint16 predictor = 0; static uint32 rowsperstrip = (uint32) -1; static int processCompressOptions(char*); int convert(void); int checksignature(void); void readscreen(void); int readgifimage(char*); void readextension(void); int readraster(void); int process(int, unsigned char**); void initcolors(unsigned char [COLSIZE][3], int); void rasterize(int, char*); int main(int argc, char* argv[]) { extern int optind; extern char *optarg; int c, status; while ((c = getopt(argc, argv, "c:r:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 2) usage(); makegamtab(GIFGAMMA); filename = argv[optind]; imagename = argv[optind+1]; if ((infile = fopen(imagename, "r" BINMODE)) != NULL) { int c; fclose(infile); printf("overwrite %s? ", imagename); fflush(stdout); c = getc(stdin); if (c != 'y' && c != 'Y') return (1); } if ((infile = fopen(filename, "r" BINMODE)) == NULL) { perror(filename); return (1); } status = convert(); fclose(infile); return (status); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } int convert(void) { int ch; char* mode = "w"; if (!checksignature()) return (-1); readscreen(); while ((ch = getc(infile)) != ';' && ch != EOF) { switch (ch) { case '\0': break; /* this kludge for non-standard files */ case ',': if (!readgifimage(mode)) return (-1); mode = "a"; /* subsequent images append */ break; case '!': readextension(); break; default: fprintf(stderr, "illegal GIF block type\n"); return (-1); } } return (0); } int checksignature(void) { char buf[6]; fread(buf,1,6,infile); if (strncmp(buf,"GIF",3)) { fprintf(stderr, "file is not a GIF file\n"); return 0; } if (strncmp(&buf[3],"87a",3)) { fprintf(stderr, "unknown GIF version number\n"); return 0; } return 1; } /* * readscreen - * Get information which is global to all the images stored * in the file */ void readscreen(void) { unsigned char buf[7]; fread(buf,1,7,infile); global = buf[4] & 0x80; if (global) { globalbits = (buf[4] & 0x07) + 1; fread(globalmap,3,1< 0; count = getc(infile)) { fread(buf,1,count,infile); for (ch=buf; count-- > 0; ch++) { datum += (unsigned long) *ch << bits; bits += 8; while (bits >= codesize) { code = datum & codemask; datum >>= codesize; bits -= codesize; if (code == eoi) { /* This kludge put in */ goto exitloop; /* because some GIF files*/ } /* aren't standard */ if (!process(code, &fill)) { status = 0; goto exitloop; } } } if (fill >= raster + width*height) { fprintf(stderr, "raster full before eoi code\n"); break; } } exitloop: if (fill != raster + width*height) { fprintf(stderr, "warning: wrong rastersize: %ld bytes\n", (long) (fill-raster)); fprintf(stderr, " instead of %ld bytes\n", (long) width*height); } return status; } /* * process - * Process a compression code. "clear" resets the code table. * Otherwise make a new code table entry, and output the bytes * associated with the code. */ int process(register int code, unsigned char** fill) { int incode; static unsigned char firstchar; if (code == clear) { codesize = datasize + 1; codemask = (1 << codesize) - 1; avail = clear + 2; oldcode = -1; return 1; } if (oldcode == -1) { *(*fill)++ = suffix[code]; firstchar = oldcode = code; return 1; } if (code > avail) { fprintf(stderr, "code %d too large for %d\n", code, avail); return 0; } incode = code; if (code == avail) { /* the first code is always < avail */ *stackp++ = firstchar; code = oldcode; } while (code > clear) { *stackp++ = suffix[code]; code = prefix[code]; } *stackp++ = firstchar = suffix[code]; prefix[avail] = oldcode; suffix[avail] = firstchar; avail++; if (((avail & codemask) == 0) && (avail < 4096)) { codesize++; codemask += avail; } oldcode = incode; do { *(*fill)++ = *--stackp; } while (stackp > stack); return 1; } /* * initcolors - * Convert a color map (local or global) to arrays with R, G and B * values. * */ void initcolors(unsigned char colormap[COLSIZE][3], int ncolors) { register int i; for (i = 0; i < ncolors; i++) { red[i] = gamtab[colormap[i][0]]; green[i] = gamtab[colormap[i][1]]; blue[i] = gamtab[colormap[i][2]]; } } void rasterize(int interleaved, char* mode) { register long row; register unsigned char *rr; unsigned char *newras; TIFF *tif; tstrip_t strip; tsize_t stripsize; if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) { fprintf(stderr, "not enough memory for image\n"); 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); \ ras += width; \ } \ } if (interleaved) { DRAWSEGMENT(0, 8); DRAWSEGMENT(4, 8); DRAWSEGMENT(2, 4); DRAWSEGMENT(1, 2); } else DRAWSEGMENT(0, 1); #undef DRAWSEGMENT tif = TIFFOpen(imagename, mode); if (!tif) { TIFFError(imagename,"Can not open output image"); exit(-1); } TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) height); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip)); TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); break; } TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); strip = 0; stripsize = TIFFStripSize(tif); for (row=0; row #include #include #endif #include #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) static void usage(void); static void cpTags(TIFF* in, TIFF* out); static int checkcmap(int n, uint16* r, uint16* g, uint16* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) return (16); fprintf(stderr, "Warning, assuming 8-bit colormap.\n"); return (8); } #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) static uint16 compression = (uint16) -1; static uint16 predictor = 0; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; static int processCompressOptions(char*); int main(int argc, char* argv[]) { uint16 bitspersample, shortv; uint32 imagewidth, imagelength; uint16 config = PLANARCONFIG_CONTIG; uint32 rowsperstrip = (uint32) -1; uint16 photometric = PHOTOMETRIC_RGB; uint16 *rmap, *gmap, *bmap; uint32 row; int cmap = -1; TIFF *in, *out; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "C:c:p:r:")) != -1) switch (c) { case 'C': /* force colormap interpretation */ cmap = atoi(optarg); break; case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'p': /* planar configuration */ if (streq(optarg, "separate")) config = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) config = PLANARCONFIG_CONTIG; else usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 2) usage(); in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-1); if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &shortv) || shortv != PHOTOMETRIC_PALETTE) { fprintf(stderr, "%s: Expecting a palette image.\n", argv[optind]); return (-1); } if (!TIFFGetField(in, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { fprintf(stderr, "%s: No colormap (not a valid palette image).\n", argv[optind]); return (-1); } bitspersample = 0; TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample != 8) { fprintf(stderr, "%s: Sorry, can only handle 8-bit images.\n", argv[optind]); return (-1); } out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-2); cpTags(in, out); TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); if (compression != (uint16)-1) TIFFSetField(out, TIFFTAG_COMPRESSION, compression); else TIFFGetField(in, TIFFTAG_COMPRESSION, &compression); switch (compression) { case COMPRESSION_JPEG: if (jpegcolormode == JPEGCOLORMODE_RGB) photometric = PHOTOMETRIC_YCBCR; else photometric = PHOTOMETRIC_RGB; TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip)); (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv); if (cmap == -1) cmap = checkcmap(1< 0; i--) { #define CVT(x) (((x) * 255) / ((1L<<16)-1)) rmap[i] = CVT(rmap[i]); gmap[i] = CVT(gmap[i]); bmap[i] = CVT(bmap[i]); } } { unsigned char *ibuf, *obuf; register unsigned char* pp; register uint32 x; ibuf = (unsigned char*)_TIFFmalloc(TIFFScanlineSize(in)); obuf = (unsigned char*)_TIFFmalloc(TIFFScanlineSize(out)); switch (config) { case PLANARCONFIG_CONTIG: for (row = 0; row < imagelength; row++) { if (!TIFFReadScanline(in, ibuf, row, 0)) goto done; pp = obuf; for (x = 0; x < imagewidth; x++) { *pp++ = rmap[ibuf[x]]; *pp++ = gmap[ibuf[x]]; *pp++ = bmap[ibuf[x]]; } if (!TIFFWriteScanline(out, obuf, row, 0)) goto done; } break; case PLANARCONFIG_SEPARATE: for (row = 0; row < imagelength; row++) { if (!TIFFReadScanline(in, ibuf, row, 0)) goto done; for (pp = obuf, x = 0; x < imagewidth; x++) *pp++ = rmap[ibuf[x]]; if (!TIFFWriteScanline(out, obuf, row, 0)) goto done; for (pp = obuf, x = 0; x < imagewidth; x++) *pp++ = gmap[ibuf[x]]; if (!TIFFWriteScanline(out, obuf, row, 0)) goto done; for (pp = obuf, x = 0; x < imagewidth; x++) *pp++ = bmap[ibuf[x]]; if (!TIFFWriteScanline(out, obuf, row, 0)) goto done; } break; } _TIFFfree(ibuf); _TIFFfree(obuf); } done: (void) TIFFClose(in); (void) TIFFClose(out); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } #define CopyField1(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) #define CopyField4(tag, v1, v2, v3, v4) \ if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { uint16 shortv, shortv2, *shortav; float floatv, *floatav; char *stringv; uint32 longv; switch (type) { case TIFF_SHORT: if (count == 1) { CopyField1(tag, shortv); } else if (count == 2) { CopyField2(tag, shortv, shortv2); } else if (count == (uint16) -1) { CopyField2(tag, shortv, shortav); } break; case TIFF_LONG: CopyField1(tag, longv); break; case TIFF_RATIONAL: if (count == 1) { CopyField1(tag, floatv); } else if (count == (uint16) -1) { CopyField1(tag, floatav); } break; case TIFF_ASCII: CopyField1(tag, stringv); break; } } #undef CopyField4 #undef CopyField3 #undef CopyField2 #undef CopyField1 static struct cpTag { uint16 tag; uint16 count; TIFFDataType type; } tags[] = { { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, { TIFFTAG_IMAGELENGTH, 1, TIFF_LONG }, { TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT }, { TIFFTAG_COMPRESSION, 1, TIFF_SHORT }, { TIFFTAG_FILLORDER, 1, TIFF_SHORT }, { TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG }, { TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG }, { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, { TIFFTAG_MAKE, 1, TIFF_ASCII }, { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, { TIFFTAG_INKSET, 1, TIFF_SHORT }, { TIFFTAG_INKNAMES, 1, TIFF_ASCII }, { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) cpTag(in, out, p->tag, p->count, p->type); } #undef NTAGS char* stuff[] = { "usage: pal2rgb [options] input.tif output.tif", "where options are:", " -p contig pack samples contiguously (e.g. RGBRGB...)", " -p separate store samples separately (e.g. RRR...GGG...BBB...)", " -r # make each strip have no more than # rows", " -C 8 assume 8-bit colormap values (instead of 16-bit)", " -C 16 assume 16-bit colormap values", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packtiff-v3.4beta018/tools/ppm2tiff.c000444 004341 000024 00000015013 06003062764 016407 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/ppm2tiff.c,v 1.22 1995/07/01 01:16:55 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include "tiffio.h" #ifdef _WINDOWS #define BINMODE "w" #else #define BINMODE #endif #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) static uint16 compression = (uint16) -1; static uint16 predictor = 0; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; static void usage(void); static int processCompressOptions(char*); static void BadPPM(char* file) { fprintf(stderr, "%s: Not a PPM file.\n", file); exit(-2); } int main(int argc, char* argv[]) { uint16 photometric; uint32 rowsperstrip = (uint32) -1; double resolution = -1; unsigned char *buf = NULL; uint32 row; tsize_t linebytes; uint16 spp; TIFF *out; FILE *in; uint32 w, h; int prec; char *infile; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:r:R:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case 'R': /* resolution */ resolution = atof(optarg); break; case '?': usage(); /*NOTREACHED*/ } /* * If only one file is specified, read input from * stdin; otherwise usage is: ppm2tiff input output. */ if (argc - optind > 1) { infile = argv[optind++]; in = fopen(infile, "r" BINMODE); if (in == NULL) { fprintf(stderr, "%s: Can not open.\n", infile); return (-1); } } else { infile = ""; in = stdin; } if (getc(in) != 'P') BadPPM(infile); switch (getc(in)) { case '5': /* it's a PGM file */ spp = 1; photometric = PHOTOMETRIC_MINISBLACK; break; case '6': /* it's a PPM file */ spp = 3; photometric = PHOTOMETRIC_RGB; if (compression == COMPRESSION_JPEG && jpegcolormode == JPEGCOLORMODE_RGB) photometric = PHOTOMETRIC_YCBCR; break; default: BadPPM(infile); } if (fscanf(in, " %ld %d %d", &w, &h, &prec) != 3) BadPPM(infile); if (getc(in) != '\n' || w <= 0 || h <= 0 || prec != 255) BadPPM(infile); out = TIFFOpen(argv[optind], "w"); if (out == NULL) return (-4); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w); TIFFSetField(out, TIFFTAG_IMAGELENGTH, h); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_JPEG: TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } linebytes = spp * w; if (TIFFScanlineSize(out) > linebytes) buf = (unsigned char *)_TIFFmalloc(linebytes); else buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); if (resolution > 0) { TIFFSetField(out, TIFFTAG_XRESOLUTION, resolution); TIFFSetField(out, TIFFTAG_YRESOLUTION, resolution); TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); } for (row = 0; row < h; row++) { if (fread(buf, linebytes, 1, in) != 1) { fprintf(stderr, "%s: scanline %lu: Read error.\n", infile, (unsigned long) row); break; } if (TIFFWriteScanline(out, buf, row, 0) < 0) break; } (void) TIFFClose(out); if (buf) _TIFFfree(buf); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } char* stuff[] = { "usage: ppm2tiff [options] input.ppm output.tif", "where options are:", " -r # make each strip have no more than # rows", " -R # set x&y resolution (dpi)", "", " -c jpeg[:opts] compress output with JPEG encoding", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } ut with packbits encoding", " -c none use no compression algorithm on output", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); etiff-v3.4beta018/tools/ras2tiff.c000444 004341 000024 00000017340 06003062765 016406 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/ras2tiff.c,v 1.26 1995/07/01 01:16:55 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include "rasterfile.h" #include "tiffio.h" #define howmany(x, y) (((x)+((y)-1))/(y)) #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) #ifndef BINMODE #define BINMODE #endif static uint16 compression = (uint16) -1; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ static uint16 predictor = 0; static void usage(void); static int processCompressOptions(char*); int main(int argc, char* argv[]) { unsigned char* buf; uint32 row; tsize_t linebytes, scanline; TIFF *out; FILE *in; struct rasterfile h; uint16 photometric; uint16 config = PLANARCONFIG_CONTIG; uint32 rowsperstrip = (uint32) -1; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:r:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 2) usage(); in = fopen(argv[optind], "r" BINMODE); if (in == NULL) { fprintf(stderr, "%s: Can not open.\n", argv[optind]); return (-1); } if (fread(&h, sizeof (h), 1, in) != 1) { fprintf(stderr, "%s: Can not read header.\n", argv[optind]); return (-2); } if (h.ras_magic != RAS_MAGIC) { fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]); return (-3); } out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-4); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) h.ras_width); TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h.ras_height); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1); TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); if (h.ras_maptype != RMT_NONE) { uint16* red; register uint16* map; register int i, j; int mapsize; buf = (unsigned char *)_TIFFmalloc(h.ras_maplength); if (buf == NULL) { fprintf(stderr, "No space to read in colormap.\n"); return (-5); } if (fread(buf, h.ras_maplength, 1, in) != 1) { fprintf(stderr, "%s: Read error on colormap.\n", argv[optind]); return (-6); } mapsize = 1< mapsize*3) { fprintf(stderr, "%s: Huh, %d colormap entries, should be %d?\n", argv[optind], h.ras_maplength, mapsize*3); return (-7); } red = (uint16*)_TIFFmalloc(mapsize * 3 * sizeof (uint16)); if (red == NULL) { fprintf(stderr, "No space for colormap.\n"); return (-8); } map = red; for (j = 0; j < 3; j++) { #define SCALE(x) (((x)*((1L<<16)-1))/255) for (i = h.ras_maplength/3; i-- > 0;) *map++ = SCALE(*buf++); if ((i = h.ras_maplength/3) < mapsize) { i = mapsize - i; _TIFFmemset(map, 0, i*sizeof (uint16)); map += i; } } TIFFSetField(out, TIFFTAG_COLORMAP, red, red + mapsize, red + 2*mapsize); photometric = PHOTOMETRIC_PALETTE; if (compression == (uint16) -1) compression = COMPRESSION_PACKBITS; TIFFSetField(out, TIFFTAG_COMPRESSION, compression); } else { /* XXX this is bogus... */ photometric = h.ras_depth == 24 ? PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK; if (compression == (uint16) -1) compression = COMPRESSION_LZW; TIFFSetField(out, TIFFTAG_COMPRESSION, compression); } switch (compression) { case COMPRESSION_JPEG: if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) photometric = PHOTOMETRIC_YCBCR; TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); linebytes = ((h.ras_depth*h.ras_width+15) >> 3) &~ 1; scanline = TIFFScanlineSize(out); if (scanline > linebytes) { buf = (unsigned char *)_TIFFmalloc(scanline); _TIFFmemset(buf+linebytes, 0, scanline-linebytes); } else buf = (unsigned char *)_TIFFmalloc(linebytes); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); for (row = 0; row < h.ras_height; row++) { if (fread(buf, linebytes, 1, in) != 1) { fprintf(stderr, "%s: scanline %lu: Read error.\n", argv[optind], (unsigned long) row); break; } if (h.ras_type == RT_STANDARD && h.ras_depth == 24) { tsize_t cc = linebytes; unsigned char* cp = buf; #define SWAP(a,b) { unsigned char t = (a); (a) = (b); (b) = t; } do { SWAP(cp[0], cp[2]); cp += 3; } while (--cc); } if (TIFFWriteScanline(out, buf, row, 0) < 0) break; } (void) TIFFClose(out); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } char* stuff[] = { "usage: ras2tiff [options] input.ras output.tif", "where options are:", " -r # make each strip have no more than # rows", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c jpeg[:opts]compress output with JPEG encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } PEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 totiff-v3.4beta018/tools/rasterfile.h000444 004341 000024 00000003357 06003062765 017036 0ustar00samuser000000 000000 /* $Header: /usr/people/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 */ struct rasterfile { int ras_magic; /* magic number */ int ras_width; /* width (pixels) of image */ int ras_height; /* height (pixels) of image */ int ras_depth; /* depth (1, 8, or 24 bits) of pixel */ int ras_length; /* length (bytes) of image */ int ras_type; /* type of file; see RT_* below */ int ras_maptype; /* type of colormap; see RMT_* below */ int ras_maplength; /* length (bytes) of following map */ /* color map follows for ras_maplength bytes, followed by image */ }; #define RAS_MAGIC 0x59a66a95 /* Sun supported ras_type's */ #define RT_OLD 0 /* Raw pixrect image in 68000 byte order */ #define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ #define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ #define RT_EXPERIMENTAL 0xffff /* Reserved for testing */ /* Sun registered ras_maptype's */ #define RMT_RAW 2 /* Sun supported ras_maptype's */ #define RMT_NONE 0 /* ras_maplength is expected to be 0 */ #define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */ /* * NOTES: * Each line of the image is rounded out to a multiple of 16 bits. * This corresponds to the rounding convention used by the memory pixrect * package (/usr/include/pixrect/memvar.h) of the SunWindows system. * The ras_encoding field (always set to 0 by Sun's supported software) * was renamed to ras_length in release 2.0. As a result, rasterfiles * of type 0 generated by the old software claim to have 0 length; for * compatibility, code reading rasterfiles must be prepared to compute the * true length from the width, height, and depth fields. */ bits. * This corresponds to the rounding convention used by the memory pixrect * package (/usr/include/pixrect/memvar.h) of the SunWindows system. * The ras_encoding field (always set to 0 by Sun's supported software) * was renamed to ras_length in release 2.0. tiff-v3.4beta018/tools/rgb2ycbcr.c000444 004341 000024 00000022721 06003062766 016545 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/rgb2ycbcr.c,v 1.25 1995/06/06 23:45:26 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define howmany(x, y) (((x)+((y)-1))/(y)) #define roundup(x, y) (howmany(x,y)*((uint32)(y))) #define LumaRed ycbcrCoeffs[0] #define LumaGreen ycbcrCoeffs[1] #define LumaBlue ycbcrCoeffs[2] uint16 compression = COMPRESSION_LZW; uint32 rowsperstrip = (uint32) -1; uint16 horizSubSampling = 2; /* YCbCr horizontal subsampling */ uint16 vertSubSampling = 2; /* YCbCr vertical subsampling */ float ycbcrCoeffs[3] = { .299, .587, .114 }; /* default coding range is CCIR Rec 601-1 with no headroom/footroom */ float refBlackWhite[6] = { 0., 255., 128., 255., 128., 255. }; static int tiffcvt(TIFF* in, TIFF* out); static void usage(void); static void setupLumaTables(void); int main(int argc, char* argv[]) { TIFF *in, *out; int c; extern int optind; extern char *optarg; while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1) switch (c) { case 'c': if (streq(optarg, "none")) compression = COMPRESSION_NONE; else if (streq(optarg, "packbits")) compression = COMPRESSION_PACKBITS; else if (streq(optarg, "lzw")) compression = COMPRESSION_LZW; else if (streq(optarg, "jpeg")) compression = COMPRESSION_JPEG; else usage(); break; case 'h': horizSubSampling = atoi(optarg); break; case 'v': vertSubSampling = atoi(optarg); break; case 'r': rowsperstrip = atoi(optarg); break; case 'z': /* CCIR Rec 601-1 w/ headroom/footroom */ refBlackWhite[0] = 16.; refBlackWhite[1] = 235.; refBlackWhite[2] = 128.; refBlackWhite[3] = 240.; refBlackWhite[4] = 128.; refBlackWhite[5] = 240.; break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); out = TIFFOpen(argv[argc-1], "w"); if (out == NULL) return (-2); setupLumaTables(); for (; optind < argc-1; optind++) { in = TIFFOpen(argv[optind], "r"); if (in != NULL) { do { if (!tiffcvt(in, out) || !TIFFWriteDirectory(out)) { (void) TIFFClose(out); return (1); } } while (TIFFReadDirectory(in)); (void) TIFFClose(in); } } (void) TIFFClose(out); return (0); } float *lumaRed; float *lumaGreen; float *lumaBlue; float D1, D2; int Yzero; static float* setupLuma(float c) { float *v = (float *)_TIFFmalloc(256 * sizeof (float)); int i; for (i = 0; i < 256; i++) v[i] = c * i; return (v); } static unsigned V2Code(float f, float RB, float RW, int CR) { unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5); return (c > 255 ? 255 : c); } static void setupLumaTables(void) { lumaRed = setupLuma(LumaRed); lumaGreen = setupLuma(LumaGreen); lumaBlue = setupLuma(LumaBlue); D1 = 1./(2 - 2*LumaBlue); D2 = 1./(2 - 2*LumaRed); Yzero = V2Code(0, refBlackWhite[0], refBlackWhite[1], 255); } static void cvtClump(unsigned char* op, uint32* raster, uint32 ch, uint32 cw, uint32 w) { float Y, Cb = 0, Cr = 0; int j, k; /* * Convert ch-by-cw block of RGB * to YCbCr and sample accordingly. */ for (k = 0; k < ch; k++) { for (j = 0; j < cw; j++) { uint32 RGB = (raster - k*w)[j]; Y = lumaRed[TIFFGetR(RGB)] + lumaGreen[TIFFGetG(RGB)] + lumaBlue[TIFFGetB(RGB)]; /* accumulate chrominance */ Cb += (TIFFGetB(RGB) - Y) * D1; Cr += (TIFFGetR(RGB) - Y) * D2; /* emit luminence */ *op++ = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255); } for (; j < horizSubSampling; j++) *op++ = Yzero; } for (; k < vertSubSampling; k++) { for (j = 0; j < horizSubSampling; j++) *op++ = Yzero; } /* emit sampled chrominance values */ *op++ = V2Code(Cb / (ch*cw), refBlackWhite[2], refBlackWhite[3], 127); *op++ = V2Code(Cr / (ch*cw), refBlackWhite[4], refBlackWhite[5], 127); } #undef LumaRed #undef LumaGreen #undef LumaBlue #undef V2Code /* * Convert a strip of RGB data to YCbCr and * sample to generate the output data. */ static void cvtStrip(unsigned char* op, uint32* raster, uint32 nrows, uint32 width) { uint32 x; int clumpSize = vertSubSampling * horizSubSampling + 2; uint32 *tp; for (; nrows >= vertSubSampling; nrows -= vertSubSampling) { tp = raster; for (x = width; x >= horizSubSampling; x -= horizSubSampling) { cvtClump(op, tp, vertSubSampling, horizSubSampling, width); op += clumpSize; tp += horizSubSampling; } if (x > 0) { cvtClump(op, tp, vertSubSampling, x, width); op += clumpSize; } raster -= vertSubSampling*width; } if (nrows > 0) { tp = raster; for (x = width; x >= horizSubSampling; x -= horizSubSampling) { cvtClump(op, tp, nrows, horizSubSampling, width); op += clumpSize; tp += horizSubSampling; } if (x > 0) cvtClump(op, tp, nrows, x, width); } } static int cvtRaster(TIFF* tif, uint32* raster, uint32 width, uint32 height) { uint32 y; tstrip_t strip = 0; tsize_t cc, acc; unsigned char* buf; uint32 rwidth = roundup(width, horizSubSampling); uint32 rheight = roundup(height, vertSubSampling); uint32 nrows = (rowsperstrip > rheight ? rheight : rowsperstrip); cc = nrows*rwidth + 2*((nrows*rwidth) / (horizSubSampling*vertSubSampling)); buf = (unsigned char*)_TIFFmalloc(cc); for (y = height; (int32) y > 0; y -= nrows) { uint32 nr = (y > nrows ? nrows : y); cvtStrip(buf, raster + (y-1)*width, nr, width); nr = roundup(nr, vertSubSampling); acc = nr*rwidth + 2*((nr*rwidth)/(horizSubSampling*vertSubSampling)); if (!TIFFWriteEncodedStrip(tif, strip++, buf, acc)) { _TIFFfree(buf); return (0); } } _TIFFfree(buf); return (1); } static int tiffcvt(TIFF* in, TIFF* out) { uint32 width, height; /* image width & height */ uint32* raster; /* retrieve RGBA image */ uint16 shortv; float floatv; char *stringv; uint32 longv; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32)); if (raster == 0) { TIFFError(TIFFFileName(in), "No space for raster buffer"); return (0); } if (!TIFFReadRGBAImage(in, width, height, raster, 0)) { _TIFFfree(raster); return (0); } CopyField(TIFFTAG_SUBFILETYPE, longv); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_COMPRESSION, compression); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); if (compression == COMPRESSION_JPEG) TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW); CopyField(TIFFTAG_FILLORDER, shortv); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); CopyField(TIFFTAG_XRESOLUTION, floatv); CopyField(TIFFTAG_YRESOLUTION, floatv); CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); { char buf[2048]; char *cp = strrchr(TIFFFileName(in), '/'); sprintf(buf, "YCbCr conversion of %s", cp ? cp+1 : TIFFFileName(in)); TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf); } TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion()); CopyField(TIFFTAG_DOCUMENTNAME, stringv); TIFFSetField(out, TIFFTAG_REFERENCEBLACKWHITE, refBlackWhite); TIFFSetField(out, TIFFTAG_YCBCRSUBSAMPLING, horizSubSampling, vertSubSampling); TIFFSetField(out, TIFFTAG_YCBCRPOSITIONING, YCBCRPOSITION_CENTERED); TIFFSetField(out, TIFFTAG_YCBCRCOEFFICIENTS, ycbcrCoeffs); rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); return (cvtRaster(out, raster, width, height)); } static char* usageMsg[] = { "usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... output\n", "where comp is one of the following compression algorithms:\n", " jpeg\t\tJPEG encoding\n", " lzw\t\tLempel-Ziv & Welch encoding\n", " packbits\tPackBits encoding\n", " none\t\tno compression\n", "and the other options are:\n", " -r\trows/strip\n", " -h\thorizontal sampling factor (1,2,4)\n", " -v\tvertical sampling factor (1,2,4)\n", NULL }; static void usage(void) { int i; for (i = 0; usageMsg[i]; i++) fprintf(stderr, "%s", usageMsg[i]); exit(-1); } utput\n", "where comp is one of the followitiff-v3.4beta018/tools/sgi2tiff.c000444 004341 000024 00000017664 06003062766 016415 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/sgi2tiff.c,v 1.23 1995/07/01 01:16:55 sam Exp $ */ /* * Copyright (c) 1991-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) static short config = PLANARCONFIG_CONTIG; static uint16 compression = COMPRESSION_LZW; static uint16 predictor = 0; static uint16 fillorder = 0; static uint32 rowsperstrip = (uint32) -1; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ static uint16 photometric; static void usage(void); static int cpContig(IMAGE*, TIFF*); static int cpSeparate(IMAGE*, TIFF*); static int processCompressOptions(char*); /* XXX image library has no prototypes */ extern IMAGE* iopen(const char*, const char*); extern void iclose(IMAGE*); extern void getrow(IMAGE*, short*, int, int); int main(int argc, char* argv[]) { IMAGE *in; TIFF *out; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:p:r:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'f': /* fill order */ if (streq(optarg, "lsb2msb")) fillorder = FILLORDER_LSB2MSB; else if (streq(optarg, "msb2lsb")) fillorder = FILLORDER_MSB2LSB; else usage(); break; case 'p': /* planar configuration */ if (streq(optarg, "separate")) config = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) config = PLANARCONFIG_CONTIG; else usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 2) usage(); in = iopen(argv[optind], "r"); if (in == NULL) return (-1); out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-2); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) in->xsize); TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) in->ysize); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_COMPRESSION, compression); if (in->zsize == 1) photometric = PHOTOMETRIC_MINISBLACK; else photometric = PHOTOMETRIC_RGB; switch (compression) { case COMPRESSION_JPEG: if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) photometric = PHOTOMETRIC_YCBCR; TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); if (fillorder != 0) TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize); TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16) in->min); TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16) in->max); TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); if (config != PLANARCONFIG_SEPARATE) TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); else /* force 1 row/strip for library limitation */ TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L); if (in->name[0] != '\0') TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name); if (config == PLANARCONFIG_CONTIG) cpContig(in, out); else cpSeparate(in, out); (void) iclose(in); (void) TIFFClose(out); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } static int cpContig(IMAGE* in, TIFF* out) { unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); short *r = NULL; int x, y; if (in->zsize == 3) { short *g, *b; r = (short *)_TIFFmalloc(3 * in->xsize * sizeof (short)); g = r + in->xsize; b = g + in->xsize; for (y = in->ysize-1; y >= 0; y--) { unsigned char* pp = buf; getrow(in, r, y, 0); getrow(in, g, y, 1); getrow(in, b, y, 2); for (x = 0; x < in->xsize; x++) { *pp++ = r[x]; *pp++ = g[x]; *pp++ = b[x]; } if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0) goto bad; } } else { r = (short *)_TIFFmalloc(in->xsize * sizeof (short)); for (y = in->ysize-1; y >= 0; y--) { getrow(in, r, y, 0); for (x = 0; x < in->xsize; x++) buf[x] = r[x]; if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0) goto bad; } } if (r) _TIFFfree(r); _TIFFfree(buf); return (1); bad: if (r) _TIFFfree(r); _TIFFfree(buf); return (0); } static int cpSeparate(IMAGE* in, TIFF* out) { unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); short *r = (short *)_TIFFmalloc(in->xsize * sizeof (short)); int x, y, z; for (z = 0; z < in->zsize; z++) { for (y = in->ysize-1; y >= 0; y--) { getrow(in, r, y, z); for (x = 0; x < in->xsize; x++) buf[x] = r[x]; if (TIFFWriteScanline(out, buf, in->ysize-y-1, z) < 0) goto bad; } } _TIFFfree(r); _TIFFfree(buf); return (1); bad: _TIFFfree(r); _TIFFfree(buf); return (0); } char* stuff[] = { "usage: sgi2tiff [options] input.rgb output.tif", "where options are:", " -r # make each strip have no more than # rows", "", " -p contig pack samples contiguously (e.g. RGBRGB...)", " -p separate store samples separately (e.g. RRR...GGG...BBB...)", "", " -f lsb2msb force lsb-to-msb FillOrder for output", " -f msb2lsb force msb-to-lsb FillOrder for output", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c jpeg[:opts]compress output with JPEG encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } ith packbits encoding", " -c none use no compression algorithm on output", "tiff-v3.4beta018/tools/sgigt.c000444 004341 000024 00000056104 06003062767 016006 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/sgigt.c,v 1.64 1995/06/21 15:40:54 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include typedef unsigned char u_char; #endif #include #include #include "tiffio.h" #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif /* XXX fudge adjustment for window borders */ #define YFUDGE 20 #define XFUDGE 20 static tileContigRoutine putContig; static tileSeparateRoutine putSeparate; static uint32 width, height; /* window width & height */ static uint32* raster = NULL; /* displayable image */ extern Colorindex greyi(int); static void setupColormapSupport(TIFFRGBAImage*); static void putContigAndDraw(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*); static void putSeparateAndDraw(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, unsigned char*, unsigned char*, unsigned char*, unsigned char*); static int prevImage(char* argv[], int ix, int b, int e, int wrap); static int nextImage(char* argv[], int ix, int b, int e, int wrap); static void usage(void); static uint16 photoArg(const char*); static void beep(void); int main(int argc, char* argv[]) { static Cursor hourglass = { 0x1ff0, 0x1ff0, 0x0820, 0x0820, 0x0820, 0x0c60, 0x06c0, 0x0100, 0x0100, 0x06c0, 0x0c60, 0x0820, 0x0820, 0x0820, 0x1ff0, 0x1ff0 }; int isRGB0 = -1, isRGB; int verbose = 0; int stoponerr = 0; /* stop on read error */ char* filename; TIFF* tif = NULL; int fg = 0; int c; int dirnum = -1; int order0 = 0, order; uint32 diroff = 0; uint16 photo0 = (uint16) -1, photo; long x, y, xmax, ymax; int ix, nix; TIFFErrorHandler oerror = TIFFSetErrorHandler(NULL); TIFFErrorHandler owarning = TIFFSetWarningHandler(NULL); uint32 w, h; long wid = -1; while ((c = getopt(argc, argv, "d:o:p:cerflmsvw")) != -1) switch (c) { case 'c': isRGB0 = 0; break; case 'd': dirnum = atoi(optarg); break; case 'e': oerror = TIFFSetErrorHandler(oerror); break; case 'f': fg = 1; break; case 'l': order0 = FILLORDER_LSB2MSB; break; case 'm': order0 = FILLORDER_MSB2LSB; break; case 'o': diroff = strtoul(optarg, NULL, 0); break; case 'p': photo0 = photoArg(optarg); break; case 'r': isRGB0 = 1; break; case 's': stoponerr = 1; break; case 'w': owarning = TIFFSetWarningHandler(owarning); break; case 'v': verbose = 1; break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 1) usage(); xmax = getgdesc(GD_XPMAX) - XFUDGE; ymax = getgdesc(GD_YPMAX) - YFUDGE; ix = optind; do { tif = TIFFOpen(argv[ix], "r"); } while (tif == NULL && (ix = nextImage(argv, ix, optind, argc, FALSE))); if (tif == NULL) exit(0); if (ix == optind) { /* * Set initial directory if user-specified * file was opened successfully. */ if (dirnum != -1 && !TIFFSetDirectory(tif, dirnum)) TIFFError(argv[ix], "Error, seeking to directory %d", dirnum); if (diroff != 0 && !TIFFSetSubDirectory(tif, diroff)) TIFFError(argv[ix], "Error, setting subdirectory at %#x", diroff); } isRGB = isRGB0; order = order0; photo = photo0; goto newfile0; for (;;) { TIFFRGBAImage img; char title[1024]; /* window title line */ const char* cp; int isrgb; if (order) TIFFSetField(tif, TIFFTAG_FILLORDER, order); if (photo != (uint16) -1) TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { TIFFError(filename, title); goto bad2; } /* * Use a full-color window if the image is * full color or a palette image and the * hardware support is present. */ isrgb = isRGB; if (isrgb == -1) isrgb = (img.bitspersample >= 8 && (img.photometric == PHOTOMETRIC_RGB || img.photometric == PHOTOMETRIC_YCBCR || img.photometric == PHOTOMETRIC_SEPARATED || img.photometric == PHOTOMETRIC_PALETTE)); /* * Check to see if the hardware can display 24-bit RGB. */ if (isrgb && getgdesc(GD_BITS_NORM_SNG_RED) < img.bitspersample && !getgdesc(GD_DITHER)) { if (verbose) printf("Warning, display is incapable of full RGB,%s\n", " using dithered colormap"); isrgb = 0; } /* * Colormap-based display is done by overriding the put * routine to install a private method that understands * how to convert RGBA values to suitable colormap indices. */ if (!isrgb) setupColormapSupport(&img); /* * Override default ``put routine'' with private * routine that also draws the raster on the display. */ if (img.put.any == 0) { TIFFError(filename, "No \"put\" routine; must not handle image format"); goto bad3; } if (img.isContig) { putContig = img.put.contig; img.put.contig = putContigAndDraw; } else { putSeparate = img.put.separate; img.put.separate = putSeparateAndDraw; } /* * Setup the image raster as required. */ if ((w = img.width) > xmax) w = xmax; if ((h = img.height) > ymax) h = ymax; if (w != width || h != height) { if (raster != NULL) _TIFFfree(raster), raster = NULL; raster = (uint32*) _TIFFmalloc(w * h * sizeof (uint32)); if (raster == 0) { width = height = 0; TIFFError(filename, "No space for raster buffer"); goto bad3; } width = w; height = h; } /* * Create a new window or reconfigure an existing * one to suit the image to be displayed. */ if (wid < 0) { x = (xmax+XFUDGE-width)/2; y = (ymax+YFUDGE-height)/2; prefposition(x, x+width-1, y, y+height-1); cp = strrchr(filename, '/'); sprintf(title, "%s [%u] %s", cp == NULL ? filename : cp+1, (unsigned int) TIFFCurrentDirectory(tif), isrgb ? " rgb" : " cmap"); if (fg) foreground(); wid = winopen(title); if (wid < 0) { TIFFError(filename, "Can not create window"); TIFFRGBAImageEnd(&img); break; } curstype(C16X1); defcursor(1, hourglass); qdevice(LEFTMOUSE); qdevice(MIDDLEMOUSE); qdevice(RIGHTMOUSE); qdevice(KEYBD); qdevice(PAGEUPKEY); qdevice(PAGEDOWNKEY); qdevice(HOMEKEY); qdevice(ENDKEY); } else { x = (xmax+XFUDGE-width)/2; y = (ymax+YFUDGE-height)/2; winposition(x, x+width-1, y, y+height-1); viewport(0, width-1, 0, height-1); cp = strrchr(filename, '/'); sprintf(title, "%s [%u] %s", cp == NULL ? filename : cp+1, (unsigned int) TIFFCurrentDirectory(tif), isrgb ? " rgb" : " cmap"); wintitle(title); } singlebuffer(); if (isrgb) { RGBmode(); gconfig(); } else { cmode(); gconfig(); } /* * Fetch the image. */ setcursor(1, 0, 0); greyi(225); clear(); (void) TIFFRGBAImageGet(&img, raster, width, height); setcursor(0, 0, 0); /* * Process input. */ for (;;) { short val; switch (qread(&val)) { case KEYBD: switch (val) { case 'b': /* photometric MinIsBlack */ photo = PHOTOMETRIC_MINISBLACK; goto newpage; case 'l': /* lsb-to-msb FillOrder */ order = FILLORDER_LSB2MSB; goto newpage; case 'm': /* msb-to-lsb FillOrder */ order = FILLORDER_MSB2LSB; goto newpage; case 'c': /* colormap visual */ isRGB = 0; goto newpage; case 'r': /* RGB visual */ isRGB = 1; goto newpage; case 'w': /* photometric MinIsWhite */ photo = PHOTOMETRIC_MINISWHITE; goto newpage; case 'W': /* toggle warnings */ owarning = TIFFSetWarningHandler(owarning); goto newpage; case 'E': /* toggle errors */ oerror = TIFFSetErrorHandler(oerror); goto newpage; case 'z': /* reset to defaults */ case 'Z': order = order0; photo = photo0; isRGB = isRGB0; if (owarning == NULL) owarning = TIFFSetWarningHandler(NULL); if (oerror == NULL) oerror = TIFFSetErrorHandler(NULL); goto newpage; case 'q': /* exit */ case '\033': TIFFRGBAImageEnd(&img); goto done; } break; case PAGEUPKEY: /* previous logical image */ if (val) { if (TIFFCurrentDirectory(tif) > 0) { if (TIFFSetDirectory(tif, TIFFCurrentDirectory(tif)-1)) goto newpage; beep(); /* XXX */ } else { ix = prevImage(argv, ix, optind, argc, TRUE); /* XXX set directory to last image in new file */ goto newfile; } } break; case PAGEDOWNKEY: /* next logical image */ if (val) { if (!TIFFLastDirectory(tif)) { if (TIFFReadDirectory(tif)) goto newpage; beep(); /* XXX */ } else { ix = nextImage(argv, ix, optind, argc, TRUE); goto newfile; } } break; case HOMEKEY: /* 1st image in current file */ if (val) { if (TIFFSetDirectory(tif, 0)) goto newpage; beep(); } break; case ENDKEY: /* last image in current file */ if (val) { /* XXX */ beep(); } break; case RIGHTMOUSE: /* previous file */ if (val) { if (nix = prevImage(argv, ix, optind, argc, FALSE)) { ix = nix; goto newfile; } beep(); } break; case LEFTMOUSE: /* next file */ if (val) { if (nix = nextImage(argv, ix, optind, argc, FALSE)) { ix = nix; goto newfile; } beep(); } break; case MIDDLEMOUSE: /* first file */ if (val) { if (nix = nextImage(argv, optind-1, optind, argc, FALSE)) { ix = nix; goto newfile; } beep(); } break; case REDRAW: lrectwrite(0, 0, width-1, height-1, raster); break; } } newfile: TIFFRGBAImageEnd(&img); if (tif != NULL && argv[ix] != filename) TIFFClose(tif), tif = NULL; /* fall thru... */ newfile0: if (argv[ix] == NULL) break; filename = argv[ix]; if (tif == NULL) { tif = TIFFOpen(filename, "r"); if (tif == NULL) goto bad1; isRGB = isRGB0; order = order0; photo = photo0; } continue; newpage: TIFFRGBAImageEnd(&img); continue; bad3: TIFFRGBAImageEnd(&img); bad2: TIFFClose(tif), tif = NULL; bad1: argv[ix] = NULL; /* don't revisit file */ ix = nextImage(argv, ix, optind, argc, TRUE); goto newfile0; } done: if (wid >= 0) winclose(wid); if (raster != NULL) _TIFFfree(raster); if (tif != NULL) TIFFClose(tif); return (0); } static int prevImage(char* argv[], int ix, int b, int e, int wrap) { int i; for (i = ix-1; i >= b && argv[i] == NULL; i--) ; if (i < b) { if (wrap) { for (i = e-1; i > ix && argv[i] == NULL; i--) ; } else i = 0; } return (i); } static int nextImage(char* argv[], int ix, int b, int e, int wrap) { int i; for (i = ix+1; i < e && argv[i] == NULL; i++) ; if (i >= e) { if (wrap) { for (i = b; i < ix && argv[i] == NULL; i++) ; } else i = 0; } return (i); } static void beep(void) { greyi(0); clear(); sginap(5); lrectwrite(0, 0, width-1, height-1, raster); } char* stuff[] = { "usage: tiffgt [options] file.tif", "where options are:", " -c use colormap visual", " -d dirnum set initial directory (default is 0)", " -e enable display of TIFF error messages", " -f run program in the foreground", " -l force lsb-to-msb FillOrder", " -m force msb-to-lsb FillOrder", " -o offset set initial directory offset", " -p photo override photometric interpretation", " -r use fullcolor visual", " -s stop decoding on first error (default is ignore errors)", " -v enable verbose mode", " -w enable display of TIFF warning messages", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } static uint16 photoArg(const char* arg) { if (strcmp(arg, "miniswhite") == 0) return (PHOTOMETRIC_MINISWHITE); else if (strcmp(arg, "minisblack") == 0) return (PHOTOMETRIC_MINISBLACK); else if (strcmp(arg, "rgb") == 0) return (PHOTOMETRIC_RGB); else if (strcmp(arg, "palette") == 0) return (PHOTOMETRIC_PALETTE); else if (strcmp(arg, "mask") == 0) return (PHOTOMETRIC_MASK); else if (strcmp(arg, "separated") == 0) return (PHOTOMETRIC_SEPARATED); else if (strcmp(arg, "ycbcr") == 0) return (PHOTOMETRIC_YCBCR); else if (strcmp(arg, "cielab") == 0) return (PHOTOMETRIC_CIELAB); else return ((uint16) -1); } static void putContigAndDraw(TIFFRGBAImage* img, uint32* raster, uint32 x, uint32 y, uint32 w, uint32 h, int32 fromskew, int32 toskew, unsigned char* cp) { (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); if (x+w == width) { w = width; if (img->orientation == ORIENTATION_TOPLEFT) lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w); else lrectwrite(0, y, w-1, y+h-1, raster); } } static void putSeparateAndDraw(TIFFRGBAImage* img, uint32* raster, uint32 x, uint32 y, uint32 w, uint32 h, int32 fromskew, int32 toskew, unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) { (*putSeparate)(img, raster, x, y, w, h, fromskew, toskew, r, g, b, a); if (x+w == width) { w = width; if (img->orientation == ORIENTATION_TOPLEFT) lrectwrite(x, y-(h-1), w-1, y, raster-x-(h-1)*w); else lrectwrite(x, y, w-1, y+h-1, raster); } } /* * {red,green,blue}_inverse are tables in libgutil.a that * do an inverse map from (r,g,b) to the closest colormap * index in the "standard" GL colormap. grey_inverse is * the equivalent map for mapping greyscale values to * colormap indices. We access these maps directly instead * of through the rgbi and greyi functions to avoid the * additional overhead of the color calls that they make. */ extern u_char red_inverse[256]; extern u_char green_inverse[256]; extern u_char blue_inverse[256]; extern u_char grey_inverse[256]; #define greyi(g) grey_inverse[g] static u_char rgbi(u_char r, u_char g, u_char b) { return (r == g && g == b ? grey_inverse[r] : red_inverse[r] + green_inverse[g] + blue_inverse[b]); } /* * The following routines move decoded data returned * from the TIFF library into rasters that are suitable * for passing to lrecwrite. They do the necessary * conversions for when a colormap drawing mode is used. */ #define REPEAT8(op) REPEAT4(op); REPEAT4(op) #define REPEAT4(op) REPEAT2(op); REPEAT2(op) #define REPEAT2(op) op; op #define CASE8(x,op) \ switch (x) { \ case 7: op; case 6: op; case 5: op; \ case 4: op; case 3: op; case 2: op; \ case 1: op; \ } #define CASE4(x,op) switch (x) { case 3: op; case 2: op; case 1: op; } #define NOP #define UNROLL8(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 8; _x -= 8) { \ op1; \ REPEAT8(op2); \ } \ if (_x > 0) { \ op1; \ CASE8(_x,op2); \ } \ } #define UNROLL4(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 4; _x -= 4) { \ op1; \ REPEAT4(op2); \ } \ if (_x > 0) { \ op1; \ CASE4(_x,op2); \ } \ } #define UNROLL2(w, op1, op2) { \ uint32 _x; \ for (_x = w; _x >= 2; _x -= 2) { \ op1; \ REPEAT2(op2); \ } \ if (_x) { \ op1; \ op2; \ } \ } #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } #define DECLAREContigPutFunc(name) \ static void name(\ TIFFRGBAImage* img, \ uint32* cp, \ uint32 x, uint32 y, \ uint32 w, uint32 h, \ int32 fromskew, int32 toskew, \ u_char* pp \ ) #define DECLARESepPutFunc(name) \ static void name(\ TIFFRGBAImage* img,\ uint32* cp,\ uint32 x, uint32 y, \ uint32 w, uint32 h,\ int32 fromskew, int32 toskew,\ u_char* r, u_char* g, u_char* b, u_char* a\ ) static tileContigRoutine libput; /* * 8-bit packed samples => colormap */ DECLAREContigPutFunc(putcontig8bittile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; (void) y; fromskew *= samplesperpixel; if (Map) { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = rgbi(Map[pp[0]], Map[pp[1]], Map[pp[2]]); pp += samplesperpixel; } cp += toskew; pp += fromskew; } } else { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = rgbi(pp[0], pp[1], pp[2]); pp += samplesperpixel; } cp += toskew; pp += fromskew; } } } /* * Convert 8-bit packed samples => colormap */ DECLAREContigPutFunc(cvtcontig8bittile) { (*libput)(img, cp, x, y, w, h, fromskew, toskew, pp); while (h-- > 0) { UNROLL8(w, NOP, cp[0] = rgbi(TIFFGetR(cp[0]),TIFFGetG(cp[0]),TIFFGetB(cp[0])); cp++ ); cp += toskew; } } /* * 16-bit packed samples => colormap */ DECLAREContigPutFunc(putcontig16bittile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; (void) y; fromskew *= samplesperpixel; if (Map) { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = rgbi(Map[pp[0]], Map[pp[1]], Map[pp[2]]); pp += samplesperpixel; } cp += toskew; pp += fromskew; } } else { while (h-- > 0) { for (x = w; x-- > 0;) { *cp++ = rgbi(pp[0], pp[1], pp[2]); pp += samplesperpixel; } cp += toskew; pp += fromskew; } } } /* * 8-bit unpacked samples => colormap */ DECLARESepPutFunc(putseparate8bittile) { TIFFRGBValue* Map = img->Map; (void) y; (void) a; if (Map) { while (h-- > 0) { for (x = w; x-- > 0;) *cp++ = rgbi(Map[*r++], Map[*g++], Map[*b++]); SKEW(r, g, b, fromskew); cp += toskew; } } else { while (h-- > 0) { for (x = w; x-- > 0;) *cp++ = rgbi(*r++, *g++, *b++); SKEW(r, g, b, fromskew); cp += toskew; } } } /* * 16-bit unpacked samples => colormap */ DECLARESepPutFunc(putseparate16bittile) { TIFFRGBValue* Map = img->Map; (void) y; (void) a; if (Map) { while (h-- > 0) { for (x = 0; x < w; x++) *cp++ = rgbi(Map[*r++], Map[*g++], Map[*b++]); SKEW(r, g, b, fromskew); cp += toskew; } } else { while (h-- > 0) { for (x = 0; x < w; x++) *cp++ = rgbi(*r++, *g++, *b++); SKEW(r, g, b, fromskew); cp += toskew; } } } /* * 8-bit packed CMYK samples => cmap * * NB: The conversion of CMYK->RGB is *very* crude. */ DECLAREContigPutFunc(putcontig8bitCMYKtile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; uint16 r, g, b, k; (void) y; fromskew *= samplesperpixel; if (Map) { while (h-- > 0) { for (x = w; x-- > 0;) { k = 255 - pp[3]; r = (k*(255-pp[0]))/255; g = (k*(255-pp[1]))/255; b = (k*(255-pp[2]))/255; *cp++ = rgbi(Map[r], Map[g], Map[b]); pp += samplesperpixel; } pp += fromskew; cp += toskew; } } else { while (h-- > 0) { UNROLL8(w, NOP, k = 255 - pp[3]; r = (k*(255-pp[0]))/255; g = (k*(255-pp[1]))/255; b = (k*(255-pp[2]))/255; *cp++ = rgbi(r, g, b); pp += samplesperpixel); cp += toskew; pp += fromskew; } } } #define YCbCrtoRGB(dst, yc) { \ int Y = (yc); \ dst = rgbi( \ clamptab[Y+Crrtab[Cr]], \ clamptab[Y + (int)((Cbgtab[Cb]+Crgtab[Cr])>>16)], \ clamptab[Y+Cbbtab[Cb]]); \ } #define YCbCrSetup \ TIFFYCbCrToRGB* ycbcr = img->ycbcr; \ int* Crrtab = ycbcr->Cr_r_tab; \ int* Cbbtab = ycbcr->Cb_b_tab; \ int32* Crgtab = ycbcr->Cr_g_tab; \ int32* Cbgtab = ycbcr->Cb_g_tab; \ TIFFRGBValue* clamptab = ycbcr->clamptab /* * 8-bit packed YCbCr samples w/ 2,2 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { YCbCrSetup; uint32* cp1 = cp+w+toskew; u_int incr = 2*toskew+w; (void) y; /* XXX adjust fromskew */ for (; h >= 2; h -= 2) { x = w>>1; do { int Cb = pp[4]; int Cr = pp[5]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); YCbCrtoRGB(cp1[0], pp[2]); YCbCrtoRGB(cp1[1], pp[3]); cp += 2, cp1 += 2; pp += 6; } while (--x); cp += incr, cp1 += incr; pp += fromskew; } } #undef YCbCrSetup #undef YCbCrtoRGB /* * Setup to handle conversion for display in a colormap * window. Many cases are handled by massaging the mapping * tables used by the normal library code to convert 32-bit * packed RGBA samples into colormap indices. Other cases * are handled with special-case routines that replace the * normal ``put routine'' installed by the library. */ static void setupColormapSupport(TIFFRGBAImage* img) { int bitspersample = img->bitspersample; int i; if (img->BWmap) { i = 255; do { uint32* p = img->BWmap[i]; switch (bitspersample) { #define GREY(x) p[x] = greyi(TIFFGetR(p[x])) case 1: GREY(7); GREY(6); GREY(5); GREY(4); case 2: GREY(3); GREY(2); case 4: GREY(1); case 8: GREY(0); } #undef GREY } while (i--); } else if (img->PALmap) { i = 255; do { uint32 rgb; uint32* p = img->PALmap[i]; #define CMAP(x) \ (rgb = p[x], p[x] = rgbi(TIFFGetR(rgb),TIFFGetG(rgb),TIFFGetB(rgb))) switch (bitspersample) { case 1: CMAP(7); CMAP(6); CMAP(5); CMAP(4); case 2: CMAP(3); CMAP(2); case 4: CMAP(1); case 8: CMAP(0); } #undef CMAP } while (i--); } else if (img->isContig) { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (bitspersample) { case 8: img->put.contig = putcontig8bittile; break; case 16: img->put.contig = putcontig16bittile; break; } break; case PHOTOMETRIC_SEPARATED: switch (bitspersample) { case 8: img->put.contig = putcontig8bitCMYKtile; break; } break; case PHOTOMETRIC_YCBCR: if (img->bitspersample == 8) { uint16 hs, vs; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); switch ((hs<<4)|vs) { case 0x22: /* most common case */ img->put.contig = putcontig8bitYCbCr22tile; break; default: /* all others cost more */ libput = img->put.contig; img->put.contig = cvtcontig8bittile; break; } } break; } } else { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: img->put.separate = putseparate8bittile; break; case 16: img->put.separate = putseparate16bittile; break; } break; } } } <<4)|vs) { case 0x22: /* most common case */ img->put.contig = putcontig8bitYCbCr22tile; break; default: /* all others cost more */ libput = img->put.contig; img->put.contig = cvtcontig8bittile; break; } } break; } } else { switch (img->photometric) { case PHOTOMETRIC_RGB: switch (img->bitspersample) { case 8: img->put.separate = putseparate8bittile; break; case 16: img->put.setiff-v3.4beta018/tools/sgisv.c000444 004341 000024 00000021000 06003062767 016007 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/sgisv.c,v 1.22 1995/06/06 23:45:26 sam Exp $ */ /* * Copyright (c) 1990-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include typedef unsigned char u_char; typedef unsigned long u_long; #endif #include #include #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) uint32 rowsperstrip = (uint32) -1; uint16 compression = COMPRESSION_LZW; uint16 config = PLANARCONFIG_CONTIG; uint16 predictor = 0; int xmaxscreen; int ymaxscreen; uint16 photometric = PHOTOMETRIC_RGB; int jpegcolormode = JPEGCOLORMODE_RGB; int quality = 75; /* JPEG quality */ static void usage(void); static void tiffsv(char*, int, int, int, int); int main(int argc, char* argv[]) { int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:p:r:")) != -1) switch (c) { case 'b': /* save as b&w */ photometric = PHOTOMETRIC_MINISBLACK; break; case 'c': /* compression scheme */ if (streq(optarg, "none")) compression = COMPRESSION_NONE; else if (streq(optarg, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(optarg, "jpeg", 4)) { char* cp = strchr(optarg, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(optarg, "lzw", 3)) { char* cp = strchr(optarg, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else usage(); break; case 'p': /* planar configuration */ if (streq(optarg, "separate")) config = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) config = PLANARCONFIG_CONTIG; else usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 1 && argc - optind != 5) usage(); xmaxscreen = getgdesc(GD_XPMAX)-1; ymaxscreen = getgdesc(GD_YPMAX)-1; foreground(); noport(); winopen("tiffsv"); if (argc - optind == 5) tiffsv(argv[optind], atoi(argv[optind+1]), atoi(argv[optind+2]), atoi(argv[optind+3]), atoi(argv[optind+4])); else tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen); return (0); } char* stuff[] = { "usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]", "where options are:", " -p contig pack samples contiguously (e.g. RGBRGB...)", " -p separate store samples separately (e.g. RRR...GGG...BBB...)", "", " -r # make each strip have no more than # rows", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c jpeg[:opts]compress output with JPEG encoding", " -c packbits compress output with packbits encoding", " -c g3[:opts] compress output with CCITT Group 3 encoding", " -c g4 compress output with CCITT Group 4 encoding", " -c none use no compression algorithm on output", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "", "LZW options:", " # set predictor value for Lempel-Ziv & Welch encoding", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } static void svRGBSeparate(TIFF* tif, u_long* ss, int xsize, int ysize) { tsize_t stripsize = TIFFStripSize(tif); u_char *rbuf = (u_char *)_TIFFmalloc(3*stripsize); u_char *gbuf = rbuf + stripsize; u_char *bbuf = gbuf + stripsize; register int y; for (y = 0; y <= ysize; y += rowsperstrip) { u_char *rp, *gp, *bp; register int x; register uint32 n; n = rowsperstrip; if (n > ysize-y+1) n = ysize-y+1; rp = rbuf; gp = gbuf; bp = bbuf; do { for (x = 0; x <= xsize; x++) { u_long v = ss[x]; rp[x] = v; gp[x] = v >> 8; bp[x] = v >> 16; } rp += xsize+1, gp += xsize+1, bp += xsize+1; ss += xsize+1; } while (--n); if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0), rbuf, stripsize) < 0) break; if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,1), gbuf, stripsize) < 0) break; if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,2), bbuf, stripsize) < 0) break; } _TIFFfree(rbuf); } static void svRGBContig(TIFF* tif, u_long* ss, int xsize, int ysize) { register int x, y; tsize_t stripsize = TIFFStripSize(tif); u_char *strip = (u_char *)_TIFFmalloc(stripsize); for (y = 0; y <= ysize; y += rowsperstrip) { register u_char *pp = strip; register uint32 n; n = rowsperstrip; if (n > ysize-y+1) n = ysize-y+1; do { for (x = 0; x <= xsize; x++) { u_long v = ss[x]; pp[0] = v; pp[1] = v >> 8; pp[2] = v >> 16; pp += 3; } ss += xsize+1; } while (--n); if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0), strip, stripsize) < 0) break; } _TIFFfree(strip); } #undef RED #undef GREEN #undef BLUE #define CVT(x) (((x)*255)/100) #define RED CVT(28) /* 28% */ #define GREEN CVT(59) /* 59% */ #define BLUE CVT(11) /* 11% */ static void svGrey(TIFF* tif, u_long* ss, int xsize, int ysize) { register int x, y; u_char *buf = (u_char *)_TIFFmalloc(TIFFScanlineSize(tif)); for (y = 0; y <= ysize; y++) { for (x = 0; x <= xsize; x++) { u_char *cp = (u_char *)&ss[x]; buf[x] = (RED*cp[3] + GREEN*cp[2] + BLUE*cp[1]) >> 8; } if (TIFFWriteScanline(tif, buf, (uint32) y, 0) < 0) break; ss += xsize+1; } _TIFFfree(buf); } #define MIN(a,b) ((a)<(b)?(a):(b)) #define ABS(x) ((x)<0?-(x):(x)) static void tiffsv(char* name, int x1, int x2, int y1, int y2) { TIFF *tif; int xsize, ysize; int xorg, yorg; u_long *scrbuf; xorg = MIN(x1,x2); yorg = MIN(y1,y2); if (xorg<0) xorg = 0; if (yorg<0) yorg = 0; xsize = ABS(x2-x1); ysize = ABS(y2-y1); if (xorg+xsize > xmaxscreen) xsize = xmaxscreen-xorg; if (yorg+ysize > ymaxscreen) ysize = ymaxscreen-yorg; tif = TIFFOpen(name, "w"); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) (xsize+1)); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) (ysize+1)); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, photometric == PHOTOMETRIC_RGB ? 3 : 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config); TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_JPEG: if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) photometric = PHOTOMETRIC_YCBCR; TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: if (predictor != 0) TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); break; } TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT); rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); scrbuf = (u_long *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (u_long)); readdisplay(xorg, yorg, xorg+xsize, yorg+ysize, scrbuf, RD_FREEZE); if (photometric == PHOTOMETRIC_RGB) { if (config == PLANARCONFIG_SEPARATE) svRGBSeparate(tif, scrbuf, xsize, ysize); else svRGBContig(tif, scrbuf, xsize, ysize); } else svGrey(tif, scrbuf, xsize, ysize); (void) TIFFClose(tif); _TIFFfree((char *)scrbuf); } tiff-v3.4beta018/tools/thumbnail.c000444 004341 000024 00000036742 06003062770 016654 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/thumbnail.c,v 1.8 1995/06/06 23:45:26 sam Exp $ */ /* * Copyright (c) 1994-1995 Sam Leffler * Copyright (c) 1994-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include "tiffio.h" #define streq(a,b) (strcasecmp(a,b) == 0) #ifndef howmany #define howmany(x, y) (((x)+((y)-1))/(y)) #endif typedef enum { EXP50, EXP60, EXP70, EXP80, EXP90, EXP, LINEAR } Contrast; static uint32 tnw = 216; /* thumbnail width */ static uint32 tnh = 274; /* thumbnail height */ static Contrast contrast = LINEAR; /* current contrast */ static u_char* thumbnail; static int cpIFD(TIFF*, TIFF*); static int generateThumbnail(TIFF*, TIFF*); static void initScale(); static void usage(void); extern int optind; int main(int argc, char* argv[]) { TIFF* in; TIFF* out; int c; while ((c = getopt(argc, argv, "w:h:c:")) != -1) { switch (c) { case 'w': tnw = strtoul(optarg, NULL, 0); break; case 'h': tnh = strtoul(optarg, NULL, 0); break; case 'c': contrast = streq(optarg, "exp50") ? EXP50 : streq(optarg, "exp60") ? EXP60 : streq(optarg, "exp70") ? EXP70 : streq(optarg, "exp80") ? EXP80 : streq(optarg, "exp90") ? EXP90 : streq(optarg, "exp") ? EXP : streq(optarg, "linear")? LINEAR : EXP; break; default: usage(); } } if (argc-optind != 2) usage(); thumbnail = (u_char*) _TIFFmalloc(tnw * tnh); out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-2); in = TIFFOpen(argv[optind], "r"); if (in != NULL) { initScale(); do { if (!generateThumbnail(in, out)) goto bad; if (!cpIFD(in, out) || !TIFFWriteDirectory(out)) goto bad; } while (TIFFReadDirectory(in)); (void) TIFFClose(in); } (void) TIFFClose(out); return (0); bad: (void) TIFFClose(out); return (1); } #define CopyField1(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) #define CopyField4(tag, v1, v2, v3, v4) \ if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { uint16 shortv, shortv2, *shortav; float floatv, *floatav; char *stringv; uint32 longv; switch (type) { case TIFF_SHORT: if (count == 1) { CopyField1(tag, shortv); } else if (count == 2) { CopyField2(tag, shortv, shortv2); } else if (count == (uint16) -1) { CopyField2(tag, shortv, shortav); } break; case TIFF_LONG: CopyField1(tag, longv); break; case TIFF_RATIONAL: if (count == 1) { CopyField1(tag, floatv); } else if (count == (uint16) -1) { CopyField1(tag, floatav); } break; case TIFF_ASCII: CopyField1(tag, stringv); break; } } #undef CopyField4 #undef CopyField3 #undef CopyField2 #undef CopyField1 static struct cpTag { uint16 tag; uint16 count; TIFFDataType type; } tags[] = { { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, { TIFFTAG_IMAGELENGTH, 1, TIFF_LONG }, { TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT }, { TIFFTAG_COMPRESSION, 1, TIFF_SHORT }, { TIFFTAG_FILLORDER, 1, TIFF_SHORT }, { TIFFTAG_SAMPLESPERPIXEL, 1, TIFF_SHORT }, { TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG }, { TIFFTAG_PLANARCONFIG, 1, TIFF_SHORT }, { TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG }, { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, { TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT }, { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, { TIFFTAG_MAKE, 1, TIFF_ASCII }, { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, { TIFFTAG_INKSET, 1, TIFF_SHORT }, { TIFFTAG_INKNAMES, 1, TIFF_ASCII }, { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) cpTag(in, out, p->tag, p->count, p->type); } #undef NTAGS static int cpStrips(TIFF* in, TIFF* out) { tsize_t bufsize = TIFFStripSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 *bytecounts; TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); for (s = 0; s < ns; s++) { if (bytecounts[s] > bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]); if (!buf) return (0); bufsize = bytecounts[s]; } if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 || TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) { _TIFFfree(buf); return (0); } } _TIFFfree(buf); return (1); } return (0); } static int cpTiles(TIFF* in, TIFF* out) { tsize_t bufsize = TIFFTileSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); uint32 *bytecounts; TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); for (t = 0; t < nt; t++) { if (bytecounts[t] > bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]); if (!buf) return (0); bufsize = bytecounts[t]; } if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 || TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) { _TIFFfree(buf); return (0); } } _TIFFfree(buf); return (1); } return (0); } static int cpIFD(TIFF* in, TIFF* out) { cpTags(in, out); if (TIFFIsTiled(in)) { if (!cpTiles(in, out)) return (0); } else { if (!cpStrips(in, out)) return (0); } return (1); } static uint16 photometric; /* current photometric of raster */ static u_short filterWidth; /* filter width in pixels */ static u_short stepSrcWidth; /* src image stepping width */ static u_short stepDstWidth; /* dest stepping width */ static u_char* src0; /* horizontal bit stepping (start) */ static u_char* src1; /* horizontal bit stepping (middle) */ static u_char* src2; /* horizontal bit stepping (end) */ static u_short* rowoff; /* row offset for stepping */ static u_char cmap[256]; /* colormap indexes */ static u_char bits[256]; /* count of bits set */ static void setupBitsTables() { int i; for (i = 0; i < 256; i++) { int n = 0; if (i&0x01) n++; if (i&0x02) n++; if (i&0x04) n++; if (i&0x08) n++; if (i&0x10) n++; if (i&0x20) n++; if (i&0x40) n++; if (i&0x80) n++; bits[i] = n; } } static int clamp(float v, int low, int high) { return (v < low ? low : v > high ? high : (int)v); } #ifndef M_E #define M_E 2.7182818284590452354 #endif static void expFill(float pct[], u_int p, u_int n) { u_int i; u_int c = (p * n) / 100; for (i = 1; i < c; i++) pct[i] = 1-exp(i/((double)(n-1)))/ M_E; for (; i < n; i++) pct[i] = 0.; } static void setupCmap() { float pct[256]; /* known to be large enough */ u_int i; pct[0] = 1; /* force white */ switch (contrast) { case EXP50: expFill(pct, 50, 256); break; case EXP60: expFill(pct, 60, 256); break; case EXP70: expFill(pct, 70, 256); break; case EXP80: expFill(pct, 80, 256); break; case EXP90: expFill(pct, 90, 256); break; case EXP: expFill(pct, 100, 256); break; case LINEAR: for (i = 1; i < 256; i++) pct[i] = 1-((float)i)/(256-1); break; } switch (photometric) { case PHOTOMETRIC_MINISWHITE: for (i = 0; i < 256; i++) cmap[i] = clamp(255*pct[(256-1)-i], 0, 255); break; case PHOTOMETRIC_MINISBLACK: for (i = 0; i < 256; i++) cmap[i] = clamp(255*pct[i], 0, 255); break; } } static void initScale() { src0 = (u_char*) _TIFFmalloc(sizeof (u_char) * tnw); src1 = (u_char*) _TIFFmalloc(sizeof (u_char) * tnw); src2 = (u_char*) _TIFFmalloc(sizeof (u_char) * tnw); rowoff = (u_short*) _TIFFmalloc(sizeof (u_short) * tnw); filterWidth = 0; stepDstWidth = stepSrcWidth = 0; setupBitsTables(); } /* * Calculate the horizontal accumulation parameteres * according to the widths of the src and dst images. */ static void setupStepTables(u_short sw) { if (stepSrcWidth != sw || stepDstWidth != tnw) { int step = sw; int limit = tnw; int err = 0; u_int sx = 0; u_int x; int fw; u_char b; for (x = 0; x < tnw; x++) { u_int sx0 = sx; err += step; while (err >= limit) { err -= limit; sx++; } rowoff[x] = sx0 >> 3; fw = sx - sx0; /* width */ b = (fw < 8) ? 0xff<<(8-fw) : 0xff; src0[x] = b >> (sx0&7); fw -= 8 - (sx0&7); if (fw < 0) fw = 0; src1[x] = fw >> 3; fw -= (fw>>3)<<3; src2[x] = 0xff << (8-fw); } stepSrcWidth = sw; stepDstWidth = tnw; } } static void setrow(u_char* row, int nrows, const u_char* rows[]) { u_int x; u_int area = nrows * filterWidth; for (x = 0; x < tnw; x++) { u_int mask0 = src0[x]; u_int fw = src1[x]; u_int mask1 = src1[x]; u_int off = rowoff[x]; u_int acc = 0; u_int y, i; for (y = 0; y < nrows; y++) { const u_char* src = rows[y] + off; acc += bits[*src++ & mask0]; switch (fw) { default: for (i = fw; i > 8; i--) acc += bits[*src++]; /* fall thru... */ case 8: acc += bits[*src++]; case 7: acc += bits[*src++]; case 6: acc += bits[*src++]; case 5: acc += bits[*src++]; case 4: acc += bits[*src++]; case 3: acc += bits[*src++]; case 2: acc += bits[*src++]; case 1: acc += bits[*src++]; case 0: break; } acc += bits[*src & mask1]; } *row++ = cmap[(255*acc)/area]; } } /* * Install the specified image. The * image is resized to fit the display page using * a box filter. The resultant pixels are mapped * with a user-selectable contrast curve. */ static void setImage1(const u_char* br, u_int rw, u_int rh) { int step = rh; int limit = tnh; int err = 0; int bpr = howmany(rw,8); u_int sy = 0; u_char* row = thumbnail; u_int dy; for (dy = 0; dy < tnh; dy++) { const u_char* rows[256]; int nrows = 1; rows[0] = br + bpr*sy; err += step; while (err >= limit) { err -= limit; sy++; if (err >= limit) rows[nrows++] = br + bpr*sy; } setrow(row, nrows, rows); row += tnw; } } static void setImage(const u_char* br, u_int rw, u_int rh) { filterWidth = (u_short) ceil((double) rw / (double) tnw); setupStepTables(rw); setImage1(br, rw, rh); } static int generateThumbnail(TIFF* in, TIFF* out) { unsigned char* raster; unsigned char* rp; uint32 sw, sh, rps; uint16 bps, spp; tsize_t rowsize, rastersize; tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 diroff[1]; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &sw); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &sh); TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); if (spp != 1 || bps != 1) return (0); rowsize = TIFFScanlineSize(in); rastersize = sh * rowsize; raster = (unsigned char*)_TIFFmalloc(rastersize); rp = raster; for (s = 0; s < ns; s++) { (void) TIFFReadEncodedStrip(in, s, rp, -1); rp += rps * rowsize; } TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); setupCmap(); setImage(raster, sw, sh); TIFFSetField(out, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE); TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) tnw); TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) tnh); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint16) 8); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (uint16) 1); TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_LZW); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); cpTag(in, out, TIFFTAG_SOFTWARE, (uint16) -1, TIFF_ASCII); cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16) -1, TIFF_ASCII); cpTag(in, out, TIFFTAG_DATETIME, (uint16) -1, TIFF_ASCII); cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16) -1, TIFF_ASCII); diroff[0] = 0; TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff); return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 && TIFFWriteDirectory(out) != -1); } char* stuff[] = { "usage: thumbnail [options] input.tif output.tif", "where options are:", " -h # specify thumbnail image height (default is 274)", " -w # specify thumbnail image width (default is 216)", "", " -c linear use linear contrast curve", " -c exp50 use 50% exponential contrast curve", " -c exp60 use 60% exponential contrast curve", " -c exp70 use 70% exponential contrast curve", " -c exp80 use 80% exponential contrast curve", " -c exp90 use 90% exponential contrast curve", " -c exp use pure exponential contrast curve", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } s 216)", "", " -c linear use ltiff-v3.4beta018/tools/tiff2bw.c000444 004341 000024 00000026206 06003062770 016226 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiff2bw.c,v 1.19 1995/07/19 00:39:51 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include #include "tiffio.h" #define streq(a,b) (strcmp((a),(b)) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) /* x% weighting -> fraction of full color */ #define PCT(x) (((x)*255)/100) int RED = PCT(28); /* 28% */ int GREEN = PCT(59); /* 59% */ int BLUE = PCT(11); /* 11% */ static void usage(void); static int processCompressOptions(char*); static void compresscontig(unsigned char* out, unsigned char* rgb, uint32 n) { register int v, red = RED, green = GREEN, blue = BLUE; while (n-- > 0) { v = red*(*rgb++); v += green*(*rgb++); v += blue*(*rgb++); *out++ = v>>8; } } static void compresssep(unsigned char* out, unsigned char* r, unsigned char* g, unsigned char* b, uint32 n) { register uint32 red = RED, green = GREEN, blue = BLUE; while (n-- > 0) *out++ = (red*(*r++) + green*(*g++) + blue*(*b++)) >> 8; } static int checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) return (16); TIFFWarning(TIFFFileName(tif), "Assuming 8-bit colormap"); return (8); } static void compresspalette(unsigned char* out, unsigned char* data, uint32 n, uint16* rmap, uint16* gmap, uint16* bmap) { register int v, red = RED, green = GREEN, blue = BLUE; while (n-- > 0) { unsigned int ix = *data++; v = red*rmap[ix]; v += green*gmap[ix]; v += blue*bmap[ix]; *out++ = v>>8; } } static uint16 compression = (uint16) -1; static uint16 predictor = 0; static int jpegcolormode = JPEGCOLORMODE_RGB; static int quality = 75; /* JPEG quality */ static void cpTags(TIFF* in, TIFF* out); int main(int argc, char* argv[]) { uint32 rowsperstrip = (uint32) -1; TIFF *in, *out; uint32 w, h; uint16 samplesperpixel; uint16 bitspersample; uint16 config; uint16 photometric; uint16* red; uint16* green; uint16* blue; tsize_t rowsize; register uint32 row; register tsample_t s; unsigned char *inbuf, *outbuf; char thing[1024]; int c; extern int optind; extern char *optarg; while ((c = getopt(argc, argv, "c:r:R:G:B:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case 'R': RED = PCT(atoi(optarg)); break; case 'G': GREEN = PCT(atoi(optarg)); break; case 'B': BLUE = PCT(atoi(optarg)); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-1); photometric = 0; TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); if (photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_PALETTE ) { fprintf(stderr, "%s: Bad photometric; can only handle RGB and Palette images.\n", argv[optind]); return (-1); } TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); if (samplesperpixel != 1 && samplesperpixel != 3) { fprintf(stderr, "%s: Bad samples/pixel %u.\n", argv[optind], samplesperpixel); return (-1); } TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample != 8) { fprintf(stderr, " %s: Sorry, only handle 8-bit samples.\n", argv[optind]); return (-1); } TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-1); cpTags(in, out); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); if (compression != (uint16) -1) { TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_JPEG: TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } } TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); sprintf(thing, "B&W version of %s", argv[optind]); TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw"); outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); #define pack(a,b) ((a)<<8 | (b)) switch (pack(photometric, config)) { case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_CONTIG): case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_SEPARATE): TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue); /* * Convert 16-bit colormap to 8-bit (unless it looks * like an old-style 8-bit colormap). */ if (checkcmap(in, 1<= 0; i--) { red[i] = CVT(red[i]); green[i] = CVT(green[i]); blue[i] = CVT(blue[i]); } #undef CVT } inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); for (row = 0; row < h; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0) break; compresspalette(outbuf, inbuf, w, red, green, blue); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG): inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); for (row = 0; row < h; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0) break; compresscontig(outbuf, inbuf, w); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE): rowsize = TIFFScanlineSize(in); inbuf = (unsigned char *)_TIFFmalloc(3*rowsize); for (row = 0; row < h; row++) { for (s = 0; s < 3; s++) if (TIFFReadScanline(in, inbuf+s*rowsize, row, s) < 0) return (-1); compresssep(outbuf, inbuf, inbuf+rowsize, inbuf+2*rowsize, w); if (TIFFWriteScanline(out, outbuf, row, 0) < 0) break; } break; } #undef pack TIFFClose(out); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; compression = COMPRESSION_JPEG; } else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } #define CopyField1(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) #define CopyField4(tag, v1, v2, v3, v4) \ if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static void cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { uint16 shortv, shortv2, *shortav; float floatv, *floatav; char *stringv; uint32 longv; switch (type) { case TIFF_SHORT: if (count == 1) { CopyField1(tag, shortv); } else if (count == 2) { CopyField2(tag, shortv, shortv2); } else if (count == (uint16) -1) { CopyField2(tag, shortv, shortav); } break; case TIFF_LONG: CopyField1(tag, longv); break; case TIFF_RATIONAL: if (count == 1) { CopyField1(tag, floatv); } else if (count == (uint16) -1) { CopyField1(tag, floatav); } break; case TIFF_ASCII: CopyField1(tag, stringv); break; } } #undef CopyField4 #undef CopyField3 #undef CopyField2 #undef CopyField1 static struct cpTag { uint16 tag; uint16 count; TIFFDataType type; } tags[] = { { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, { TIFFTAG_IMAGELENGTH, 1, TIFF_LONG }, { TIFFTAG_FILLORDER, 1, TIFF_SHORT }, { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, { TIFFTAG_MAKE, 1, TIFF_ASCII }, { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpTags(TIFF* in, TIFF* out) { struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) cpTag(in, out, p->tag, p->count, p->type); } #undef NTAGS char* stuff[] = { "usage: tiff2bw [options] input.tif output.tif", "where options are:", " -R % use #% from red channel", " -G % use #% from green channel", " -B % use #% from blue channel", "", " -r # make each strip have no more than # rows", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c g3[:opts] compress output with CCITT Group 3 encoding", " -c g4 compress output with CCITT Group 4 encoding", " -c none use no compression algorithm on output", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } ress output with packbits encoding", " -c g3[:opts] compress output with CCITT Group 3 encoding", " -c g4 compress output with CCITT Group 4 encoding", " -c none use no compression algorithm on output", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { ctiff-v3.4beta018/tools/tiff2ps.c000444 004341 000024 00000060117 06003062770 016237 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiff2ps.c,v 1.45 1995/06/06 23:45:26 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include /* for atof */ #endif #include #include #include "tiffio.h" /* * NB: this code assumes uint32 works with printf's %l[ud]. */ #define TRUE 1 #define FALSE 0 int ascii85 = FALSE; /* use ASCII85 encoding */ int level2 = FALSE; /* generate PostScript level 2 */ int printAll = FALSE; /* print all images in file */ int generateEPSF = TRUE; /* generate Encapsulated PostScript */ int PSduplex = FALSE; /* enable duplex printing */ int PStumble = FALSE; /* enable top edge binding */ char *filename; /* input filename */ int TIFF2PS(FILE*, TIFF*, float, float); void PSpage(FILE*, TIFF*, uint32, uint32); void PSColorContigPreamble(FILE*, uint32, uint32, int); void PSColorSeparatePreamble(FILE*, uint32, uint32, int); void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int); void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int); void PSDataPalette(FILE*, TIFF*, uint32, uint32); void PSDataBW(FILE*, TIFF*, uint32, uint32); void PSRawDataBW(FILE*, TIFF*, uint32, uint32); void Ascii85Init(void); void Ascii85Put(unsigned char code, FILE* fd); void Ascii85Flush(FILE* fd); void PSHead(FILE*, TIFF*, uint32, uint32, float, float, float, float); void PSTail(FILE*, int); static void usage(int); int main(int argc, char* argv[]) { int dirnum = -1, c, np = 0; float pageWidth = 0; float pageHeight = 0; uint32 diroff = 0; extern char *optarg; extern int optind; FILE* output = stdout; while ((c = getopt(argc, argv, "h:w:d:o:O:aeps128DT")) != -1) switch (c) { case 'd': dirnum = atoi(optarg); break; case 'D': PSduplex = TRUE; break; case 'T': PStumble = TRUE; break; case 'e': generateEPSF = TRUE; break; case 'h': pageHeight = atof(optarg); break; case 'o': diroff = (uint32) strtoul(optarg, NULL, 0); break; case 'O': /* XXX too bad -o is already taken */ output = fopen(optarg, "w"); if (output == NULL) { fprintf(stderr, "%s: %s: Cannot open output file.\n", argv[0], optarg); exit(-2); } break; case 'a': printAll = TRUE; /* fall thru... */ case 'p': generateEPSF = FALSE; break; case 's': printAll = FALSE; break; case 'w': pageWidth = atof(optarg); break; case '1': level2 = FALSE; ascii85 = FALSE; break; case '2': level2 = TRUE; ascii85 = TRUE; /* default to yes */ break; case '8': ascii85 = FALSE; break; case '?': usage(-1); } for (; argc - optind > 0; optind++) { TIFF* tif = TIFFOpen(filename = argv[optind], "r"); if (tif != NULL) { if (dirnum != -1 && !TIFFSetDirectory(tif, dirnum)) return (-1); else if (diroff != 0 && !TIFFSetSubDirectory(tif, diroff)) return (-1); np = TIFF2PS(output, tif, pageWidth, pageHeight); TIFFClose(tif); } } if (np) PSTail(output, np); else usage(-1); if (output != stdout) fclose(output); return (0); } static uint16 samplesperpixel; static uint16 bitspersample; static uint16 planarconfiguration; static uint16 photometric; static uint16 compression; static uint16 extrasamples; 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 && planarconfiguration == PLANARCONFIG_CONTIG) { /* can rely on libjpeg to convert to RGB */ TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); photometric = PHOTOMETRIC_RGB; } else { TIFFError(filename, "Can not handle image with PhotometricInterpretation=YCbCr"); return (0); } /* fall thru... */ case PHOTOMETRIC_RGB: if (alpha && bitspersample != 8) { TIFFError(filename, "Can not handle %d-bit/sample RGB image with alpha", bitspersample); return (0); } /* fall thru... */ case PHOTOMETRIC_SEPARATED: case PHOTOMETRIC_PALETTE: case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: break; default: TIFFError(filename, "Can not handle image with PhotometricInterpretation=%d", photometric); return (0); } if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0) TIFFWarning(filename, "Ignoring extra samples"); return (1); } #define PS_UNIT_SIZE 72.0 #define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res))) static char RGBcolorimage[] = "\ /bwproc {\n\ rgbproc\n\ dup length 3 idiv string 0 3 0\n\ 5 -1 roll {\n\ add 2 1 roll 1 sub dup 0 eq {\n\ pop 3 idiv\n\ 3 -1 roll\n\ dup 4 -1 roll\n\ dup 3 1 roll\n\ 5 -1 roll put\n\ 1 add 3 0\n\ } { 2 1 roll } ifelse\n\ } forall\n\ pop pop pop\n\ } def\n\ /colorimage where {pop} {\n\ /colorimage {pop pop /rgbproc exch def {bwproc} image} bind def\n\ } ifelse\n\ "; /* * Adobe Photoshop requires a comment line of the form: * * %ImageData:
* <1 for binary|2 for hex> "data start" * * It is claimed to be part of some future revision of the EPS spec. */ static void PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) { fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", w, h, bitspersample, nc, bs); fprintf(fd, startline, nc); fprintf(fd, "\"\n"); } static void setupPageState(TIFF* tif, uint32* pw, uint32* ph, float* pprw, float* pprh) { uint16 res_unit; float xres, yres; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph); TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit); /* * Calculate printable area. */ if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres)) xres = PS_UNIT_SIZE; if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres)) yres = PS_UNIT_SIZE; switch (res_unit) { case RESUNIT_CENTIMETER: xres /= 2.54, yres /= 2.54; break; case RESUNIT_NONE: xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE; break; } *pprh = PSUNITS(*ph, yres); *pprw = PSUNITS(*pw, xres); } static tsize_t tf_bytesperrow; static tsize_t ps_bytesperrow; static tsize_t tf_rowsperstrip; static tsize_t tf_numberstrips; static char *hex = "0123456789abcdef"; /* returns the sequence number of the page processed */ int TIFF2PS(FILE* fd, TIFF* tif, float pw, float ph) { uint32 w, h; float ox, oy, prw, prh; uint32 subfiletype; uint16* sampleinfo; static int npages = 0; if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) ox = 0; if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy)) oy = 0; setupPageState(tif, &w, &h, &prw, &prh); do { tf_numberstrips = TIFFNumberOfStrips(tif); TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &tf_rowsperstrip); 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, &samplesperpixel); TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarconfiguration); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo); alpha = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); if (checkImage(tif)) { npages++; fprintf(fd, "%%%%Page: %d %d\n", npages, npages); fprintf(fd, "gsave\n"); fprintf(fd, "100 dict begin\n"); if (pw != 0 && ph != 0) fprintf(fd, "%f %f scale\n", pw*PS_UNIT_SIZE, ph*PS_UNIT_SIZE); else fprintf(fd, "%f %f scale\n", prw, prh); PSpage(fd, tif, w, h); fprintf(fd, "end\n"); fprintf(fd, "grestore\n"); fprintf(fd, "showpage\n"); } if (generateEPSF) break; TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype); } while (((subfiletype & FILETYPE_PAGE) || printAll) && TIFFReadDirectory(tif)); return(npages); } static char DuplexPreamble[] = "\ %%BeginFeature: *Duplex True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ 2 ge { 1 dict dup /Duplex true put setpagedevice }\n\ { statusdict /setduplex known { statusdict begin setduplex true end } if\n\ } ifelse\n\ end\n\ %%EndFeature\n\ "; static char TumblePreamble[] = "\ %%BeginFeature: *Tumble True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ 2 ge { 1 dict dup /Tumble true put setpagedevice }\n\ { statusdict /settumble known { statusdict begin settumble true end } if\n\ } ifelse\n\ end\n\ %%EndFeature\n\ "; void PSHead(FILE *fd, TIFF *tif, uint32 w, uint32 h, float pw, float ph, float ox, float oy) { time_t t; (void) tif; (void) w; (void) h; t = time(0); fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : ""); fprintf(fd, "%%%%Creator: tiff2ps\n"); fprintf(fd, "%%%%Title: %s\n", filename); fprintf(fd, "%%%%CreationDate: %s", ctime(&t)); fprintf(fd, "%%%%Origin: %ld %ld\n", (long) ox, (long) oy); /* NB: should use PageBoundingBox */ fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", (long) ceil(pw), (long) ceil(ph)); fprintf(fd, "%%%%Pages: (atend)\n"); fprintf(fd, "%%%%EndComments\n"); fprintf(fd, "%%%%BeginSetup\n"); if (PSduplex) fprintf(fd, "%s", DuplexPreamble); if (PStumble) fprintf(fd, "%s", TumblePreamble); fprintf(fd, "%%%%EndSetup\n"); } void PSTail(FILE *fd, int npages) { fprintf(fd, "%%%%Pages: %d\n", npages); fprintf(fd, "%%%%Trailer\n%%%%EOF\n"); } static int emitPSLevel2FilterFunction(FILE* fd, TIFF* tif, uint32 w, uint32 h) { uint32 group3opts; int K; #define P(a,b) (((a)<<4)|((b)&0xf)) switch (P(compression, photometric)) { case P(COMPRESSION_CCITTRLE, PHOTOMETRIC_MINISBLACK): case P(COMPRESSION_CCITTRLE, PHOTOMETRIC_MINISWHITE): K = 0; break; case P(COMPRESSION_CCITTFAX3, PHOTOMETRIC_MINISBLACK): case P(COMPRESSION_CCITTFAX3, PHOTOMETRIC_MINISWHITE): TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS, &group3opts); K = group3opts&GROUP3OPT_2DENCODING; break; case P(COMPRESSION_CCITTFAX4, PHOTOMETRIC_MINISBLACK): case P(COMPRESSION_CCITTFAX4, PHOTOMETRIC_MINISWHITE): K = -1; break; case P(COMPRESSION_LZW, PHOTOMETRIC_MINISBLACK): fprintf(fd, " /LZWDecode filter\n"); return (TRUE); default: return (FALSE); } #undef P fprintf(fd, " <<"); fprintf(fd, "/K %d", K); fprintf(fd, " /Columns %d /Rows %d", w, h); fprintf(fd, " /EndOfBlock false /BlackIs1 %s", (photometric == PHOTOMETRIC_MINISBLACK) ? "true" : "false"); fprintf(fd, ">>\n /CCITTFaxDecode filter\n"); return (TRUE); } void PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) { ps_bytesperrow = tf_bytesperrow; switch (photometric) { case PHOTOMETRIC_RGB: if (planarconfiguration == PLANARCONFIG_CONTIG) { fprintf(fd, "%s", RGBcolorimage); PSColorContigPreamble(fd, w, h, 3); PSDataColorContig(fd, tif, w, h, 3); } else { PSColorSeparatePreamble(fd, w, h, 3); PSDataColorSeparate(fd, tif, w, h, 3); } break; case PHOTOMETRIC_SEPARATED: /* XXX should emit CMYKcolorimage */ if (planarconfiguration == PLANARCONFIG_CONTIG) { PSColorContigPreamble(fd, w, h, 4); PSDataColorContig(fd, tif, w, h, 4); } else { PSColorSeparatePreamble(fd, w, h, 4); PSDataColorSeparate(fd, tif, w, h, 4); } break; case PHOTOMETRIC_PALETTE: fprintf(fd, "%s", RGBcolorimage); PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); fprintf(fd, "/scanLine %d string def\n", ps_bytesperrow); fprintf(fd, "%lu %lu 8\n", w, h); fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "false 3 colorimage\n"); PSDataPalette(fd, tif, w, h); break; case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: if (level2) { int rawdata; fprintf(fd, "{ %lu { %lu %lu %d\n", tf_numberstrips, w, tf_rowsperstrip, bitspersample); fprintf(fd, " [%lu 0 0 -%lu 0 %lu]\n", w, h, h); fprintf(fd, " currentfile /ASCII%sDecode filter\n", ascii85 ? "85" : "Hex"); rawdata = emitPSLevel2FilterFunction(fd, tif, w, h); fprintf(fd, " image\n"); fprintf(fd, " 0 -%f translate\n", (float)tf_rowsperstrip/(float)h); fprintf(fd, " } repeat\n}\n"); PhotoshopBanner(fd, w, h, 1, 1, "image"); fprintf(fd, "%%%%BeginData\nexec\n"); if (ascii85) { if (rawdata) PSRawDataBW(fd, tif, w, tf_rowsperstrip); else PSDataBW(fd, tif, w, h); } else { if (rawdata) PSRawDataBW(fd, tif, w, h); else PSDataBW(fd, tif, w, h); } fprintf(fd, "%%%%EndData\n"); } else { PhotoshopBanner(fd, w, h, 1, 1, "image"); fprintf(fd, "/scanLine %d string def\n",ps_bytesperrow); fprintf(fd, "%lu %lu %d\n", w, h, bitspersample); fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", w, h, h); fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); fprintf(fd, "image\n"); PSDataBW(fd, tif, w, h); } break; } putc('\n', fd); } void PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc) { ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); fprintf(fd, "/line %d string def\n", ps_bytesperrow); fprintf(fd, "%lu %lu %d\n", w, h, bitspersample); fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", w, h, h); fprintf(fd, "{currentfile line readhexstring pop} bind\n"); fprintf(fd, "false %d colorimage\n", nc); } void PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) { int i; PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); for (i = 0; i < nc; i++) fprintf(fd, "/line%d %d string def\n", i, ps_bytesperrow); fprintf(fd, "%lu %lu %d\n", w, h, bitspersample); fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", w, h, h); for (i = 0; i < nc; i++) fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); fprintf(fd, "true %d colorimage\n", nc); } #define MAXLINE 36 #define DOBREAK(len, howmany, fd) \ if (((len) -= (howmany)) <= 0) { \ putc('\n', fd); \ (len) = MAXLINE-(howmany); \ } #define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd) void PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) { uint32 row; int breaklen = MAXLINE, cc, es = samplesperpixel - nc; unsigned char *tf_buf; unsigned char *cp, c; (void) w; tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); if (tf_buf == NULL) { TIFFError(filename, "No space for scanline buffer"); return; } for (row = 0; row < h; row++) { if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) break; cp = tf_buf; if (alpha) { int adjust; cc = 0; for (; cc < tf_bytesperrow; cc += samplesperpixel) { DOBREAK(breaklen, nc, fd); /* * For images with alpha, matte against * a white background; i.e. * Cback * (1 - Aimage) * where Cback = 1. */ adjust = 255 - cp[nc]; switch (nc) { case 4: c = *cp++ + adjust; PUTHEX(c,fd); case 3: c = *cp++ + adjust; PUTHEX(c,fd); case 2: c = *cp++ + adjust; PUTHEX(c,fd); case 1: c = *cp++ + adjust; PUTHEX(c,fd); } cp += es; } } else { cc = 0; for (; cc < tf_bytesperrow; cc += samplesperpixel) { DOBREAK(breaklen, nc, fd); switch (nc) { case 4: c = *cp++; PUTHEX(c,fd); case 3: c = *cp++; PUTHEX(c,fd); case 2: c = *cp++; PUTHEX(c,fd); case 1: c = *cp++; PUTHEX(c,fd); } cp += es; } } } _TIFFfree((char *) tf_buf); } void PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) { uint32 row; int breaklen = MAXLINE, cc, s, maxs; unsigned char *tf_buf; unsigned char *cp, c; (void) w; tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); if (tf_buf == NULL) { TIFFError(filename, "No space for scanline buffer"); return; } maxs = (samplesperpixel > nc ? nc : samplesperpixel); for (row = 0; row < h; row++) { for (s = 0; s < maxs; s++) { if (TIFFReadScanline(tif, tf_buf, row, s) < 0) break; for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { DOBREAK(breaklen, 1, fd); c = *cp++; PUTHEX(c,fd); } } } _TIFFfree((char *) tf_buf); } #define PUTRGBHEX(c,fd) \ PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd) static int checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) { (void) tif; while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) return (16); TIFFWarning(filename, "Assuming 8-bit colormap"); return (8); } void PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) { uint16 *rmap, *gmap, *bmap; uint32 row; int breaklen = MAXLINE, cc, nc; unsigned char *tf_buf; unsigned char *cp, c; (void) w; if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { TIFFError(filename, "Palette image w/o \"Colormap\" tag"); return; } switch (bitspersample) { case 8: case 4: case 2: case 1: break; default: TIFFError(filename, "Depth %d not supported", bitspersample); return; } nc = 3 * (8 / bitspersample); tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow); if (tf_buf == NULL) { TIFFError(filename, "No space for scanline buffer"); return; } if (checkcmap(tif, 1<= 0; i--) { rmap[i] = CVT(rmap[i]); gmap[i] = CVT(gmap[i]); bmap[i] = CVT(bmap[i]); } #undef CVT } for (row = 0; row < h; row++) { if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) break; for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { DOBREAK(breaklen, nc, fd); switch (bitspersample) { case 8: c = *cp++; PUTRGBHEX(c, fd); break; case 4: c = *cp++; PUTRGBHEX(c&0xf, fd); c >>= 4; PUTRGBHEX(c, fd); break; case 2: c = *cp++; PUTRGBHEX(c&0x3, fd); c >>= 2; PUTRGBHEX(c&0x3, fd); c >>= 2; PUTRGBHEX(c&0x3, fd); c >>= 2; PUTRGBHEX(c, fd); break; case 1: c = *cp++; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c&0x1, fd); c >>= 1; PUTRGBHEX(c, fd); break; } } } _TIFFfree((char *) tf_buf); } void PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) { int breaklen = MAXLINE; unsigned char* tf_buf; unsigned char* cp; tsize_t stripsize = TIFFStripSize(tif); tstrip_t s; (void) w; (void) h; tf_buf = (unsigned char *) _TIFFmalloc(stripsize); if (tf_buf == NULL) { TIFFError(filename, "No space for scanline buffer"); return; } if (ascii85) Ascii85Init(); for (s = 0; s < TIFFNumberOfStrips(tif); s++) { int cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize); if (cc < 0) { TIFFError(filename, "Can't read strip"); break; } cp = tf_buf; if (photometric == PHOTOMETRIC_MINISWHITE) { for (cp += cc; --cp >= tf_buf;) *cp = ~*cp; cp++; } if (ascii85) { while (cc-- > 0) Ascii85Put(*cp++, fd); } else { while (cc-- > 0) { unsigned char c = *cp++; DOBREAK(breaklen, 1, fd); PUTHEX(c, fd); } } } if (ascii85) Ascii85Flush(fd); else if (level2) fputs(">\n", fd); _TIFFfree(tf_buf); } void PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) { uint32 *bc; uint32 bufsize; int breaklen = MAXLINE, cc; uint16 fillorder; unsigned char *tf_buf; unsigned char *cp, c; tstrip_t s; (void) w; (void) h; TIFFGetField(tif, TIFFTAG_FILLORDER, &fillorder); TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); bufsize = bc[0]; tf_buf = (unsigned char*) _TIFFmalloc(bufsize); if (tf_buf == NULL) { TIFFError(filename, "No space for strip buffer"); return; } for (s = 0; s < tf_numberstrips; s++) { if (bc[s] > bufsize) { tf_buf = (unsigned char *) _TIFFrealloc(tf_buf, bc[s]); if (tf_buf == NULL) { TIFFError(filename, "No space for strip buffer"); return; } bufsize = bc[s]; } cc = TIFFReadRawStrip(tif, s, tf_buf, bc[s]); if (cc < 0) { TIFFError(filename, "Can't read strip"); break; } if (fillorder == FILLORDER_LSB2MSB) TIFFReverseBits(tf_buf, cc); if (!ascii85) { for (cp = tf_buf; cc > 0; cc--) { DOBREAK(breaklen, 1, fd); c = *cp++; PUTHEX(c, fd); } fputs(">\n", fd); breaklen = MAXLINE; } else { Ascii85Init(); for (cp = tf_buf; cc > 0; cc--) Ascii85Put(*cp++, fd); Ascii85Flush(fd); } } _TIFFfree((char *) tf_buf); } /* * ASCII85 Encoding Support. */ unsigned char ascii85buf[10]; int ascii85count; int ascii85breaklen; void Ascii85Init(void) { ascii85breaklen = 2*MAXLINE; ascii85count = 0; } static char* Ascii85Encode(unsigned char* raw) { static char encoded[6]; uint32 word; word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3]; if (word != 0L) { uint32 q; uint16 w1; q = word / (85L*85*85*85); /* actually only a byte */ encoded[0] = q + '!'; word -= q * (85L*85*85*85); q = word / (85L*85*85); encoded[1] = q + '!'; word -= q * (85L*85*85); q = word / (85*85); encoded[2] = q + '!'; w1 = (uint16) (word - q*(85L*85)); encoded[3] = (w1 / 85) + '!'; encoded[4] = (w1 % 85) + '!'; encoded[5] = '\0'; } else encoded[0] = 'z', encoded[1] = '\0'; return (encoded); } void Ascii85Put(unsigned char code, FILE* fd) { ascii85buf[ascii85count++] = code; if (ascii85count >= 4) { unsigned char* p; int n; for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) { char* cp; for (cp = Ascii85Encode(p); *cp; cp++) { putc(*cp, fd); if (--ascii85breaklen == 0) { putc('\n', fd); ascii85breaklen = 2*MAXLINE; } } p += 4; } _TIFFmemcpy(ascii85buf, p, n); ascii85count = n; } } void Ascii85Flush(FILE* fd) { if (ascii85count > 0) { char* res; _TIFFmemset(&ascii85buf[ascii85count], 0, 3); res = Ascii85Encode(ascii85buf); fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd); } fputs("~>\n", fd); } char* stuff[] = { "usage: tiff2ps [options] input.tif ...", "where options are:", " -1 generate PostScript Level I (default)", " -2 generate PostScript Level II", " -8 disable use of ASCII85 encoding with PostScript Level II", " -d # convert directory number #", " -D enable duplex printing (two pages per sheet of paper)", " -e generate Encapsulated PostScript (EPS)", " -h # assume printed page height is # inches (default 11)", " -o # convert directory at file offset #", " -O file write PostScript to file instead of standard output", " -a convert all directories in file (default is first)", " -p generate regular PostScript", " -s generate PostScript for a single image", " -T print pages for top edge binding", " -w # assume printed page width is # inches (default 8.5)", NULL }; static void usage(int code) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(code); } ript to file instead of standard output", " -a convert all directories in file (default is first)", " -p generate regular PostScript", " -s generate PostScript for a single image", " -T print pages for top edge binding", " -w # assume printed page width is # inches (default 8.5)", NULL }; static void usage(int code) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i =tiff-v3.4beta018/tools/tiffcmp.c000444 004341 000024 00000033170 06003062771 016312 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffcmp.c,v 1.27 1995/07/19 00:39:51 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" static int stopondiff = 1; static int stoponfirsttag = 1; static uint16 bitspersample = 1; static uint16 samplesperpixel = 1; static uint32 imagewidth; static uint32 imagelength; static int tiffcmp(TIFF*, TIFF*); static int cmptags(TIFF*, TIFF*); static void ContigCompare(int, uint32, unsigned char*, unsigned char*, int); static void PrintDiff(uint32, int, uint32, int, int); static void SeparateCompare(int, int, uint32, unsigned char*, unsigned char*); static void eof(const char*, uint32, int); static void usage(void) { fprintf(stderr, "Usage: tiffcmp [-l] [-t] [-z] file1 file2\n"); exit(-3); } int main(int argc, char* argv[]) { TIFF *tif1, *tif2; int c, dirnum; extern int optind; while ((c = getopt(argc, argv, "ltz")) != -1) switch (c) { case 'l': stopondiff = 0; break; case 'z': stopondiff += 100; break; case 't': stoponfirsttag = 0; break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); tif1 = TIFFOpen(argv[optind], "r"); if (tif1 == NULL) return (-1); tif2 = TIFFOpen(argv[optind+1], "r"); if (tif2 == NULL) return (-2); dirnum = 0; while (tiffcmp(tif1, tif2)) { if (!TIFFReadDirectory(tif1)) { if (!TIFFReadDirectory(tif2)) break; printf("No more directories for %s\n", TIFFFileName(tif1)); return (1); } else if (!TIFFReadDirectory(tif2)) { printf("No more directories for %s\n", TIFFFileName(tif2)); return (1); } printf("Directory %d:\n", ++dirnum); } return (0); } #define checkEOF(tif, row, sample) { \ eof(TIFFFileName(tif), row, sample); \ goto bad; \ } static int CheckShortTag(TIFF*, TIFF*, int, char*); static int CheckShort2Tag(TIFF*, TIFF*, int, char*); static int CheckShortArrayTag(TIFF*, TIFF*, int, char*); static int CheckLongTag(TIFF*, TIFF*, int, char*); static int CheckFloatTag(TIFF*, TIFF*, int, char*); static int CheckStringTag(TIFF*, TIFF*, int, char*); static int tiffcmp(TIFF* tif1, TIFF* tif2) { uint16 config1, config2; tsize_t size1; uint32 s, row; unsigned char *buf1, *buf2; if (!CheckShortTag(tif1, tif2, TIFFTAG_BITSPERSAMPLE, "BitsPerSample")) return (0); if (!CheckShortTag(tif1, tif2, TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel")) return (0); if (!CheckLongTag(tif1, tif2, TIFFTAG_IMAGEWIDTH, "ImageWidth")) return (0); if (!cmptags(tif1, tif2)) return (1); (void) TIFFGetField(tif1, TIFFTAG_BITSPERSAMPLE, &bitspersample); (void) TIFFGetField(tif1, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); (void) TIFFGetField(tif1, TIFFTAG_IMAGEWIDTH, &imagewidth); (void) TIFFGetField(tif1, TIFFTAG_IMAGELENGTH, &imagelength); (void) TIFFGetField(tif1, TIFFTAG_PLANARCONFIG, &config1); (void) TIFFGetField(tif2, TIFFTAG_PLANARCONFIG, &config2); buf1 = (unsigned char *)_TIFFmalloc(size1 = TIFFScanlineSize(tif1)); buf2 = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif2)); if (buf1 == NULL || buf2 == NULL) { fprintf(stderr, "No space for scanline buffers\n"); exit(-1); } if (config1 != config2 && bitspersample != 8 && samplesperpixel > 1) { fprintf(stderr, "Can't handle different planar configuration w/ different bits/sample\n"); goto bad; } #define pack(a,b) ((a)<<8)|(b) switch (pack(config1, config2)) { case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG): for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(tif2, buf2, row, 0) < 0) checkEOF(tif2, row, -1) for (s = 0; s < samplesperpixel; s++) { if (TIFFReadScanline(tif1, buf1, row, s) < 0) checkEOF(tif1, row, s) SeparateCompare(1, s, row, buf2, buf1); } } break; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE): for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(tif1, buf1, row, 0) < 0) checkEOF(tif1, row, -1) for (s = 0; s < samplesperpixel; s++) { if (TIFFReadScanline(tif2, buf2, row, s) < 0) checkEOF(tif2, row, s) SeparateCompare(0, s, row, buf1, buf2); } } break; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE): for (s = 0; s < samplesperpixel; s++) for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(tif1, buf1, row, s) < 0) checkEOF(tif1, row, s) if (TIFFReadScanline(tif2, buf2, row, s) < 0) checkEOF(tif2, row, s) ContigCompare(s, row, buf1, buf2, size1); } break; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG): for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(tif1, buf1, row, 0) < 0) checkEOF(tif1, row, -1) if (TIFFReadScanline(tif2, buf2, row, 0) < 0) checkEOF(tif2, row, -1) ContigCompare(-1, row, buf1, buf2, size1); } break; } if (buf1) _TIFFfree(buf1); if (buf2) _TIFFfree(buf2); return (1); bad: if (stopondiff) exit(1); if (buf1) _TIFFfree(buf1); if (buf2) _TIFFfree(buf2); return (0); } #define CmpShortField(tag, name) \ if (!CheckShortTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) #define CmpShortField2(tag, name) \ if (!CheckShort2Tag(tif1, tif2, tag, name) && stoponfirsttag) return (0) #define CmpLongField(tag, name) \ if (!CheckLongTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) #define CmpFloatField(tag, name) \ if (!CheckFloatTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) #define CmpStringField(tag, name) \ if (!CheckStringTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) #define CmpShortArrayField(tag, name) \ if (!CheckShortArrayTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) static int cmptags(TIFF* tif1, TIFF* tif2) { CmpLongField(TIFFTAG_SUBFILETYPE, "SubFileType"); CmpLongField(TIFFTAG_IMAGEWIDTH, "ImageWidth"); CmpLongField(TIFFTAG_IMAGELENGTH, "ImageLength"); CmpShortField(TIFFTAG_BITSPERSAMPLE, "BitsPerSample"); CmpShortField(TIFFTAG_COMPRESSION, "Compression"); CmpShortField(TIFFTAG_PREDICTOR, "Predictor"); CmpShortField(TIFFTAG_PHOTOMETRIC, "PhotometricInterpretation"); CmpShortField(TIFFTAG_THRESHHOLDING, "Thresholding"); CmpShortField(TIFFTAG_FILLORDER, "FillOrder"); CmpShortField(TIFFTAG_ORIENTATION, "Orientation"); CmpShortField(TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel"); CmpShortField(TIFFTAG_MINSAMPLEVALUE, "MinSampleValue"); CmpShortField(TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue"); CmpFloatField(TIFFTAG_XRESOLUTION, "XResolution"); CmpFloatField(TIFFTAG_YRESOLUTION, "YResolution"); CmpLongField(TIFFTAG_GROUP3OPTIONS, "Group3Options"); CmpLongField(TIFFTAG_GROUP4OPTIONS, "Group4Options"); CmpShortField(TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit"); CmpShortField(TIFFTAG_PLANARCONFIG, "PlanarConfiguration"); CmpLongField(TIFFTAG_ROWSPERSTRIP, "RowsPerStrip"); CmpFloatField(TIFFTAG_XPOSITION, "XPosition"); CmpFloatField(TIFFTAG_YPOSITION, "YPosition"); CmpShortField(TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit"); CmpShortField(TIFFTAG_COLORRESPONSEUNIT, "ColorResponseUnit"); #ifdef notdef { uint16 *graycurve; CmpField(TIFFTAG_GRAYRESPONSECURVE, graycurve); } { uint16 *red, *green, *blue; CmpField3(TIFFTAG_COLORRESPONSECURVE, red, green, blue); } { uint16 *red, *green, *blue; CmpField3(TIFFTAG_COLORMAP, red, green, blue); } #endif CmpShortField2(TIFFTAG_PAGENUMBER, "PageNumber"); CmpStringField(TIFFTAG_ARTIST, "Artist"); CmpStringField(TIFFTAG_IMAGEDESCRIPTION,"ImageDescription"); CmpStringField(TIFFTAG_MAKE, "Make"); CmpStringField(TIFFTAG_MODEL, "Model"); CmpStringField(TIFFTAG_SOFTWARE, "Software"); CmpStringField(TIFFTAG_DATETIME, "DateTime"); CmpStringField(TIFFTAG_HOSTCOMPUTER, "HostComputer"); CmpStringField(TIFFTAG_PAGENAME, "PageName"); CmpStringField(TIFFTAG_DOCUMENTNAME, "DocumentName"); CmpShortField(TIFFTAG_MATTEING, "Matteing"); CmpShortArrayField(TIFFTAG_EXTRASAMPLES,"ExtraSamples"); return (1); } static void ContigCompare(int sample, uint32 row, unsigned char* p1, unsigned char* p2, int size) { register uint32 pix; register int ppb = 8/bitspersample; if (memcmp(p1, p2, size) == 0) return; switch (bitspersample) { case 1: case 2: case 4: case 8: { register unsigned char *pix1 = p1, *pix2 = p2; for (pix = 0; pix < imagewidth; pix1++, pix2++, pix += ppb) if (*pix1 != *pix2) PrintDiff(row, sample, pix, *pix1, *pix2); break; } case 16: { register uint16 *pix1 = (uint16 *)p1, *pix2 = (uint16 *)p2; for (pix = 0; pix < imagewidth; pix1++, pix2++, pix++) if (*pix1 != *pix2) PrintDiff(row, sample, pix, *pix1, *pix2); break; } } } static void PrintDiff(uint32 row, int sample, uint32 pix, int w1, int w2) { register int mask1, mask2, s, bps; if (sample < 0) sample = 0; bps = bitspersample; switch (bps) { case 1: case 2: case 4: mask1 = ~((-1)<>= bps, s -= bps, pix++) { if ((w1 & mask2) ^ (w2 & mask2)) { printf( "Scanline %lu, pixel %lu, sample %d: %01x %01x\n", row, pix, sample, (w1 >> s) & mask1, (w2 >> s) & mask1 ); if (--stopondiff == 0) exit(1); } } break; case 8: printf("Scanline %lu, pixel %lu, sample %d: %02x %02x\n", row, pix, sample, w1, w2); if (--stopondiff) exit(1); break; case 16: printf("Scanline %lu, pixel %lu, sample %d: %04x %04x\n", row, pix, sample, w1, w2); if (--stopondiff) exit(1); break; } } static void SeparateCompare(int reversed, int sample, uint32 row, unsigned char* cp1, unsigned char* p2) { uint32 npixels = imagewidth; register int pixel; cp1 += sample; for (pixel = 0; npixels-- > 0; pixel++, cp1 += samplesperpixel, p2++) if (*cp1 != *p2) { printf("Scanline %lu, pixel %lu, sample %d: ", row, pixel, sample); if (reversed) printf("%02x %02x\n", *p2, *cp1); else printf("%02x %02x\n", *cp1, *p2); if (--stopondiff) exit(1); } } static int checkTag(TIFF* tif1, TIFF* tif2, int tag, char* name, void* p1, void* p2) { if (TIFFGetField(tif1, tag, p1)) { if (!TIFFGetField(tif2, tag, p2)) { printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); return (0); } return (1); } else if (TIFFGetField(tif2, tag, p2)) { printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); return (0); } return (-1); } #define CHECK(cmp, fmt) { \ switch (checkTag(tif1,tif2,tag,name,&v1,&v2)) { \ case 1: if (cmp) \ case -1: return (1); \ printf(fmt, name, v1, v2); \ } \ return (0); \ } static int CheckShortTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint16 v1, v2; CHECK(v1 == v2, "%s: %u %u\n"); } static int CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint16 v11, v12, v21, v22; if (TIFFGetField(tif1, tag, &v11, &v12)) { if (!TIFFGetField(tif2, tag, &v21, &v22)) { printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); return (0); } if (v11 == v21 && v12 == v22) return (1); printf("%s: <%u,%u> <%u,%u>\n", name, v11, v12, v21, v22); } else if (TIFFGetField(tif2, tag, &v21, &v22)) printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); else return (1); return (0); } static int CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint16 n1, *a1; uint16 n2, *a2; if (TIFFGetField(tif1, tag, &n1, &a1)) { if (!TIFFGetField(tif2, tag, &n2, &a2)) { printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); return (0); } if (n1 == n2) { char* sep; uint16 i; if (memcmp(a1, a2, n1) == 0) return (1); printf("%s: value mismatch, <%u:", name, n1); sep = ""; for (i = 0; i < n1; i++) printf("%s%u", sep, a1[i]), sep = ","; printf("> and <%u: ", n2); sep = ""; for (i = 0; i < n2; i++) printf("%s%u", sep, a2[i]), sep = ","; printf(">\n"); } else printf("%s: %u items in %s, %u items in %s", name, n1, TIFFFileName(tif1), n2, TIFFFileName(tif2) ); } else if (TIFFGetField(tif2, tag, &n2, &a2)) printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); else return (1); return (0); } static int CheckLongTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { uint32 v1, v2; CHECK(v1 == v2, "%s: %lu %lu\n"); } static int CheckFloatTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { float v1, v2; CHECK(v1 == v2, "%s: %g %g\n"); } static int CheckStringTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { char *v1, *v2; CHECK(strcmp(v1, v2) == 0, "%s: \"%s\" \"%s\"\n"); } static void eof(const char* name, uint32 row, int s) { printf("%s: EOF at scanline %lu", name, row); if (s >= 0) printf(", sample %d", s); printf("\n"); } tif2, int tag, char* name) { uint32 v1, v2; CHECK(v1 == v2, "%s: %lu %lu\n"); } static int CheckFloatTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { float v1, v2; CHECK(v1 == v2, "%s: %g %g\n"); } static int CheckStringTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { char *v1, *v2; CHECK(strcmp(v1, v2) == 0, "%s: \"%s\" \"%s\"\n"); } static void eof(const char* name, uint32 tiff-v3.4beta018/tools/tiffcp.c000444 004341 000024 00000100314 06003062771 016130 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffcp.c,v 1.43 1995/06/30 05:37:07 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include typedef unsigned char u_char; #endif #include #include "tiffio.h" #if defined(VMS) #define unlink delete #endif #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) #define TRUE 1 #define FALSE 0 static int outtiled = -1; static uint32 tilewidth; static uint32 tilelength; static uint16 config; static uint16 compression; static uint16 predictor; static uint16 fillorder; static uint32 rowsperstrip; static uint32 g3opts; static int ignore = FALSE; /* if true, ignore read errors */ static uint32 defg3opts = (uint32) -1; static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; static uint16 defcompression = (uint16) -1; static uint16 defpredictor = (uint16) -1; static int tiffcp(TIFF*, TIFF*); static int processCompressOptions(char*); static void usage(void); int main(int argc, char* argv[]) { uint16 defconfig = (uint16) -1; uint16 deffillorder = 0; uint32 deftilewidth = (uint32) -1; uint32 deftilelength = (uint32) -1; uint32 defrowsperstrip = (uint32) -1; uint32 diroff = 0; TIFF* in; TIFF* out; const char* mode = "w"; int c; extern int optind; extern char* optarg; while ((c = getopt(argc, argv, "c:f:l:o:p:r:w:aist")) != -1) switch (c) { case 'a': /* append to output */ mode = "a"; break; case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'f': /* fill order */ if (streq(optarg, "lsb2msb")) deffillorder = FILLORDER_LSB2MSB; else if (streq(optarg, "msb2lsb")) deffillorder = FILLORDER_MSB2LSB; else usage(); break; case 'i': /* ignore errors */ ignore = TRUE; break; case 'l': /* tile length */ outtiled = TRUE; deftilelength = atoi(optarg); break; case 'o': /* initial directory offset */ diroff = strtoul(optarg, NULL, 0); break; case 'p': /* planar configuration */ if (streq(optarg, "separate")) defconfig = PLANARCONFIG_SEPARATE; else if (streq(optarg, "contig")) defconfig = PLANARCONFIG_CONTIG; else usage(); break; case 'r': /* rows/strip */ defrowsperstrip = atoi(optarg); break; case 's': /* generate stripped output */ outtiled = FALSE; break; case 't': /* generate tiled output */ outtiled = TRUE; break; case 'w': /* tile width */ outtiled = TRUE; deftilewidth = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); out = TIFFOpen(argv[argc-1], mode); if (out == NULL) return (-2); for (; optind < argc-1 ; optind++) { in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-3); if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) { TIFFError(TIFFFileName(in), "Error, setting subdirectory at %#x", diroff); (void) TIFFClose(out); return (1); } do { config = defconfig; compression = defcompression; predictor = defpredictor; fillorder = deffillorder; rowsperstrip = defrowsperstrip; tilewidth = deftilewidth; tilelength = deftilelength; g3opts = defg3opts; if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) { (void) TIFFClose(out); return (1); } } while (TIFFReadDirectory(in)); (void) TIFFClose(in); } (void) TIFFClose(out); return (0); } static void processG3Options(char* cp) { if (cp = strchr(cp, ':')) { if (defg3opts == (uint32) -1) defg3opts = 0; do { cp++; if (strneq(cp, "1d", 2)) defg3opts &= ~GROUP3OPT_2DENCODING; else if (strneq(cp, "2d", 2)) defg3opts |= GROUP3OPT_2DENCODING; else if (strneq(cp, "fill", 4)) defg3opts |= GROUP3OPT_FILLBITS; else usage(); } while (cp = strchr(cp, ':')); } } static int processCompressOptions(char* opt) { if (streq(opt, "none")) defcompression = COMPRESSION_NONE; else if (streq(opt, "packbits")) defcompression = COMPRESSION_PACKBITS; else if (strneq(opt, "jpeg", 4)) { char* cp = strchr(opt, ':'); if (cp && isdigit(cp[1])) quality = atoi(cp+1); if (cp && strchr(cp, 'r')) jpegcolormode = JPEGCOLORMODE_RAW; defcompression = COMPRESSION_JPEG; } else if (strneq(opt, "g3", 2)) { processG3Options(opt); defcompression = COMPRESSION_CCITTFAX3; } else if (streq(opt, "g4")) defcompression = COMPRESSION_CCITTFAX4; else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) defpredictor = atoi(cp+1); defcompression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) defpredictor = atoi(cp+1); defcompression = COMPRESSION_DEFLATE; } else return (0); return (1); } char* stuff[] = { "usage: tiffcp [options] input... output", "where options are:", " -a append to output instead of overwriting", " -o offset set initial directory offset", " -p contig pack samples contiguously (e.g. RGBRGB...)", " -p separate store samples separately (e.g. RRR...GGG...BBB...)", " -s write output in strips", " -t write output in tiles", " -i ignore read errors", "", " -r # make each strip have no more than # rows", " -w # set output tile width (pixels)", " -l # set output tile length (pixels)", "", " -f lsb2msb force lsb-to-msb FillOrder for output", " -f msb2lsb force msb-to-lsb FillOrder for output", "", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c jpeg[:opts]compress output with JPEG encoding", " -c packbits compress output with packbits encoding", " -c g3[:opts] compress output with CCITT Group 3 encoding", " -c g4 compress output with CCITT Group 4 encoding", " -c none use no compression algorithm on output", "", "Group 3 options:", " 1d use default CCITT Group 3 1D-encoding", " 2d use optional CCITT Group 3 2D-encoding", " fill byte-align EOL codes", "For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", "", "JPEG options:", " # set compression quality level (0-100, default 75)", " r output color image as RGB rather than YCbCr", "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } static void CheckAndCorrectColormap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) { int i; for (i = 0; i < n; i++) if (r[i] >= 256 || g[i] >= 256 || b[i] >= 256) return; TIFFWarning(TIFFFileName(tif), "Scaling 8-bit colormap"); #define CVT(x) (((x) * ((1L<<16)-1)) / 255) for (i = 0; i < n; i++) { r[i] = CVT(r[i]); g[i] = CVT(g[i]); b[i] = CVT(b[i]); } #undef CVT } #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) #define CopyField4(tag, v1, v2, v3, v4) \ if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) static struct cpTag { uint16 tag; uint16 count; TIFFDataType type; } tags[] = { { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, { TIFFTAG_MAKE, 1, TIFF_ASCII }, { TIFFTAG_MODEL, 1, TIFF_ASCII }, { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, { TIFFTAG_DATETIME, 1, TIFF_ASCII }, { TIFFTAG_ARTIST, 1, TIFF_ASCII }, { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, { TIFFTAG_WHITEPOINT, 1, TIFF_RATIONAL }, { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, { TIFFTAG_CONSECUTIVEBADFAXLINES,1, TIFF_LONG }, { TIFFTAG_INKSET, 1, TIFF_SHORT }, { TIFFTAG_INKNAMES, 1, TIFF_ASCII }, { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, }; #define NTAGS (sizeof (tags) / sizeof (tags[0])) static void cpOtherTags(TIFF* in, TIFF* out) { struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) switch (p->type) { case TIFF_SHORT: if (p->count == 1) { uint16 shortv; CopyField(p->tag, shortv); } else if (p->count == 2) { uint16 shortv1, shortv2; CopyField2(p->tag, shortv1, shortv2); } else if (p->count == (uint16) -1) { uint16 shortv1; uint16* shortav; CopyField2(p->tag, shortv1, shortav); } break; case TIFF_LONG: { uint32 longv; CopyField(p->tag, longv); } break; case TIFF_RATIONAL: if (p->count == 1) { float floatv; CopyField(p->tag, floatv); } else if (p->count == (uint16) -1) { float* floatav; CopyField(p->tag, floatav); } break; case TIFF_ASCII: { char* stringv; CopyField(p->tag, stringv); } break; case TIFF_DOUBLE: if (p->count == 1) { double doublev; CopyField(p->tag, doublev); } else if (p->count == (uint16) -1) { double* doubleav; CopyField(p->tag, doubleav); } break; } } typedef int (*copyFunc) (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel); static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16); static int tiffcp(TIFF* in, TIFF* out) { uint16 bitspersample, samplesperpixel, shortv; copyFunc cf; uint32 w, l; CopyField(TIFFTAG_IMAGEWIDTH, w); CopyField(TIFFTAG_IMAGELENGTH, l); CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); 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 CopyField(TIFFTAG_PHOTOMETRIC, shortv); if (fillorder != 0) TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); else CopyField(TIFFTAG_FILLORDER, shortv); CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); /* * Choose tiles/strip for the output image according to * the command line arguments (-tiles, -strips) and the * structure of the input image. */ if (outtiled == -1) outtiled = TIFFIsTiled(in); if (outtiled) { /* * Setup output file's tile width&height. If either * is not specified, use either the value from the * input image or, if nothing is defined, use the * library default. */ if (tilewidth == (uint32) -1) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); if (tilelength == (uint32) -1) TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); TIFFDefaultTileSize(out, &tilewidth, &tilelength); TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); } else { /* * RowsPerStrip is left unspecified: use either the * value from the input image or, if nothing is defined, * use the library default. */ if (rowsperstrip == (uint32) -1) TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); } if (config != (uint16) -1) TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); else CopyField(TIFFTAG_PLANARCONFIG, config); if (g3opts != (uint32) -1) TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); else CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); if (samplesperpixel <= 4) { uint16 *tr, *tg, *tb, *ta; CopyField4(TIFFTAG_TRANSFERFUNCTION, tr, tg, tb, ta); } { uint16 *red, *green, *blue; if (TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue)) { CheckAndCorrectColormap(in, 1< contig by scanline for rows/strip change. */ DECLAREcpFunc(cpContig2ContigByRow) { u_char *buf = (u_char *)_TIFFmalloc(TIFFScanlineSize(in)); uint32 row; (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) goto done; if (TIFFWriteScanline(out, buf, row, 0) < 0) goto bad; } done: _TIFFfree(buf); return (TRUE); bad: _TIFFfree(buf); return (FALSE); } /* * Strip -> strip for change in encoding. */ DECLAREcpFunc(cpDecodedStrips) { tsize_t stripsize = TIFFStripSize(in); u_char *buf = (u_char *)_TIFFmalloc(stripsize); (void) imagewidth; (void) spp; if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 row = 0; for (s = 0; s < ns; s++) { tsize_t cc = (row + rowsperstrip > imagelength) ? TIFFVStripSize(in, imagelength - row) : stripsize; if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore) break; if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) { _TIFFfree(buf); return (FALSE); } row += rowsperstrip; } _TIFFfree(buf); return (TRUE); } return (FALSE); } /* * Separate -> separate by row for rows/strip change. */ DECLAREcpFunc(cpSeparate2SeparateByRow) { u_char *buf = (u_char *)_TIFFmalloc(TIFFScanlineSize(in)); uint32 row; tsample_t s; (void) imagewidth; for (s = 0; s < spp; s++) { for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) goto done; if (TIFFWriteScanline(out, buf, row, s) < 0) goto bad; } } done: _TIFFfree(buf); return (TRUE); bad: _TIFFfree(buf); return (FALSE); } /* * Contig -> separate by row. */ DECLAREcpFunc(cpContig2SeparateByRow) { u_char *inbuf = (u_char *)_TIFFmalloc(TIFFScanlineSize(in)); u_char *outbuf = (u_char *)_TIFFmalloc(TIFFScanlineSize(out)); register u_char *inp, *outp; register uint32 n; uint32 row; tsample_t s; /* unpack channels */ for (s = 0; s < spp; s++) { for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) goto done; inp = inbuf + s; outp = outbuf; for (n = imagewidth; n-- > 0;) { *outp++ = *inp; inp += spp; } if (TIFFWriteScanline(out, outbuf, row, s) < 0) goto bad; } } done: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return (TRUE); bad: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return (FALSE); } /* * Separate -> contig by row. */ DECLAREcpFunc(cpSeparate2ContigByRow) { u_char *inbuf = (u_char *)_TIFFmalloc(TIFFScanlineSize(in)); u_char *outbuf = (u_char *)_TIFFmalloc(TIFFScanlineSize(out)); register u_char *inp, *outp; register uint32 n; uint32 row; tsample_t s; for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) goto done; inp = inbuf; outp = outbuf + s; for (n = imagewidth; n-- > 0;) { *outp = *inp++; outp += spp; } } if (TIFFWriteScanline(out, outbuf, row, 0) < 0) goto bad; } done: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return (TRUE); bad: if (inbuf) _TIFFfree(inbuf); if (outbuf) _TIFFfree(outbuf); return (FALSE); } static void cpStripToTile(u_char* out, u_char* in, uint32 rows, uint32 cols, int outskew, int inskew) { while (rows-- > 0) { uint32 j = cols; while (j-- > 0) *out++ = *in++; out += outskew; in += inskew; } } static void cpContigBufToSeparateBuf(u_char* out, u_char* in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp) { while (rows-- > 0) { uint32 j = cols; while (j-- > 0) *out++ = *in, in += spp; out += outskew; in += inskew; } } static void cpSeparateBufToContigBuf(u_char* out, u_char* in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp) { while (rows-- > 0) { uint32 j = cols; while (j-- > 0) *out = *in++, out += spp; out += outskew; in += inskew; } } static int cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, uint32 imagelength, uint32 imagewidth, tsample_t spp) { int status = FALSE; u_char* buf = (u_char *) _TIFFmalloc(TIFFRasterScanlineSize(in) * imagelength); if (buf) { (*fin)(in, buf, imagelength, imagewidth, spp); status = (fout)(out, buf, imagelength, imagewidth, spp); _TIFFfree(buf); } return (status); } DECLAREreadFunc(readContigStripsIntoBuffer) { tsize_t scanlinesize = TIFFScanlineSize(in); u_char *bufp = buf; uint32 row; (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFReadScanline(in, bufp, row, 0) < 0 && !ignore) break; bufp += scanlinesize; } } DECLAREreadFunc(readSeparateStripsIntoBuffer) { tsize_t scanlinesize = TIFFScanlineSize(in); u_char* scanline = (u_char *) _TIFFmalloc(scanlinesize); (void) imagewidth; if (scanline) { u_char *bufp = buf; uint32 row; tsample_t s; for (row = 0; row < imagelength; row++) { /* merge channels */ for (s = 0; s < spp; s++) { u_char* sp = scanline; u_char* bp = bufp + s; tsize_t n = scanlinesize; if (TIFFReadScanline(in, sp, row, s) < 0 && !ignore) goto done; while (n-- > 0) *bp = *bufp++, bp += spp; } bufp += scanlinesize; } done: _TIFFfree(scanline); } } DECLAREreadFunc(readContigTilesIntoBuffer) { u_char* tilebuf = (u_char *) _TIFFmalloc(TIFFTileSize(in)); uint32 imagew = TIFFScanlineSize(in); uint32 tilew = TIFFTileRowSize(in); int iskew = imagew - tilew; u_char *bufp = buf; uint32 tw, tl; uint32 row; (void) spp; if (tilebuf == 0) return; (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); for (row = 0; row < imagelength; row += tl) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; uint32 colb = 0; uint32 col; for (col = 0; col < imagewidth; col += tw) { if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 && !ignore) goto done; if (colb + tilew > imagew) { uint32 width = imagew - colb; uint32 oskew = tilew - width; cpStripToTile(bufp + colb, tilebuf, nrow, width, oskew + iskew, oskew); } else cpStripToTile(bufp + colb, tilebuf, nrow, tilew, iskew, 0); colb += tilew; } bufp += imagew * nrow; } done: _TIFFfree(tilebuf); } DECLAREreadFunc(readSeparateTilesIntoBuffer) { uint32 imagew = TIFFScanlineSize(in); uint32 tilew = TIFFTileRowSize(in); int iskew = imagew - tilew; u_char* tilebuf = (u_char *) _TIFFmalloc(TIFFTileSize(in)); u_char *bufp = buf; uint32 tw, tl; uint32 row; if (tilebuf == 0) return; (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); for (row = 0; row < imagelength; row += tl) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; uint32 colb = 0; uint32 col; for (col = 0; col < imagewidth; col += tw) { tsample_t s; for (s = 0; s < spp; s++) { if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore) goto done; /* * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ if (colb + tilew > imagew) { uint32 width = imagew - colb; int oskew = tilew - width; cpSeparateBufToContigBuf(bufp+colb+s, tilebuf, nrow, width, oskew + iskew, oskew, spp); } else cpSeparateBufToContigBuf(bufp+colb+s, tilebuf, nrow, tw, iskew, 0, spp); } colb += tilew; } bufp += imagew * nrow; } done: _TIFFfree(tilebuf); } DECLAREwriteFunc(writeBufferToContigStrips) { tsize_t scanline = TIFFScanlineSize(out); uint32 row; (void) imagewidth; (void) spp; for (row = 0; row < imagelength; row++) { if (TIFFWriteScanline(out, buf, row, 0) < 0) return (FALSE); buf += scanline; } return (TRUE); } DECLAREwriteFunc(writeBufferToSeparateStrips) { u_char *obuf = (u_char *) _TIFFmalloc(TIFFScanlineSize(out)); tsample_t s; if (obuf == NULL) return (0); for (s = 0; s < spp; s++) { uint32 row; for (row = 0; row < imagelength; row++) { u_char* inp = buf + s; u_char* outp = obuf; uint32 n = imagewidth; while (n-- > 0) *outp++ = *inp, inp += spp; if (TIFFWriteScanline(out, obuf, row, s) < 0) { _TIFFfree(obuf); return (FALSE); } } } _TIFFfree(obuf); return (TRUE); } DECLAREwriteFunc(writeBufferToContigTiles) { uint32 imagew = TIFFScanlineSize(out); uint32 tilew = TIFFTileRowSize(out); int iskew = imagew - tilew; u_char* obuf = (u_char *) _TIFFmalloc(TIFFTileSize(out)); u_char* bufp = buf; uint32 tl, tw; uint32 row; (void) spp; if (obuf == NULL) return (FALSE); (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); for (row = 0; row < imagelength; row += tilelength) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; uint32 colb = 0; uint32 col; for (col = 0; col < imagewidth; col += tw) { /* * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ if (colb + tilew > imagew) { uint32 width = imagew - colb; int oskew = tilew - width; cpStripToTile(obuf, bufp + colb, nrow, width, oskew, oskew + iskew); } else cpStripToTile(obuf, bufp + colb, nrow, tilew, 0, iskew); if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) { _TIFFfree(obuf); return (FALSE); } colb += tilew; } bufp += nrow * imagew; } _TIFFfree(obuf); return (TRUE); } DECLAREwriteFunc(writeBufferToSeparateTiles) { uint32 imagew = TIFFScanlineSize(out); tsize_t tilew = TIFFTileRowSize(out); int iskew = imagew - tilew; u_char *obuf = (u_char*) _TIFFmalloc(TIFFTileSize(out)); u_char *bufp = buf; uint32 tl, tw; uint32 row; if (obuf == NULL) return (FALSE); (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); for (row = 0; row < imagelength; row += tl) { uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; uint32 colb = 0; uint32 col; for (col = 0; col < imagewidth; col += tw) { tsample_t s; for (s = 0; s < spp; s++) { /* * Tile is clipped horizontally. Calculate * visible portion and skewing factors. */ if (colb + tilew > imagew) { uint32 width = imagew - colb; int oskew = tilew - width; cpContigBufToSeparateBuf(obuf, bufp + colb + s, nrow, width, oskew/spp, oskew + imagew, spp); } else cpContigBufToSeparateBuf(obuf, bufp + colb + s, nrow, tilewidth, 0, iskew, spp); if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { _TIFFfree(obuf); return (FALSE); } } colb += tilew; } bufp += nrow * imagew; } _TIFFfree(obuf); return (TRUE); } /* * Contig strips -> contig tiles. */ DECLAREcpFunc(cpContigStrips2ContigTiles) { return cpImage(in, out, readContigStripsIntoBuffer, writeBufferToContigTiles, imagelength, imagewidth, spp); } /* * Contig strips -> separate tiles. */ DECLAREcpFunc(cpContigStrips2SeparateTiles) { return cpImage(in, out, readContigStripsIntoBuffer, writeBufferToSeparateTiles, imagelength, imagewidth, spp); } /* * Separate strips -> contig tiles. */ DECLAREcpFunc(cpSeparateStrips2ContigTiles) { return cpImage(in, out, readSeparateStripsIntoBuffer, writeBufferToContigTiles, imagelength, imagewidth, spp); } /* * Separate strips -> separate tiles. */ DECLAREcpFunc(cpSeparateStrips2SeparateTiles) { return cpImage(in, out, readSeparateStripsIntoBuffer, writeBufferToSeparateTiles, imagelength, imagewidth, spp); } /* * Contig strips -> contig tiles. */ DECLAREcpFunc(cpContigTiles2ContigTiles) { return cpImage(in, out, readContigTilesIntoBuffer, writeBufferToContigTiles, imagelength, imagewidth, spp); } /* * Contig tiles -> separate tiles. */ DECLAREcpFunc(cpContigTiles2SeparateTiles) { return cpImage(in, out, readContigTilesIntoBuffer, writeBufferToSeparateTiles, imagelength, imagewidth, spp); } /* * Separate tiles -> contig tiles. */ DECLAREcpFunc(cpSeparateTiles2ContigTiles) { return cpImage(in, out, readSeparateTilesIntoBuffer, writeBufferToContigTiles, imagelength, imagewidth, spp); } /* * Separate tiles -> separate tiles (tile dimension change). */ DECLAREcpFunc(cpSeparateTiles2SeparateTiles) { return cpImage(in, out, readSeparateTilesIntoBuffer, writeBufferToSeparateTiles, imagelength, imagewidth, spp); } /* * Contig tiles -> contig tiles (tile dimension change). */ DECLAREcpFunc(cpContigTiles2ContigStrips) { return cpImage(in, out, readContigTilesIntoBuffer, writeBufferToContigStrips, imagelength, imagewidth, spp); } /* * Contig tiles -> separate strips. */ DECLAREcpFunc(cpContigTiles2SeparateStrips) { return cpImage(in, out, readContigTilesIntoBuffer, writeBufferToSeparateStrips, imagelength, imagewidth, spp); } /* * Separate tiles -> contig strips. */ DECLAREcpFunc(cpSeparateTiles2ContigStrips) { return cpImage(in, out, readSeparateTilesIntoBuffer, writeBufferToContigStrips, imagelength, imagewidth, spp); } /* * Separate tiles -> separate strips. */ DECLAREcpFunc(cpSeparateTiles2SeparateStrips) { return cpImage(in, out, readSeparateTilesIntoBuffer, writeBufferToSeparateStrips, imagelength, imagewidth, spp); } /* * Select the appropriate copy function to use. */ static copyFunc pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) { uint16 shortv; uint32 w, l, tw, tl; int bychunk; (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv); if (shortv != config && bitspersample != 8 && samplesperpixel > 1) { fprintf(stderr, "%s: Can not handle different planar configuration w/ bits/sample != 8\n", TIFFFileName(in)); return (NULL); } TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l); if (TIFFIsTiled(out)) { if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw)) tw = w; if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl)) tl = l; bychunk = (tw == tilewidth && tl == tilelength); } else if (TIFFIsTiled(in)) { TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); bychunk = (tw == w && tl == rowsperstrip); } else { uint32 irps = (uint32) -1L; TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); bychunk = (rowsperstrip == irps); } #define T 1 #define F 0 #define pack(a,b,c,d,e) ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e))) switch(pack(shortv,config,TIFFIsTiled(in),TIFFIsTiled(out),bychunk)) { /* Strips -> Tiles */ case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,T): return cpContigStrips2ContigTiles; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,T): return cpContigStrips2SeparateTiles; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,T): return cpSeparateStrips2ContigTiles; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,T): return cpSeparateStrips2SeparateTiles; /* Tiles -> Tiles */ case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,T): return cpContigTiles2ContigTiles; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,T): return cpContigTiles2SeparateTiles; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,T): return cpSeparateTiles2ContigTiles; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,T): return cpSeparateTiles2SeparateTiles; /* Tiles -> Strips */ case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,T): return cpContigTiles2ContigStrips; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,T): return cpContigTiles2SeparateStrips; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,T): return cpSeparateTiles2ContigStrips; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,T): return cpSeparateTiles2SeparateStrips; /* Strips -> Strips */ case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,F): return cpContig2ContigByRow; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,T): return cpDecodedStrips; case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,F): case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,T): return cpContig2SeparateByRow; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T): return cpSeparate2ContigByRow; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,T): return cpSeparate2SeparateByRow; } #undef pack #undef F #undef T fprintf(stderr, "tiffcp: %s: Don't know how to copy/convert image.\n", TIFFFileName(in)); return (NULL); } T): return cpContig2SeparateByRow; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T): return cpSeparate2ContigByRow; case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F): case pack(PLANARCONFIG_SEPARATE, PLANARCONtiff-v3.4beta018/tools/tiffdither.c000444 004341 000024 00000020700 06003062772 017006 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffdither.c,v 1.24 1995/06/30 00:27:07 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) uint32 imagewidth; uint32 imagelength; int threshold = 128; static void usage(void); /* * Floyd-Steinberg error propragation with threshold. * This code is stolen from tiffmedian. */ static void fsdither(TIFF* in, TIFF* out) { unsigned char *outline, *inputline, *inptr; short *thisline, *nextline, *tmpptr; register unsigned char *outptr; register short *thisptr, *nextptr; register uint32 i, j; uint32 imax, jmax; int lastline, lastpixel; int bit; tsize_t outlinesize; imax = imagelength - 1; jmax = imagewidth - 1; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); thisline = (short *)_TIFFmalloc(imagewidth * sizeof (short)); nextline = (short *)_TIFFmalloc(imagewidth * sizeof (short)); outlinesize = TIFFScanlineSize(out); outline = (unsigned char *) _TIFFmalloc(outlinesize); /* * Get first line */ if (TIFFReadScanline(in, inputline, 0, 0) <= 0) return; inptr = inputline; nextptr = nextline; for (j = 0; j < imagewidth; ++j) *nextptr++ = *inptr++; for (i = 1; i < imagelength; ++i) { tmpptr = thisline; thisline = nextline; nextline = tmpptr; lastline = (i == imax); if (TIFFReadScanline(in, inputline, i, 0) <= 0) break; inptr = inputline; nextptr = nextline; for (j = 0; j < imagewidth; ++j) *nextptr++ = *inptr++; thisptr = thisline; nextptr = nextline; _TIFFmemset(outptr = outline, 0, outlinesize); bit = 0x80; for (j = 0; j < imagewidth; ++j) { register int v; lastpixel = (j == jmax); v = *thisptr++; if (v < 0) v = 0; else if (v > 255) v = 255; if (v > threshold) { *outptr |= bit; v -= 255; } bit >>= 1; if (bit == 0) { outptr++; bit = 0x80; } if (!lastpixel) thisptr[0] += v * 7 / 16; if (!lastline) { if (j != 0) nextptr[-1] += v * 3 / 16; *nextptr++ += v * 5 / 16; if (!lastpixel) nextptr[0] += v / 16; } } if (TIFFWriteScanline(out, outline, i-1, 0) < 0) break; } _TIFFfree(inputline); _TIFFfree(thisline); _TIFFfree(nextline); _TIFFfree(outline); } static uint16 compression = COMPRESSION_LZW; static uint16 predictor = 0; static uint32 group3options = 0; static void processG3Options(char* cp) { if (cp = strchr(cp, ':')) { do { cp++; if (strneq(cp, "1d", 2)) group3options &= ~GROUP3OPT_2DENCODING; else if (strneq(cp, "2d", 2)) group3options |= GROUP3OPT_2DENCODING; else if (strneq(cp, "fill", 4)) group3options |= GROUP3OPT_FILLBITS; else usage(); } while (cp = strchr(cp, ':')); } } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "g3", 2)) { processG3Options(opt); compression = COMPRESSION_CCITTFAX3; } else if (streq(opt, "g4")) compression = COMPRESSION_CCITTFAX4; else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } int main(int argc, char* argv[]) { TIFF *in, *out; uint16 samplesperpixel, bitspersample = 1, shortv; float floatv; char thing[1024]; uint32 rowsperstrip = (uint32) -1; int onestrip = 0; uint16 fillorder = 0; int c; extern int optind; extern char *optarg; while ((c = getopt(argc, argv, "c:f:r:t:")) != -1) switch (c) { case 'c': /* compression scheme */ if (!processCompressOptions(optarg)) usage(); break; case 'f': /* fill order */ if (streq(optarg, "lsb2msb")) fillorder = FILLORDER_LSB2MSB; else if (streq(optarg, "msb2lsb")) fillorder = FILLORDER_MSB2LSB; else usage(); break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); onestrip = 0; break; case 't': threshold = atoi(optarg); if (threshold < 0) threshold = 0; else if (threshold > 255) threshold = 255; break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind < 2) usage(); in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-1); TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); if (samplesperpixel != 1) { fprintf(stderr, "%s: Not a b&w image.\n", argv[0]); return (-1); } TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample != 8) { fprintf(stderr, " %s: Sorry, only handle 8-bit samples.\n", argv[0]); return (-1); } out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-1); CopyField(TIFFTAG_IMAGEWIDTH, imagewidth); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); TIFFSetField(out, TIFFTAG_IMAGELENGTH, imagelength-1); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_COMPRESSION, compression); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); sprintf(thing, "Dithered B&W version of %s", argv[optind]); TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); CopyField(TIFFTAG_ORIENTATION, shortv); CopyField(TIFFTAG_XRESOLUTION, floatv); CopyField(TIFFTAG_YRESOLUTION, floatv); CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); if (onestrip) rowsperstrip = imagelength-1; else rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); switch (compression) { case COMPRESSION_CCITTFAX3: TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options); break; case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } fsdither(in, out); TIFFClose(in); TIFFClose(out); return (0); } char* stuff[] = { "usage: tiffdither [options] input.tif output.tif", "where options are:", " -r # make each strip have no more than # rows", " -f lsb2msb force lsb-to-msb FillOrder for output", " -f msb2lsb force msb-to-lsb FillOrder for output", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c g3[:opts] compress output with CCITT Group 3 encoding", " -c g4 compress output with CCITT Group 4 encoding", " -c none use no compression algorithm on output", "", "Group 3 options:", " 1d use default CCITT Group 3 1D-encoding", " 2d use optional CCITT Group 3 2D-encoding", " fill byte-align EOL codes", "For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } " 1d use default CCITT Group 3 1D-encoding", " 2d use optionatiff-v3.4beta018/tools/tiffdump.c000444 004341 000024 00000046067 06003062772 016512 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffdump.c,v 1.44 1995/07/19 00:39:51 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #if defined(VMS) #include #include #elif defined(_WINDOWS) #include #define off_t toff_t #include "tiffio.h" #include #elif defined(applec) #define open _open_ /* to avoid conflicts */ #include #undef open int open(const char*, int, int); typedef unsigned int off_t; #else /* !VMS && !_WINDOWS */ #include #include #endif #if defined(MSDOS) #include #endif #ifndef O_BINARY #define O_BINARY 0 #endif #include "tiffio.h" char *curfile; int swabflag; int bigendian; int typeshift[13]; /* data type shift counts */ long typemask[13]; /* data type masks */ char* bytefmt = "%s%#02x"; /* BYTE */ char* sbytefmt = "%s%d"; /* SBYTE */ char* shortfmt = "%s%u"; /* SHORT */ char* sshortfmt = "%s%d"; /* SSHORT */ char* longfmt = "%s%lu"; /* LONG */ char* slongfmt = "%s%ld"; /* SLONG */ char* rationalfmt = "%s%g"; /* RATIONAL */ char* srationalfmt = "%s%g"; /* SRATIONAL */ char* floatfmt = "%s%g"; /* FLOAT */ char* doublefmt = "%s%g"; /* DOUBLE */ static void dump(int, uint32); extern int optind; extern char* optarg; int main(int argc, char* argv[]) { int one = 1, fd; int multiplefiles = (argc > 1); int c; uint32 diroff = (uint32) 0; bigendian = (*(char *)&one == 0); while ((c = getopt(argc, argv, "o:h")) != -1) { switch (c) { case 'h': /* print values in hex */ shortfmt = "%s%#x"; sshortfmt = "%s%#x"; longfmt = "%s%#lx"; slongfmt = "%s%#lx"; break; case 'o': diroff = (uint32) strtoul(optarg, NULL, 0); break; default: fprintf(stderr, "usage: %s [-h] [files]\n", argv[0]); return (-1); } } for (; optind < argc; optind++) { fd = open(argv[optind], O_RDONLY|O_BINARY, 0); if (fd < 0) { perror(argv[0]); return (-1); } if (multiplefiles) printf("%s:\n", argv[optind]); curfile = argv[optind]; swabflag = 0; dump(fd, diroff); close(fd); } return (0); } static TIFFHeader hdr; #define ord(e) ((int)e) /* * Initialize shift & mask tables and byte * swapping state according to the file * byte order. */ static void InitByteOrder(int magic) { typemask[0] = 0; typemask[ord(TIFF_BYTE)] = 0xff; typemask[ord(TIFF_SBYTE)] = 0xff; typemask[ord(TIFF_UNDEFINED)] = 0xff; typemask[ord(TIFF_SHORT)] = 0xffff; typemask[ord(TIFF_SSHORT)] = 0xffff; typemask[ord(TIFF_LONG)] = 0xffffffff; typemask[ord(TIFF_SLONG)] = 0xffffffff; typemask[ord(TIFF_RATIONAL)] = 0xffffffff; typemask[ord(TIFF_SRATIONAL)] = 0xffffffff; typemask[ord(TIFF_FLOAT)] = 0xffffffff; typemask[ord(TIFF_DOUBLE)] = 0xffffffff; typeshift[0] = 0; typeshift[ord(TIFF_LONG)] = 0; typeshift[ord(TIFF_SLONG)] = 0; typeshift[ord(TIFF_RATIONAL)] = 0; typeshift[ord(TIFF_SRATIONAL)] = 0; typeshift[ord(TIFF_FLOAT)] = 0; typeshift[ord(TIFF_DOUBLE)] = 0; if (magic == TIFF_BIGENDIAN) { typeshift[ord(TIFF_BYTE)] = 24; typeshift[ord(TIFF_SBYTE)] = 24; typeshift[ord(TIFF_SHORT)] = 16; typeshift[ord(TIFF_SSHORT)] = 16; swabflag = !bigendian; } else { typeshift[ord(TIFF_BYTE)] = 0; typeshift[ord(TIFF_SBYTE)] = 0; typeshift[ord(TIFF_SHORT)] = 0; typeshift[ord(TIFF_SSHORT)] = 0; swabflag = bigendian; } } static uint32 ReadDirectory(int, unsigned, uint32); static void ReadError(char*); static void Error(const char*, ...); static void Fatal(const char*, ...); static void dump(int fd, uint32 diroff) { unsigned i; lseek(fd, (off_t) 0, 0); if (read(fd, (char*) &hdr, sizeof (hdr)) != sizeof (hdr)) ReadError("TIFF header"); /* * Setup the byte order handling. */ if (hdr.tiff_magic != TIFF_BIGENDIAN && hdr.tiff_magic != TIFF_LITTLEENDIAN) Fatal("Not a TIFF file, bad magic number %u (%#x)", hdr.tiff_magic, hdr.tiff_magic); InitByteOrder(hdr.tiff_magic); /* * Swap header if required. */ if (swabflag) { TIFFSwabShort(&hdr.tiff_version); TIFFSwabLong(&hdr.tiff_diroff); } /* * Now check version (if needed, it's been byte-swapped). * Note that this isn't actually a version number, it's a * magic number that doesn't change (stupid). */ if (hdr.tiff_version != TIFF_VERSION) Fatal("Not a TIFF file, bad version number %u (%#x)", hdr.tiff_version, hdr.tiff_version); printf("Magic: %#x <%s-endian> Version: %#x\n", hdr.tiff_magic, hdr.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", hdr.tiff_version); if (diroff == 0) diroff = hdr.tiff_diroff; for (i = 0; diroff != 0; i++) { if (i > 0) putchar('\n'); diroff = ReadDirectory(fd, i, diroff); } } static int datawidth[] = { 0, /* nothing */ 1, /* TIFF_BYTE */ 1, /* TIFF_ASCII */ 2, /* TIFF_SHORT */ 4, /* TIFF_LONG */ 8, /* TIFF_RATIONAL */ 1, /* TIFF_SBYTE */ 1, /* TIFF_UNDEFINED */ 2, /* TIFF_SSHORT */ 4, /* TIFF_SLONG */ 8, /* TIFF_SRATIONAL */ 4, /* TIFF_FLOAT */ 8, /* TIFF_DOUBLE */ }; #define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0])) static int TIFFFetchData(int, TIFFDirEntry*, void*); static void PrintTag(FILE*, uint16); static void PrintType(FILE*, uint16); static void PrintData(FILE*, uint16, uint32, unsigned char*); static void PrintByte(FILE*, const char*, TIFFDirEntry*); static void PrintShort(FILE*, const char*, TIFFDirEntry*); static void PrintLong(FILE*, const char*, TIFFDirEntry*); /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ static uint32 ReadDirectory(int fd, unsigned ix, uint32 off) { register TIFFDirEntry *dp; register int n; TIFFDirEntry *dir = 0; uint16 dircount; int space; uint32 nextdiroff = 0; if (off == 0) /* no more directories */ goto done; if (lseek(fd, (off_t) off, 0) != off) { Fatal("Seek error accessing TIFF directory"); goto done; } if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { ReadError("directory count"); goto done; } if (swabflag) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)_TIFFmalloc(dircount * sizeof (TIFFDirEntry)); if (dir == NULL) { Fatal("No space for TIFF directory"); goto done; } n = read(fd, (char*) dir, dircount*sizeof (*dp)); if (n != dircount*sizeof (*dp)) { n /= sizeof (*dp); Error( "Could only read %u of %u entries in directory at offset %#lx", n, dircount, (unsigned long) off); dircount = n; } if (read(fd, (char*) &nextdiroff, sizeof (uint32)) != sizeof (uint32)) nextdiroff = 0; if (swabflag) TIFFSwabLong(&nextdiroff); printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix, off, off, nextdiroff, nextdiroff); for (dp = dir, n = dircount; n > 0; n--, dp++) { if (swabflag) { TIFFSwabArrayOfShort(&dp->tdir_tag, 2); TIFFSwabArrayOfLong(&dp->tdir_count, 2); } PrintTag(stdout, dp->tdir_tag); putchar(' '); PrintType(stdout, dp->tdir_type); putchar(' '); printf("%u<", dp->tdir_count); if (dp->tdir_type >= NWIDTHS) { printf(">\n"); continue; } space = dp->tdir_count * datawidth[dp->tdir_type]; if (space <= 4) { switch (dp->tdir_type) { case TIFF_UNDEFINED: case TIFF_ASCII: { unsigned char data[4]; _TIFFmemcpy(data, &dp->tdir_offset, 4); if (swabflag) TIFFSwabLong((uint32*) data); PrintData(stdout, dp->tdir_type, dp->tdir_count, data); break; } case TIFF_BYTE: PrintByte(stdout, bytefmt, dp); break; case TIFF_SBYTE: PrintByte(stdout, sbytefmt, dp); break; case TIFF_SHORT: PrintShort(stdout, shortfmt, dp); break; case TIFF_SSHORT: PrintShort(stdout, sshortfmt, dp); break; case TIFF_LONG: PrintLong(stdout, longfmt, dp); break; case TIFF_SLONG: PrintLong(stdout, slongfmt, dp); break; } } else { unsigned char *data = (unsigned char *)_TIFFmalloc(space); if (data) { if (TIFFFetchData(fd, dp, data)) PrintData(stdout, dp->tdir_type, dp->tdir_count, data); _TIFFfree(data); } else Error("No space for data for tag %u", dp->tdir_tag); } printf(">\n"); } done: if (dir) _TIFFfree((char *)dir); return (nextdiroff); } static struct tagname { uint16 tag; char* name; } tagnames[] = { { TIFFTAG_SUBFILETYPE, "SubFileType" }, { TIFFTAG_OSUBFILETYPE, "OldSubFileType" }, { TIFFTAG_IMAGEWIDTH, "ImageWidth" }, { TIFFTAG_IMAGELENGTH, "ImageLength" }, { TIFFTAG_BITSPERSAMPLE, "BitsPerSample" }, { TIFFTAG_COMPRESSION, "Compression" }, { TIFFTAG_PHOTOMETRIC, "Photometric" }, { TIFFTAG_THRESHHOLDING, "Threshholding" }, { TIFFTAG_CELLWIDTH, "CellWidth" }, { TIFFTAG_CELLLENGTH, "CellLength" }, { TIFFTAG_FILLORDER, "FillOrder" }, { TIFFTAG_DOCUMENTNAME, "DocumentName" }, { TIFFTAG_IMAGEDESCRIPTION, "ImageDescription" }, { TIFFTAG_MAKE, "Make" }, { TIFFTAG_MODEL, "Model" }, { TIFFTAG_STRIPOFFSETS, "StripOffsets" }, { TIFFTAG_ORIENTATION, "Orientation" }, { TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel" }, { TIFFTAG_ROWSPERSTRIP, "RowsPerStrip" }, { TIFFTAG_STRIPBYTECOUNTS, "StripByteCounts" }, { TIFFTAG_MINSAMPLEVALUE, "MinSampleValue" }, { TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue" }, { TIFFTAG_XRESOLUTION, "XResolution" }, { TIFFTAG_YRESOLUTION, "YResolution" }, { TIFFTAG_PLANARCONFIG, "PlanarConfig" }, { TIFFTAG_PAGENAME, "PageName" }, { TIFFTAG_XPOSITION, "XPosition" }, { TIFFTAG_YPOSITION, "YPosition" }, { TIFFTAG_FREEOFFSETS, "FreeOffsets" }, { TIFFTAG_FREEBYTECOUNTS, "FreeByteCounts" }, { TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit" }, { TIFFTAG_GRAYRESPONSECURVE,"GrayResponseCurve" }, { TIFFTAG_GROUP3OPTIONS, "Group3Options" }, { TIFFTAG_GROUP4OPTIONS, "Group4Options" }, { TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit" }, { TIFFTAG_PAGENUMBER, "PageNumber" }, { TIFFTAG_COLORRESPONSEUNIT,"ColorResponseUnit" }, { TIFFTAG_TRANSFERFUNCTION, "TransferFunction" }, { TIFFTAG_SOFTWARE, "Software" }, { TIFFTAG_DATETIME, "DateTime" }, { TIFFTAG_ARTIST, "Artist" }, { TIFFTAG_HOSTCOMPUTER, "HostComputer" }, { TIFFTAG_PREDICTOR, "Predictor" }, { TIFFTAG_WHITEPOINT, "Whitepoint" }, { TIFFTAG_PRIMARYCHROMATICITIES,"PrimaryChromaticities" }, { TIFFTAG_COLORMAP, "Colormap" }, { TIFFTAG_HALFTONEHINTS, "HalftoneHints" }, { TIFFTAG_TILEWIDTH, "TileWidth" }, { TIFFTAG_TILELENGTH, "TileLength" }, { TIFFTAG_TILEOFFSETS, "TileOffsets" }, { TIFFTAG_TILEBYTECOUNTS, "TileByteCounts" }, { TIFFTAG_BADFAXLINES, "BadFaxLines" }, { TIFFTAG_CLEANFAXDATA, "CleanFaxData" }, { TIFFTAG_CONSECUTIVEBADFAXLINES, "ConsecutiveBadFaxLines" }, { TIFFTAG_SUBIFD, "SubIFD" }, { TIFFTAG_INKSET, "InkSet" }, { TIFFTAG_INKNAMES, "InkNames" }, { TIFFTAG_DOTRANGE, "DotRange" }, { TIFFTAG_TARGETPRINTER, "TargetPrinter" }, { TIFFTAG_EXTRASAMPLES, "ExtraSamples" }, { TIFFTAG_SAMPLEFORMAT, "SampleFormat" }, { TIFFTAG_SMINSAMPLEVALUE, "SMinSampleValue" }, { TIFFTAG_SMAXSAMPLEVALUE, "SMaxSampleValue" }, { TIFFTAG_JPEGPROC, "JPEGProcessingMode" }, { TIFFTAG_JPEGIFOFFSET, "JPEGInterchangeFormat" }, { TIFFTAG_JPEGIFBYTECOUNT, "JPEGInterchangeFormatLength" }, { TIFFTAG_JPEGRESTARTINTERVAL,"JPEGRestartInterval" }, { TIFFTAG_JPEGLOSSLESSPREDICTORS,"JPEGLosslessPredictors" }, { TIFFTAG_JPEGPOINTTRANSFORM,"JPEGPointTransform" }, { TIFFTAG_JPEGQTABLES, "JPEGQTables" }, { TIFFTAG_JPEGDCTABLES, "JPEGDCTables" }, { TIFFTAG_JPEGACTABLES, "JPEGACTables" }, { TIFFTAG_YCBCRCOEFFICIENTS,"YCbCrCoefficients" }, { TIFFTAG_YCBCRSUBSAMPLING, "YCbCrSubsampling" }, { TIFFTAG_YCBCRPOSITIONING, "YCbCrPositioning" }, { TIFFTAG_REFERENCEBLACKWHITE, "ReferenceBlackWhite" }, { TIFFTAG_REFPTS, "IgReferencePoints (Island Graphics)" }, { TIFFTAG_REGIONTACKPOINT, "IgRegionTackPoint (Island Graphics)" }, { TIFFTAG_REGIONWARPCORNERS,"IgRegionWarpCorners (Island Graphics)" }, { TIFFTAG_REGIONAFFINE, "IgRegionAffine (Island Graphics)" }, { TIFFTAG_MATTEING, "OBSOLETE Matteing (Silicon Graphics)" }, { TIFFTAG_DATATYPE, "OBSOLETE DataType (Silicon Graphics)" }, { TIFFTAG_IMAGEDEPTH, "ImageDepth (Silicon Graphics)" }, { TIFFTAG_TILEDEPTH, "TileDepth (Silicon Graphics)" }, { 32768, "OLD BOGUS Matteing tag" }, { TIFFTAG_COPYRIGHT, "Copyright" }, { TIFFTAG_JBIGOPTIONS, "JBIG Options" }, }; #define NTAGS (sizeof (tagnames) / sizeof (tagnames[0])) static void PrintTag(FILE* fd, uint16 tag) { register struct tagname *tp; for (tp = tagnames; tp < &tagnames[NTAGS]; tp++) if (tp->tag == tag) { fprintf(fd, "%s (%u)", tp->name, tag); return; } fprintf(fd, "%u (%#x)", tag, tag); } static void PrintType(FILE* fd, uint16 type) { static char *typenames[] = { "0", "BYTE", "ASCII", "SHORT", "LONG", "RATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", "SRATIONAL", "FLOAT", "DOUBLE" }; #define NTYPES (sizeof (typenames) / sizeof (typenames[0])) if (type < NTYPES) fprintf(fd, "%s (%u)", typenames[type], type); else fprintf(fd, "%u (%#x)", type, type); } #undef NTYPES static void PrintByte(FILE* fd, const char* fmt, TIFFDirEntry* dp) { char* sep = ""; if (hdr.tiff_magic != TIFF_LITTLEENDIAN) { switch ((int)dp->tdir_count) { case 4: fprintf(fd, fmt, sep, dp->tdir_offset&0xff); sep = " "; case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff); sep = " "; case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff); sep = " "; case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>24); } } else { switch ((int)dp->tdir_count) { case 4: fprintf(fd, fmt, sep, dp->tdir_offset>>24); sep = " "; case 3: fprintf(fd, fmt, sep, (dp->tdir_offset>>16)&0xff); sep = " "; case 2: fprintf(fd, fmt, sep, (dp->tdir_offset>>8)&0xff); sep = " "; case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xff); } } } static void PrintShort(FILE* fd, const char* fmt, TIFFDirEntry* dp) { char *sep = ""; if (hdr.tiff_magic != TIFF_LITTLEENDIAN) { switch (dp->tdir_count) { case 2: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff); sep = " "; case 1: fprintf(fd, fmt, sep, dp->tdir_offset>>16); } } else { switch (dp->tdir_count) { case 2: fprintf(fd, fmt, sep, dp->tdir_offset>>16); sep = " "; case 1: fprintf(fd, fmt, sep, dp->tdir_offset&0xffff); } } } static void PrintLong(FILE* fd, const char* fmt, TIFFDirEntry* dp) { fprintf(fd, fmt, "", (long) dp->tdir_offset); } #include static void PrintASCII(FILE* fd, uint32 cc, const unsigned char* cp) { for (; cc > 0; cc--, cp++) { const char* tp; if (isprint(*cp)) { fputc(*cp, fd); continue; } for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) if (*tp++ == *cp) break; if (*tp) fprintf(fd, "\\%c", *tp); else fprintf(fd, "\\%03o", *cp); } } static void PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) { char* sep = ""; switch (type) { case TIFF_BYTE: while (count-- > 0) fprintf(fd, bytefmt, sep, *data++), sep = " "; break; case TIFF_SBYTE: while (count-- > 0) fprintf(fd, sbytefmt, sep, *(char *)data++), sep = " "; break; case TIFF_UNDEFINED: while (count-- > 0) fprintf(fd, bytefmt, sep, *data++), sep = " "; break; case TIFF_ASCII: PrintASCII(fd, count, data); break; case TIFF_SHORT: { register uint16 *wp = (uint16*)data; while (count-- > 0) fprintf(fd, shortfmt, sep, *wp++), sep = " "; break; } case TIFF_SSHORT: { register int16 *wp = (int16*)data; while (count-- > 0) fprintf(fd, sshortfmt, sep, *wp++), sep = " "; break; } case TIFF_LONG: { register uint32 *lp = (uint32*)data; while (count-- > 0) { fprintf(fd, longfmt, sep, (unsigned long) *lp++); sep = " "; } break; } case TIFF_SLONG: { register int32 *lp = (int32*)data; while (count-- > 0) fprintf(fd, slongfmt, sep, (long) *lp++), sep = " "; break; } case TIFF_RATIONAL: { register uint32 *lp = (uint32*)data; while (count-- > 0) { if (lp[1] == 0) fprintf(fd, "%sNan (%lu/%lu)", sep, lp[0], lp[1]); else fprintf(fd, rationalfmt, sep, (double)lp[0] / (double)lp[1]); sep = " "; lp += 2; } break; } case TIFF_SRATIONAL: { register int32 *lp = (int32*)data; while (count-- > 0) { if (lp[1] == 0) fprintf(fd, "%sNan (%ld/%ld)", sep, lp[0], lp[1]); else fprintf(fd, srationalfmt, sep, (double)lp[0] / (double)lp[1]); sep = " "; lp += 2; } break; } case TIFF_FLOAT: { register float *fp = (float *)data; while (count-- > 0) fprintf(fd, floatfmt, sep, *fp++), sep = " "; break; } case TIFF_DOUBLE: { register double *dp = (double *)data; while (count-- > 0) fprintf(fd, doublefmt, sep, *dp++), sep = " "; break; } } } /* * Fetch a contiguous directory item. */ static int TIFFFetchData(int fd, TIFFDirEntry* dir, void* cp) { int cc, w; w = (dir->tdir_type < NWIDTHS ? datawidth[dir->tdir_type] : 0); cc = dir->tdir_count * w; if (lseek(fd, (off_t) dir->tdir_offset, 0) == dir->tdir_offset && read(fd, cp, cc) == cc) { if (swabflag) { switch (dir->tdir_type) { case TIFF_SHORT: case TIFF_SSHORT: TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); break; case TIFF_LONG: case TIFF_SLONG: TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); break; case TIFF_RATIONAL: case TIFF_DOUBLE: TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); break; } } return (cc); } Error("Error while reading data for tag %u", dir->tdir_tag); return (0); } static void ReadError(char* what) { Fatal("Error while reading %s", what); } #include static void vError(FILE* fd, const char* fmt, va_list ap) { fprintf(fd, "%s: ", curfile); vfprintf(fd, fmt, ap); fprintf(fd, ".\n"); } static void Error(const char* fmt, ...) { va_list ap; va_start(ap, fmt); vError(stderr, fmt, ap); va_end(ap); } static void Fatal(const char* fmt, ...) { va_list ap; va_start(ap, fmt); vError(stderr, fmt, ap); va_end(ap); exit(-1); } ->tdir_tag); return (0); } static void ReadError(char* what) { Fatal("Error while reading %s", what); } #include static void vError(FILE* fd, const char* fmt, va_list ap) { fprintf(fd, "%s: ", curfile); vfprintf(fd, fmt, ap); fprintf(fd, ".\n"); } static void Error(const char* fmt, ...) { va_list ap; va_start(ap, fmt); vError(stderr, fmt, ap); va_end(ap); } static void Fatal(const char* fmt, ...) { va_list ap; va_start(ap, fmttiff-v3.4beta018/tools/tiffinfo.c000444 004341 000024 00000024265 06003062773 016475 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffinfo.c,v 1.24 1995/06/12 15:43:49 sam Exp $ */ /* * Copyright (c) 1988-1995 Sam Leffler * Copyright (c) 1991-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) int showdata = 0; /* show data */ int rawdata = 0; /* show raw/decoded data */ int showwords = 0; /* show data as bytes/words */ int readdata = 0; /* read data in file */ int stoponerr = 1; /* stop on first read error */ static void usage(void); static void tiffinfo(TIFF*, uint16, long); int main(int argc, char* argv[]) { int dirnum = -1, multiplefiles, c; uint16 order = 0; TIFF* tif; extern int optind; extern char* optarg; long flags = 0; uint32 diroff = 0; while ((c = getopt(argc, argv, "f:o:cdDSjlmrsvw0123456789")) != -1) switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': dirnum = atoi(&argv[optind-1][1]); break; case 'd': showdata++; /* fall thru... */ case 'D': readdata++; break; case 'c': flags |= TIFFPRINT_COLORMAP | TIFFPRINT_CURVES; break; case 'f': /* fill order */ if (streq(optarg, "lsb2msb")) order = FILLORDER_LSB2MSB; else if (streq(optarg, "msb2lsb")) order = FILLORDER_MSB2LSB; else usage(); break; case 'i': stoponerr = 0; break; case 'o': diroff = strtoul(optarg, NULL, 0); break; case 'j': flags |= TIFFPRINT_JPEGQTABLES | TIFFPRINT_JPEGACTABLES | TIFFPRINT_JPEGDCTABLES; break; case 'r': rawdata = 1; break; case 's': flags |= TIFFPRINT_STRIPS; break; case 'w': showwords = 1; break; case '?': usage(); /*NOTREACHED*/ } if (optind >= argc) usage(); multiplefiles = (argc - optind > 1); for (; optind < argc; optind++) { if (multiplefiles) printf("%s:\n", argv[optind]); tif = TIFFOpen(argv[optind], "r"); if (tif != NULL) { if (dirnum != -1) { if (TIFFSetDirectory(tif, dirnum)) tiffinfo(tif, order, flags); } else if (diroff != 0) { if (TIFFSetSubDirectory(tif, diroff)) tiffinfo(tif, order, flags); } else { do tiffinfo(tif, order, flags); while (TIFFReadDirectory(tif)); } TIFFClose(tif); } } return (0); } char* stuff[] = { "usage: tiffinfo [options] input...", "where options are:", " -D read data", " -i ignore read errors", " -c display data for grey/color response curve or colormap", " -d display raw/decoded image data", " -f lsb2msb force lsb-to-msb FillOrder for input", " -f msb2lsb force msb-to-lsb FillOrder for input", " -j show JPEG tables", " -o offset set initial directory offset", " -r read/display raw image data instead of decoded data", " -s display strip offsets and byte counts", " -w display raw data in words rather than bytes", " -# set initial directory (first directory is # 0)", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } static void ShowStrip(tstrip_t strip, unsigned char* pp, uint32 nrow, tsize_t scanline) { register tsize_t cc; printf("Strip %lu:\n", (unsigned long) strip); while (nrow-- > 0) { for (cc = 0; cc < scanline; cc++) { printf(" %02x", *pp++); if (((cc+1) % 24) == 0) putchar('\n'); } putchar('\n'); } } void TIFFReadContigStripData(TIFF* tif) { unsigned char *buf; tsize_t scanline = TIFFScanlineSize(tif); buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); if (buf) { uint32 row, h; uint32 rowsperstrip = (uint32)-1; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); for (row = 0; row < h; row += rowsperstrip) { uint32 nrow = (row+rowsperstrip > h ? h-row : rowsperstrip); tstrip_t strip = TIFFComputeStrip(tif, row, 0); if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { if (stoponerr) break; } else if (showdata) ShowStrip(strip, buf, nrow, scanline); } _TIFFfree(buf); } } void TIFFReadSeparateStripData(TIFF* tif) { unsigned char *buf; tsize_t scanline = TIFFScanlineSize(tif); buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); if (buf) { uint32 row, h; uint32 rowsperstrip = (uint32)-1; tsample_t s, samplesperpixel; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); for (row = 0; row < h; row += rowsperstrip) { for (s = 0; s < samplesperpixel; s++) { uint32 nrow = (row+rowsperstrip > h ? h-row : rowsperstrip); tstrip_t strip = TIFFComputeStrip(tif, row, s); if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { if (stoponerr) break; } else if (showdata) ShowStrip(strip, buf, nrow, scanline); } } _TIFFfree(buf); } } static void ShowTile(uint32 row, uint32 col, tsample_t sample, unsigned char* pp, uint32 nrow, uint32 rowsize) { register tsize_t cc; printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col); if (sample != (tsample_t) -1) printf(",%u", sample); printf("):\n"); while (nrow-- > 0) { for (cc = 0; cc < rowsize; cc++) { printf(" %02x", *pp++); if (((cc+1) % 24) == 0) putchar('\n'); } putchar('\n'); } } void TIFFReadContigTileData(TIFF* tif) { unsigned char *buf; tsize_t rowsize = TIFFTileRowSize(tif); buf = (unsigned char *)_TIFFmalloc(TIFFTileSize(tif)); if (buf) { uint32 tw, th, w, h; uint32 row, col; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); for (row = 0; row < h; row += th) { for (col = 0; col < w; col += tw) { if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0) { if (stoponerr) break; } else if (showdata) ShowTile(row, col, (tsample_t) -1, buf, th, rowsize); } } _TIFFfree(buf); } } void TIFFReadSeparateTileData(TIFF* tif) { unsigned char *buf; tsize_t rowsize = TIFFTileRowSize(tif); buf = (unsigned char *)_TIFFmalloc(TIFFTileSize(tif)); if (buf) { uint32 tw, th, w, h; uint32 row, col; tsample_t s, samplesperpixel; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); for (row = 0; row < h; row += th) { for (col = 0; col < w; col += tw) { for (s = 0; s < samplesperpixel; s++) { if (TIFFReadTile(tif, buf, col, row, 0, s) < 0) { if (stoponerr) break; } else if (showdata) ShowTile(row, col, s, buf, th, rowsize); } } } _TIFFfree(buf); } } void TIFFReadData(TIFF* tif) { uint16 config; TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); if (TIFFIsTiled(tif)) { if (config == PLANARCONFIG_CONTIG) TIFFReadContigTileData(tif); else TIFFReadSeparateTileData(tif); } else { if (config == PLANARCONFIG_CONTIG) TIFFReadContigStripData(tif); else TIFFReadSeparateStripData(tif); } } static void ShowRawBytes(unsigned char* pp, uint32 n) { tsize_t i; for (i = 0; i < n; i++) { printf(" %02x", *pp++); if (((i+1) % 24) == 0) printf("\n "); } putchar('\n'); } static void ShowRawWords(uint16* pp, uint32 n) { tsize_t i; for (i = 0; i < n; i++) { printf(" %04x", *pp++); if (((i+1) % 15) == 0) printf("\n "); } putchar('\n'); } void TIFFReadRawData(TIFF* tif, int bitrev) { tstrip_t nstrips = TIFFNumberOfStrips(tif); const char* what = TIFFIsTiled(tif) ? "Tile" : "Strip"; uint32* stripbc; TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); if (nstrips > 0) { tsize_t bufsize = stripbc[0]; tdata_t buf = _TIFFmalloc(bufsize); tstrip_t s; for (s = 0; s < nstrips; s++) { if (stripbc[s] > bufsize) { buf = _TIFFrealloc(buf, stripbc[s]); bufsize = stripbc[s]; } if (buf == NULL) { fprintf(stderr, "Cannot allocate buffer to read strip %lu\n", (unsigned long) s); break; } if (TIFFReadRawStrip(tif, s, buf, stripbc[s]) < 0) { fprintf(stderr, "Error reading strip %lu\n", (unsigned long) s); if (stoponerr) break; } else if (showdata) { if (bitrev) { TIFFReverseBits(buf, stripbc[s]); printf("%s %lu: (bit reversed)\n ", what, (unsigned long) s); } else printf("%s %lu:\n ", what, (unsigned long) s); if (showwords) ShowRawWords((uint16*) buf, stripbc[s]>>1); else ShowRawBytes((unsigned char*) buf, stripbc[s]); } } if (buf != NULL) _TIFFfree(buf); } } static void tiffinfo(TIFF* tif, uint16 order, long flags) { TIFFPrintDirectory(tif, stdout, flags); if (!readdata) return; if (rawdata) { if (order) { uint16 o; TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &o); TIFFReadRawData(tif, o != order); } else TIFFReadRawData(tif, 0); } else { if (order) TIFFSetField(tif, TIFFTAG_FILLORDER, order); TIFFReadData(tif); } } se ShowRawBytes((unsigned char*) buf, stripbc[s]); } } if (buf != NULL) _TIFFfree(buf); } } static void tiffinfo(TIFF* tif, uint16 order, long flags) { TIFFPrintDirectory(tif, stdout, flags); if (!readdata) return; if (rawdata) { if (order) { uint16 o; TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORtiff-v3.4beta018/tools/tiffmedian.c000444 004341 000024 00000055316 06003062773 017000 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffmedian.c,v 1.17 1995/07/01 01:16:55 sam Exp $ */ /* * Apply median cut on an image. * * tiffmedian [-c n] [-f] input output * -C n - set colortable size. Default is 256. * -f - use Floyd-Steinberg dithering. * -c lzw - compress output with LZW * -c none - use no compression on output * -c packbits - use packbits compression on output * -r n - create output with n rows/strip of data * (by default the compression scheme and rows/strip are taken * from the input file) * * Notes: * * [1] Floyd-Steinberg dither: * I should point out that the actual fractions we used were, assuming * you are at X, moving left to right: * * X 7/16 * 3/16 5/16 1/16 * * Note that the error goes to four neighbors, not three. I think this * will probably do better (at least for black and white) than the * 3/8-3/8-1/4 distribution, at the cost of greater processing. I have * seen the 3/8-3/8-1/4 distribution described as "our" algorithm before, * but I have no idea who the credit really belongs to. * Also, I should add that if you do zig-zag scanning (see my immediately * previous message), it is sufficient (but not quite as good) to send * half the error one pixel ahead (e.g. to the right on lines you scan * left to right), and half one pixel straight down. Again, this is for * black and white; I've not tried it with color. * -- * Lou Steinberg * * [2] Color Image Quantization for Frame Buffer Display, Paul Heckbert, * Siggraph '82 proceedings, pp. 297-307 */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" #define MAX_CMAP_SIZE 256 #define streq(a,b) (strcmp(a,b) == 0) #define strneq(a,b,n) (strncmp(a,b,n) == 0) #define COLOR_DEPTH 8 #define MAX_COLOR 256 #define B_DEPTH 5 /* # bits/pixel to use */ #define B_LEN (1L< MAX_CMAP_SIZE) { fprintf(stderr, "-c: colormap too big, max %d\n", MAX_CMAP_SIZE); usage(); } break; case 'f': /* dither */ dither = 1; break; case 'r': /* rows/strip */ rowsperstrip = atoi(optarg); break; case '?': usage(); /*NOTREACHED*/ } if (argc - optind != 2) usage(); in = TIFFOpen(argv[optind], "r"); if (in == NULL) return (-1); TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); if (bitspersample != 8 && bitspersample != 16) { fprintf(stderr, "%s: Image must have at least 8-bits/sample\n", argv[optind]); return (-3); } if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric) || photometric != PHOTOMETRIC_RGB || samplesperpixel < 3) { fprintf(stderr, "%s: Image must have RGB data\n", argv[optind]); return (-4); } TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); if (config != PLANARCONFIG_CONTIG) { fprintf(stderr, "%s: Can only handle contiguous data packing\n", argv[optind]); return (-5); } /* * STEP 1: create empty boxes */ usedboxes = NULL; box_list = freeboxes = (Colorbox *)_TIFFmalloc(num_colors*sizeof (Colorbox)); freeboxes[0].next = &freeboxes[1]; freeboxes[0].prev = NULL; for (i = 1; i < num_colors-1; ++i) { freeboxes[i].next = &freeboxes[i+1]; freeboxes[i].prev = &freeboxes[i-1]; } freeboxes[num_colors-1].next = NULL; freeboxes[num_colors-1].prev = &freeboxes[num_colors-2]; /* * STEP 2: get histogram, initialize first box */ ptr = freeboxes; freeboxes = ptr->next; if (freeboxes) freeboxes->prev = NULL; ptr->next = usedboxes; usedboxes = ptr; if (ptr->next) ptr->next->prev = ptr; get_histogram(in, ptr); /* * STEP 3: continually subdivide boxes until no more free * boxes remain or until all colors assigned. */ while (freeboxes != NULL) { ptr = largest_box(); if (ptr != NULL) splitbox(ptr); else freeboxes = NULL; } /* * STEP 4: assign colors to all boxes */ for (i = 0, ptr = usedboxes; ptr != NULL; ++i, ptr = ptr->next) { rm[i] = ((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2; gm[i] = ((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2; bm[i] = ((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2; } /* We're done with the boxes now */ _TIFFfree(box_list); freeboxes = usedboxes = NULL; /* * STEP 5: scan histogram and map all values to closest color */ /* 5a: create cell list as described in Heckbert[2] */ ColorCells = (C_cell **)_TIFFmalloc(C_LEN*C_LEN*C_LEN*sizeof (C_cell*)); _TIFFmemset(ColorCells, 0, C_LEN*C_LEN*C_LEN*sizeof (C_cell*)); /* 5b: create mapping from truncated pixel space to color table entries */ map_colortable(); /* * STEP 6: scan image, match input values to table entries */ out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) return (-2); CopyField(TIFFTAG_SUBFILETYPE, longv); CopyField(TIFFTAG_IMAGEWIDTH, longv); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (short)COLOR_DEPTH); if (compression != (uint16)-1) { TIFFSetField(out, TIFFTAG_COMPRESSION, compression); switch (compression) { case COMPRESSION_LZW: case COMPRESSION_DEFLATE: if (predictor != 0) TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); break; } } else CopyField(TIFFTAG_COMPRESSION, compression); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, (short)PHOTOMETRIC_PALETTE); CopyField(TIFFTAG_ORIENTATION, shortv); TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (short)1); CopyField(TIFFTAG_PLANARCONFIG, shortv); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(out, rowsperstrip)); CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); CopyField(TIFFTAG_XRESOLUTION, floatv); CopyField(TIFFTAG_YRESOLUTION, floatv); CopyField(TIFFTAG_XPOSITION, floatv); CopyField(TIFFTAG_YPOSITION, floatv); if (dither) quant_fsdither(in, out); else quant(in, out); /* * Scale colormap to TIFF-required 16-bit values. */ #define SCALE(x) (((x)*((1L<<16)-1))/255) for (i = 0; i < MAX_CMAP_SIZE; ++i) { rm[i] = SCALE(rm[i]); gm[i] = SCALE(gm[i]); bm[i] = SCALE(bm[i]); } TIFFSetField(out, TIFFTAG_COLORMAP, rm, gm, bm); (void) TIFFClose(out); return (0); } static int processCompressOptions(char* opt) { if (streq(opt, "none")) compression = COMPRESSION_NONE; else if (streq(opt, "packbits")) compression = COMPRESSION_PACKBITS; else if (strneq(opt, "lzw", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_LZW; } else if (strneq(opt, "zip", 3)) { char* cp = strchr(opt, ':'); if (cp) predictor = atoi(cp+1); compression = COMPRESSION_DEFLATE; } else return (0); return (1); } char* stuff[] = { "usage: tiffmedian [options] input.tif output.tif", "where options are:", " -r # make each strip have no more than # rows", " -C # create a colormap with # entries", " -f use Floyd-Steinberg dithering", " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", " -c zip[:opts] compress output with deflate encoding", " -c packbits compress output with packbits encoding", " -c none use no compression algorithm on output", "", "LZW and deflate options:", " # set predictor value", "For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", NULL }; static void usage(void) { char buf[BUFSIZ]; int i; setbuf(stderr, buf); for (i = 0; stuff[i] != NULL; i++) fprintf(stderr, "%s\n", stuff[i]); exit(-1); } static void get_histogram(TIFF* in, Colorbox* box) { register unsigned char *inptr; register int red, green, blue; register uint32 j, i; unsigned char *inputline; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); if (inputline == NULL) { fprintf(stderr, "No space for scanline buffer\n"); exit(-1); } box->rmin = box->gmin = box->bmin = 999; box->rmax = box->gmax = box->bmax = -1; box->total = imagewidth * imagelength; { register int *ptr = &histogram[0][0][0]; for (i = B_LEN*B_LEN*B_LEN; i-- > 0;) *ptr++ = 0; } for (i = 0; i < imagelength; i++) { if (TIFFReadScanline(in, inputline, i, 0) <= 0) break; inptr = inputline; for (j = imagewidth; j-- > 0;) { red = *inptr++ >> COLOR_SHIFT; green = *inptr++ >> COLOR_SHIFT; blue = *inptr++ >> COLOR_SHIFT; if (red < box->rmin) box->rmin = red; if (red > box->rmax) box->rmax = red; if (green < box->gmin) box->gmin = green; if (green > box->gmax) box->gmax = green; if (blue < box->bmin) box->bmin = blue; if (blue > box->bmax) box->bmax = blue; histogram[red][green][blue]++; } } _TIFFfree(inputline); } static Colorbox * largest_box(void) { register Colorbox *p, *b; register int size; b = NULL; size = -1; for (p = usedboxes; p != NULL; p = p->next) if ((p->rmax > p->rmin || p->gmax > p->gmin || p->bmax > p->bmin) && p->total > size) size = (b = p)->total; return (b); } static void splitbox(Colorbox* ptr) { int hist2[B_LEN]; int first, last; register Colorbox *new; register int *iptr, *histp; register int i, j; register int ir,ig,ib; register int sum, sum1, sum2; enum { RED, GREEN, BLUE } axis; /* * See which axis is the largest, do a histogram along that * axis. Split at median point. Contract both new boxes to * fit points and return */ i = ptr->rmax - ptr->rmin; if (i >= ptr->gmax - ptr->gmin && i >= ptr->bmax - ptr->bmin) axis = RED; else if (ptr->gmax - ptr->gmin >= ptr->bmax - ptr->bmin) axis = GREEN; else axis = BLUE; /* get histogram along longest axis */ switch (axis) { case RED: histp = &hist2[ptr->rmin]; for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { *histp = 0; for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { iptr = &histogram[ir][ig][ptr->bmin]; for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) *histp += *iptr++; } histp++; } first = ptr->rmin; last = ptr->rmax; break; case GREEN: histp = &hist2[ptr->gmin]; for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { *histp = 0; for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { iptr = &histogram[ir][ig][ptr->bmin]; for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) *histp += *iptr++; } histp++; } first = ptr->gmin; last = ptr->gmax; break; case BLUE: histp = &hist2[ptr->bmin]; for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) { *histp = 0; for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { iptr = &histogram[ir][ptr->gmin][ib]; for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { *histp += *iptr; iptr += B_LEN; } } histp++; } first = ptr->bmin; last = ptr->bmax; break; } /* find median point */ sum2 = ptr->total / 2; histp = &hist2[first]; sum = 0; for (i = first; i <= last && (sum += *histp++) < sum2; ++i) ; if (i == first) i++; /* Create new box, re-allocate points */ new = freeboxes; freeboxes = new->next; if (freeboxes) freeboxes->prev = NULL; if (usedboxes) usedboxes->prev = new; new->next = usedboxes; usedboxes = new; histp = &hist2[first]; for (sum1 = 0, j = first; j < i; j++) sum1 += *histp++; for (sum2 = 0, j = i; j <= last; j++) sum2 += *histp++; new->total = sum1; ptr->total = sum2; new->rmin = ptr->rmin; new->rmax = ptr->rmax; new->gmin = ptr->gmin; new->gmax = ptr->gmax; new->bmin = ptr->bmin; new->bmax = ptr->bmax; switch (axis) { case RED: new->rmax = i-1; ptr->rmin = i; break; case GREEN: new->gmax = i-1; ptr->gmin = i; break; case BLUE: new->bmax = i-1; ptr->bmin = i; break; } shrinkbox(new); shrinkbox(ptr); } static void shrinkbox(Colorbox* box) { register int *histp, ir, ig, ib; if (box->rmax > box->rmin) { for (ir = box->rmin; ir <= box->rmax; ++ir) for (ig = box->gmin; ig <= box->gmax; ++ig) { histp = &histogram[ir][ig][box->bmin]; for (ib = box->bmin; ib <= box->bmax; ++ib) if (*histp++ != 0) { box->rmin = ir; goto have_rmin; } } have_rmin: if (box->rmax > box->rmin) for (ir = box->rmax; ir >= box->rmin; --ir) for (ig = box->gmin; ig <= box->gmax; ++ig) { histp = &histogram[ir][ig][box->bmin]; ib = box->bmin; for (; ib <= box->bmax; ++ib) if (*histp++ != 0) { box->rmax = ir; goto have_rmax; } } } have_rmax: if (box->gmax > box->gmin) { for (ig = box->gmin; ig <= box->gmax; ++ig) for (ir = box->rmin; ir <= box->rmax; ++ir) { histp = &histogram[ir][ig][box->bmin]; for (ib = box->bmin; ib <= box->bmax; ++ib) if (*histp++ != 0) { box->gmin = ig; goto have_gmin; } } have_gmin: if (box->gmax > box->gmin) for (ig = box->gmax; ig >= box->gmin; --ig) for (ir = box->rmin; ir <= box->rmax; ++ir) { histp = &histogram[ir][ig][box->bmin]; ib = box->bmin; for (; ib <= box->bmax; ++ib) if (*histp++ != 0) { box->gmax = ig; goto have_gmax; } } } have_gmax: if (box->bmax > box->bmin) { for (ib = box->bmin; ib <= box->bmax; ++ib) for (ir = box->rmin; ir <= box->rmax; ++ir) { histp = &histogram[ir][box->gmin][ib]; for (ig = box->gmin; ig <= box->gmax; ++ig) { if (*histp != 0) { box->bmin = ib; goto have_bmin; } histp += B_LEN; } } have_bmin: if (box->bmax > box->bmin) for (ib = box->bmax; ib >= box->bmin; --ib) for (ir = box->rmin; ir <= box->rmax; ++ir) { histp = &histogram[ir][box->gmin][ib]; ig = box->gmin; for (; ig <= box->gmax; ++ig) { if (*histp != 0) { box->bmax = ib; goto have_bmax; } histp += B_LEN; } } } have_bmax: ; } static C_cell * create_colorcell(int red, int green, int blue) { register int ir, ig, ib, i; register C_cell *ptr; int mindist, next_n; register int tmp, dist, n; ir = red >> (COLOR_DEPTH-C_DEPTH); ig = green >> (COLOR_DEPTH-C_DEPTH); ib = blue >> (COLOR_DEPTH-C_DEPTH); ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell)); *(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr; ptr->num_ents = 0; /* * Step 1: find all colors inside this cell, while we're at * it, find distance of centermost point to furthest corner */ mindist = 99999999; for (i = 0; i < num_colors; ++i) { if (rm[i]>>(COLOR_DEPTH-C_DEPTH) != ir || gm[i]>>(COLOR_DEPTH-C_DEPTH) != ig || bm[i]>>(COLOR_DEPTH-C_DEPTH) != ib) continue; ptr->entries[ptr->num_ents][0] = i; ptr->entries[ptr->num_ents][1] = 0; ++ptr->num_ents; tmp = rm[i] - red; if (tmp < (MAX_COLOR/C_LEN/2)) tmp = MAX_COLOR/C_LEN-1 - tmp; dist = tmp*tmp; tmp = gm[i] - green; if (tmp < (MAX_COLOR/C_LEN/2)) tmp = MAX_COLOR/C_LEN-1 - tmp; dist += tmp*tmp; tmp = bm[i] - blue; if (tmp < (MAX_COLOR/C_LEN/2)) tmp = MAX_COLOR/C_LEN-1 - tmp; dist += tmp*tmp; if (dist < mindist) mindist = dist; } /* * Step 3: find all points within that distance to cell. */ for (i = 0; i < num_colors; ++i) { if (rm[i] >> (COLOR_DEPTH-C_DEPTH) == ir && gm[i] >> (COLOR_DEPTH-C_DEPTH) == ig && bm[i] >> (COLOR_DEPTH-C_DEPTH) == ib) continue; dist = 0; if ((tmp = red - rm[i]) > 0 || (tmp = rm[i] - (red + MAX_COLOR/C_LEN-1)) > 0 ) dist += tmp*tmp; if ((tmp = green - gm[i]) > 0 || (tmp = gm[i] - (green + MAX_COLOR/C_LEN-1)) > 0 ) dist += tmp*tmp; if ((tmp = blue - bm[i]) > 0 || (tmp = bm[i] - (blue + MAX_COLOR/C_LEN-1)) > 0 ) dist += tmp*tmp; if (dist < mindist) { ptr->entries[ptr->num_ents][0] = i; ptr->entries[ptr->num_ents][1] = dist; ++ptr->num_ents; } } /* * Sort color cells by distance, use cheap exchange sort */ for (n = ptr->num_ents - 1; n > 0; n = next_n) { next_n = 0; for (i = 0; i < n; ++i) if (ptr->entries[i][1] > ptr->entries[i+1][1]) { tmp = ptr->entries[i][0]; ptr->entries[i][0] = ptr->entries[i+1][0]; ptr->entries[i+1][0] = tmp; tmp = ptr->entries[i][1]; ptr->entries[i][1] = ptr->entries[i+1][1]; ptr->entries[i+1][1] = tmp; next_n = i; } } return (ptr); } static void map_colortable(void) { register int *histp = &histogram[0][0][0]; register C_cell *cell; register int j, tmp, d2, dist; int ir, ig, ib, i; for (ir = 0; ir < B_LEN; ++ir) for (ig = 0; ig < B_LEN; ++ig) for (ib = 0; ib < B_LEN; ++ib, histp++) { if (*histp == 0) { *histp = -1; continue; } cell = *(ColorCells + (((ir>>(B_DEPTH-C_DEPTH)) << C_DEPTH*2) + ((ig>>(B_DEPTH-C_DEPTH)) << C_DEPTH) + (ib>>(B_DEPTH-C_DEPTH)))); if (cell == NULL ) cell = create_colorcell( ir << COLOR_SHIFT, ig << COLOR_SHIFT, ib << COLOR_SHIFT); dist = 9999999; for (i = 0; i < cell->num_ents && dist > cell->entries[i][1]; ++i) { j = cell->entries[i][0]; d2 = rm[j] - (ir << COLOR_SHIFT); d2 *= d2; tmp = gm[j] - (ig << COLOR_SHIFT); d2 += tmp*tmp; tmp = bm[j] - (ib << COLOR_SHIFT); d2 += tmp*tmp; if (d2 < dist) { dist = d2; *histp = j; } } } } /* * straight quantization. Each pixel is mapped to the colors * closest to it. Color values are rounded to the nearest color * table entry. */ static void quant(TIFF* in, TIFF* out) { unsigned char *outline, *inputline; register unsigned char *outptr, *inptr; register uint32 i, j; register int red, green, blue; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); outline = (unsigned char *)_TIFFmalloc(imagewidth); for (i = 0; i < imagelength; i++) { if (TIFFReadScanline(in, inputline, i, 0) <= 0) break; inptr = inputline; outptr = outline; for (j = 0; j < imagewidth; j++) { red = *inptr++ >> COLOR_SHIFT; green = *inptr++ >> COLOR_SHIFT; blue = *inptr++ >> COLOR_SHIFT; *outptr++ = histogram[red][green][blue]; } if (TIFFWriteScanline(out, outline, i, 0) < 0) break; } _TIFFfree(inputline); _TIFFfree(outline); } #define SWAP(type,a,b) { type p; p = a; a = b; b = p; } #define GetInputLine(tif, row, bad) \ if (TIFFReadScanline(tif, inputline, row, 0) <= 0) \ bad; \ inptr = inputline; \ nextptr = nextline; \ for (j = 0; j < imagewidth; ++j) { \ *nextptr++ = *inptr++; \ *nextptr++ = *inptr++; \ *nextptr++ = *inptr++; \ } #define GetComponent(raw, cshift, c) \ cshift = raw; \ if (cshift < 0) \ cshift = 0; \ else if (cshift >= MAX_COLOR) \ cshift = MAX_COLOR-1; \ c = cshift; \ cshift >>= COLOR_SHIFT; static void quant_fsdither(TIFF* in, TIFF* out) { unsigned char *outline, *inputline, *inptr; short *thisline, *nextline; register unsigned char *outptr; register short *thisptr, *nextptr; register uint32 i, j; uint32 imax, jmax; int lastline, lastpixel; imax = imagelength - 1; jmax = imagewidth - 1; inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); thisline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof (short)); nextline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof (short)); outline = (unsigned char *) _TIFFmalloc(TIFFScanlineSize(out)); GetInputLine(in, 0, goto bad); /* get first line */ for (i = 1; i < imagelength; ++i) { SWAP(short *, thisline, nextline); lastline = (i == imax); GetInputLine(in, i, break); thisptr = thisline; nextptr = nextline; outptr = outline; for (j = 0; j < imagewidth; ++j) { int red, green, blue; register int oval, r2, g2, b2; lastpixel = (j == jmax); GetComponent(*thisptr++, r2, red); GetComponent(*thisptr++, g2, green); GetComponent(*thisptr++, b2, blue); oval = histogram[r2][g2][b2]; if (oval == -1) { int ci; register int cj, tmp, d2, dist; register C_cell *cell; cell = *(ColorCells + (((r2>>(B_DEPTH-C_DEPTH)) << C_DEPTH*2) + ((g2>>(B_DEPTH-C_DEPTH)) << C_DEPTH ) + (b2>>(B_DEPTH-C_DEPTH)))); if (cell == NULL) cell = create_colorcell(red, green, blue); dist = 9999999; for (ci = 0; ci < cell->num_ents && dist > cell->entries[ci][1]; ++ci) { cj = cell->entries[ci][0]; d2 = (rm[cj] >> COLOR_SHIFT) - r2; d2 *= d2; tmp = (gm[cj] >> COLOR_SHIFT) - g2; d2 += tmp*tmp; tmp = (bm[cj] >> COLOR_SHIFT) - b2; d2 += tmp*tmp; if (d2 < dist) { dist = d2; oval = cj; } } histogram[r2][g2][b2] = oval; } *outptr++ = oval; red -= rm[oval]; green -= gm[oval]; blue -= bm[oval]; if (!lastpixel) { thisptr[0] += blue * 7 / 16; thisptr[1] += green * 7 / 16; thisptr[2] += red * 7 / 16; } if (!lastline) { if (j != 0) { nextptr[-3] += blue * 3 / 16; nextptr[-2] += green * 3 / 16; nextptr[-1] += red * 3 / 16; } nextptr[0] += blue * 5 / 16; nextptr[1] += green * 5 / 16; nextptr[2] += red * 5 / 16; if (!lastpixel) { nextptr[3] += blue / 16; nextptr[4] += green / 16; nextptr[5] += red / 16; } nextptr += 3; } } if (TIFFWriteScanline(out, outline, i-1, 0) < 0) break; } bad: _TIFFfree(inputline); _TIFFfree(thisline); _TIFFfree(nextline); _TIFFfree(outline); } += blue * 3 / 16; nextptr[-2] += green * 3 / 16; nextptr[-1] += red * 3 / 16; } nextptr[0] += blue * 5 / 16; nextptr[1] += green * 5 / 16; nextptr[2] += red * 5 / 16; if (!lastpixel) { nextptr[3] += blue / 16; nextptr[4] += green / 16; nextptr[5]tiff-v3.4beta018/tools/tiffsplit.c000444 004341 000024 00000014221 06003062773 016664 0ustar00samuser000000 000000 /* $Header: /usr/people/sam/tiff/tools/RCS/tiffsplit.c,v 1.11 1995/06/06 23:45:26 sam Exp $ */ /* * Copyright (c) 1992-1995 Sam Leffler * Copyright (c) 1992-1995 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. */ #if defined(unix) || defined(__unix) #include "port.h" #else #include #include #include #endif #include "tiffio.h" #define streq(a,b) (strcmp(a,b) == 0) #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #define CopyField2(tag, v1, v2) \ if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) #define CopyField3(tag, v1, v2, v3) \ if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) static char fname[1024+1]; static int tiffcp(TIFF*, TIFF*); static void newfilename(void); static int cpStrips(TIFF*, TIFF*); static int cpTiles(TIFF*, TIFF*); int main(int argc, char* argv[]) { TIFF *in, *out; if (argc < 2) { fprintf(stderr, "usage: tiffsplit input.tif [prefix]\n"); return (-3); } if (argc > 2) strcpy(fname, argv[2]); in = TIFFOpen(argv[1], "r"); if (in != NULL) { do { char path[1024+1]; newfilename(); strcpy(path, fname); strcat(path, ".tif"); out = TIFFOpen(path, "w"); if (out == NULL) return (-2); if (!tiffcp(in, out)) return (-1); TIFFClose(out); } while (TIFFReadDirectory(in)); (void) TIFFClose(in); } return (0); } static void newfilename(void) { static int first = 1; static long fnum; static short defname; static char *fpnt; if (first) { if (fname[0]) { fpnt = fname + strlen(fname); defname = 0; } else { fname[0] = 'x'; fpnt = fname + 1; defname = 1; } first = 0; } #define MAXFILES 676 if (fnum == MAXFILES) { if (!defname || fname[0] == 'z') { fprintf(stderr, "tiffsplit: too many files.\n"); exit(1); } fname[0]++; fnum = 0; } fpnt[0] = fnum / 26 + 'a'; fpnt[1] = fnum % 26 + 'a'; fnum++; } static int tiffcp(TIFF* in, TIFF* out) { short bitspersample, samplesperpixel, shortv, *shortav; uint32 w, l; float floatv; char *stringv; uint32 longv; CopyField(TIFFTAG_SUBFILETYPE, longv); CopyField(TIFFTAG_TILEWIDTH, w); CopyField(TIFFTAG_TILELENGTH, l); CopyField(TIFFTAG_IMAGEWIDTH, w); CopyField(TIFFTAG_IMAGELENGTH, l); CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); CopyField(TIFFTAG_COMPRESSION, shortv); CopyField(TIFFTAG_PREDICTOR, shortv); CopyField(TIFFTAG_PHOTOMETRIC, shortv); CopyField(TIFFTAG_THRESHHOLDING, shortv); CopyField(TIFFTAG_FILLORDER, shortv); CopyField(TIFFTAG_ORIENTATION, shortv); CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); CopyField(TIFFTAG_XRESOLUTION, floatv); CopyField(TIFFTAG_YRESOLUTION, floatv); CopyField(TIFFTAG_GROUP3OPTIONS, longv); CopyField(TIFFTAG_GROUP4OPTIONS, longv); CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); CopyField(TIFFTAG_PLANARCONFIG, shortv); CopyField(TIFFTAG_ROWSPERSTRIP, longv); CopyField(TIFFTAG_XPOSITION, floatv); CopyField(TIFFTAG_YPOSITION, floatv); CopyField(TIFFTAG_IMAGEDEPTH, longv); CopyField(TIFFTAG_TILEDEPTH, longv); CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); { uint16 *red, *green, *blue; CopyField3(TIFFTAG_COLORMAP, red, green, blue); } { uint16 shortv2; CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2); } CopyField(TIFFTAG_ARTIST, stringv); CopyField(TIFFTAG_IMAGEDESCRIPTION, stringv); CopyField(TIFFTAG_MAKE, stringv); CopyField(TIFFTAG_MODEL, stringv); CopyField(TIFFTAG_SOFTWARE, stringv); CopyField(TIFFTAG_DATETIME, stringv); CopyField(TIFFTAG_HOSTCOMPUTER, stringv); CopyField(TIFFTAG_PAGENAME, stringv); CopyField(TIFFTAG_DOCUMENTNAME, stringv); if (TIFFIsTiled(in)) return (cpTiles(in, out)); else return (cpStrips(in, out)); } static int cpStrips(TIFF* in, TIFF* out) { tsize_t bufsize = TIFFStripSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 *bytecounts; TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); for (s = 0; s < ns; s++) { if (bytecounts[s] > bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]); if (!buf) return (0); bufsize = bytecounts[s]; } if (TIFFReadRawStrip(in, s, buf, bytecounts[s]) < 0 || TIFFWriteRawStrip(out, s, buf, bytecounts[s]) < 0) { _TIFFfree(buf); return (0); } } _TIFFfree(buf); return (1); } return (0); } static int cpTiles(TIFF* in, TIFF* out) { tsize_t bufsize = TIFFTileSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf) { ttile_t t, nt = TIFFNumberOfTiles(in); uint32 *bytecounts; TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); for (t = 0; t < nt; t++) { if (bytecounts[t] > bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]); if (!buf) return (0); bufsize = bytecounts[t]; } if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 || TIFFWriteRawTile(out, t, buf, bytecounts[t]) < 0) { _TIFFfree(buf); return (0); } } _TIFFfree(buf); return (1); } return (0); } t, nt = TIFFNumberOfTiles(in); uint32 *bytecounts; TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); for (t = 0; t < nt; t++) { if (bytecounts[t] > bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]); if (!buf) return (0); bufsize = bytecounts[t]; } if (TIFFReadRawTile(in, t, buf, bytecounts[t]) < 0 || TItiff-v3.4beta018/tools/ycbcr.c000444 004341 000024 00000007771 06003062774 015777 0ustar00samuser000000 000000 float ycbcrCoeffs[3] = { .299, .587, .114 }; /* default coding range is CCIR Rec 601-1 with no headroom/footroom */ unsigned long refBlackWhite[6] = { 0, 255, 128, 255, 128, 255 }; #define LumaRed ycbcrCoeffs[0] #define LumaGreen ycbcrCoeffs[1] #define LumaBlue ycbcrCoeffs[2] long eRtotal = 0; long eGtotal = 0; long eBtotal = 0; long preveRtotal = 0; long preveGtotal = 0; long preveBtotal = 0; unsigned long AbseRtotal = 0; unsigned long AbseGtotal = 0; unsigned long AbseBtotal = 0; unsigned long eCodes = 0; unsigned long preveCodes = 0; unsigned long eBits = 0; unsigned long preveBits = 0; static void setupLumaTables(); static int abs(int v) { return (v < 0 ? -v : v); } static double pct(int v,double range) { return (v*100. / range); } float D1, D2; float D3, D4; float D5, D6; int main(int argc, char* argv) { int R, G, B; if (argc > 1) { refBlackWhite[0] = 16; refBlackWhite[1] = 235; refBlackWhite[2] = 128; refBlackWhite[3] = 240; refBlackWhite[4] = 128; refBlackWhite[5] = 240; } D3 = 2 - 2*LumaRed; D4 = 2 - 2*LumaBlue; D1 = 1. / D3; D2 = 1. / D4; D5 = D3*LumaRed / LumaGreen; D6 = D4*LumaBlue / LumaGreen; setupLumaTables(); for (R = 0; R < 256; R++) { for (G = 0; G < 256; G++) for (B = 0; B < 256; B++) check(R, G, B); printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n" , R , eCodes - preveCodes, eCodes , eBits - preveBits, eBits , abs(AbseRtotal - preveRtotal), eRtotal , AbseRtotal , abs(AbseGtotal - preveGtotal), eGtotal , AbseGtotal , abs(AbseBtotal - preveBtotal), eBtotal , AbseBtotal ); preveRtotal = AbseRtotal; preveGtotal = AbseGtotal; preveBtotal = AbseBtotal; preveCodes = eCodes; preveBits = eBits; } printf("%u total codes\n", 256*256*256); printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n" , eCodes , eBits , eRtotal , AbseRtotal , eGtotal , AbseGtotal , eBtotal , AbseBtotal ); return (0); } float *lumaRed; float *lumaGreen; float *lumaBlue; static float* setupLuma(float c) { float *v = (float *)_TIFFmalloc(256 * sizeof (float)); int i; for (i = 0; i < 256; i++) v[i] = c * i; return (v); } static void setupLumaTables(void) { lumaRed = setupLuma(LumaRed); lumaGreen = setupLuma(LumaGreen); lumaBlue = setupLuma(LumaBlue); } static unsigned V2Code(float f, unsigned long RB, unsigned long RW, int CR) { unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5); return (c > 255 ? 255 : c); } #define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB)) #define CLAMP(f,min,max) \ (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5) void check(int R, int G, int B) { float Y, Cb, Cr; int iY, iCb, iCr; float rY, rCb, rCr; float rR, rG, rB; int eR, eG, eB; Y = lumaRed[R] + lumaGreen[G] + lumaBlue[B]; Cb = (B - Y)*D2; Cr = (R - Y)*D1; iY = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255); iCb = V2Code(Cb, refBlackWhite[2], refBlackWhite[3], 127); iCr = V2Code(Cr, refBlackWhite[4], refBlackWhite[5], 127); rCb = Code2V(iCb, refBlackWhite[2], refBlackWhite[3], 127); rCr = Code2V(iCr, refBlackWhite[4], refBlackWhite[5], 127); rY = Code2V(iY, refBlackWhite[0], refBlackWhite[1], 255); rR = rY + rCr*D3; rB = rY + rCb*D4; rG = rY - rCb*D6 - rCr*D5; eR = R - CLAMP(rR,0,255); eG = G - CLAMP(rG,0,255); eB = B - CLAMP(rB,0,255); if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1) { printf("R %u G %u B %u", R, G, B); printf(" Y %g Cb %g Cr %g", Y, Cb, Cr); printf(" iY %u iCb %u iCr %u", iY, iCb, iCr); printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr); printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n" , rR, CLAMP(rR,0,255) , rG, CLAMP(rG,0,255) , rB, CLAMP(rB,0,255) , eR, eG, eB ); } eRtotal += eR; eGtotal += eG; eBtotal += eB; AbseRtotal += abs(eR); AbseGtotal += abs(eG); AbseBtotal += abs(eB); if (eR | eG | eB) eCodes++; eBits += abs(eR) + abs(eG) + abs(eB); } f(" Y %tiff-v3.4beta018/man/Makefile.in000444 004341 000024 00000013401 06003062774 016174 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/man/RCS/Makefile.in,v 1.4 1995/06/28 04:40:37 sam Exp $ # # @WARNING@ # # Tag Image File Format Library Manual Pages # # Copyright (c) 1991-1995 Sam Leffler # Copyright (c) 1991-1995 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 Stanford 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. # DEPTH = .. SRCDIR = ${DEPTH}/@SRCDIR@/man VPATH = ../@SRCDIR@/man PORT = ${DEPTH}/port # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = ECHO = echo MV = mv RM = rm -f INSTALL = @INSTALL@ MAN = @DIR_MAN@ MANTOOLS=\ fax2tiff.1 \ fax2ps.1 \ gif2tiff.1 \ pal2rgb.1 \ ppm2tiff.1 \ ras2tiff.1 \ rgb2ycbcr.1 \ sgi2tiff.1 \ thumbnail.1 \ tiff2bw.1 \ tiff2ps.1 \ tiffcmp.1 \ tiffcp.1 \ tiffdither.1 \ tiffdump.1 \ tiffgt.1 \ tiffinfo.1 \ tiffmedian.1 \ tiffsplit.1 \ tiffsv.1 \ ${NULL} MANDEVLINKS=\ TIFFComputeTile.3t \ TIFFCheckTile.3t \ TIFFNumberOfTiles.3t \ TIFFComputeStrip.3t \ TIFFNumberOfStrips.3t \ TIFFCurrentDirectory.3t \ TIFFCurrentRow.3t \ TIFFCurrentStrip.3t \ TIFFCurrentTile.3t \ TIFFFdOpen.3t \ TIFFFileName.3t \ TIFFFileno.3t \ TIFFFlushData.3t \ TIFFGetMode.3t \ TIFFIsTiled.3t \ TIFFReverseBits.3t \ TIFFSetErrorHandler.3t \ TIFFSetWarningHandler.3t \ TIFFSwabArrayOfLong.3t \ TIFFSwabArrayOfShort.3t \ TIFFSwabLong.3t \ TIFFSwabShort.3t \ TIFFScanlineSize.3t \ TIFFStripSize.3t \ TIFFTileSize.3t \ TIFFVGetField.3t \ TIFFVSetField.3t \ ${NULL} MANDEV=\ TIFFClose.3t \ TIFFError.3t \ TIFFFlush.3t \ TIFFGetField.3t \ TIFFOpen.3t \ TIFFPrintDirectory.3t \ TIFFReadDirectory.3t \ TIFFReadEncodedStrip.3t \ TIFFReadEncodedTile.3t \ TIFFReadRGBAImage.3t \ TIFFReadRawStrip.3t \ TIFFReadRawTile.3t \ TIFFReadScanline.3t \ TIFFReadTile.3t \ TIFFSetDirectory.3t \ TIFFSetField.3t \ TIFFWarning.3t \ TIFFWriteDirectory.3t \ TIFFWriteEncodedStrip.3t \ TIFFWriteEncodedTile.3t \ TIFFWriteRawStrip.3t \ TIFFWriteRawTile.3t \ TIFFWriteScanline.3t \ intro.3t \ query.3t \ size.3t \ strip.3t \ swab.3t \ tile.3t \ ${NULL} TARGETS = ${MANTOOLS} ${MANDEV} ${MANDEVLINKS} all: ${TARGETS} install: all ${INSTALL} -m 755 -dir -idb tiff.man.tools ${MAN} ${INSTALL} -m 755 -dir -idb tiff.man.tools ${MAN}/man1 for i in ${MANTOOLS}; do \ ${INSTALL} -idb tiff.man.tools -m 444 -F ${MAN}/man1 \ -src ${SRCDIR}/$$i -O $$i; \ done ${INSTALL} -m 755 -dir -idb tiff.man.dev ${MAN}/man3 for i in ${MANDEV}; do \ ${INSTALL} -idb tiff.man.dev -m 444 -F ${MAN}/man3 \ -src ${SRCDIR}/$$i -O $$i; \ done ${INSTALL} -idb tiff.man.dev -m 444 -F ${MAN}/man3 -O ${MANDEVLINKS} clean: ${RM} ${MANDEVLINKS} TIFFComputeTile.3t:; ${ECHO} ".so tile.3t" > $@ TIFFCheckTile.3t:; ${ECHO} ".so tile.3t" > $@ TIFFNumberOfTiles.3t:; ${ECHO} ".so tile.3t" > $@ TIFFComputeStrip.3t:; ${ECHO} ".so strip.3t" > $@ TIFFNumberOfStrips.3t:; ${ECHO} ".so strip.3t" > $@ TIFFCurrentDirectory.3t:; ${ECHO} ".so query.3t" > $@ TIFFCurrentRow.3t:; ${ECHO} ".so query.3t" > $@ TIFFCurrentStrip.3t:; ${ECHO} ".so query.3t" > $@ TIFFCurrentTile.3t:; ${ECHO} ".so query.3t" > $@ TIFFFdOpen.3t:; ${ECHO} ".so TIFFOpen.3t" > $@ TIFFFileName.3t:; ${ECHO} ".so query.3t" > $@ TIFFFileno.3t:; ${ECHO} ".so query.3t" > $@ TIFFFlushData.3t:; ${ECHO} ".so TIFFFlush.3t" > $@ TIFFGetMode.3t:; ${ECHO} ".so query.3t" > $@ TIFFIsTiled.3t:; ${ECHO} ".so query.3t" > $@ TIFFReverseBits.3t:; ${ECHO} ".so swab.3t" > $@ TIFFSetErrorHandler.3t:; ${ECHO} ".so TIFFError.3t" > $@ TIFFSetWarningHandler.3t:; ${ECHO} ".so TIFFWarning.3t" > $@ TIFFSwabArrayOfLong.3t:; ${ECHO} ".so swab.3t" > $@ TIFFSwabArrayOfShort.3t:; ${ECHO} ".so swab.3t" > $@ TIFFSwabLong.3t:; ${ECHO} ".so swab.3t" > $@ TIFFSwabShort.3t:; ${ECHO} ".so swab.3t" > $@ TIFFScanlineSize.3t:; ${ECHO} ".so size.3t" > $@ TIFFStripSize.3t:; ${ECHO} ".so size.3t" > $@ TIFFTileSize.3t:; ${ECHO} ".so size.3t" > $@ TIFFVGetField.3t:; ${ECHO} ".so TIFFGetField.3t" > $@ TIFFVSetField.3t:; ${ECHO} ".so TIFFSetField.3t" > $@ links: ${MANDEVLINKS} short: ${MV} TIFFClose.3t close.3t ${MV} TIFFError.3t error.3t ${MV} TIFFFlush.3t flush.3t ${MV} TIFFGetField.3t getfield.3t ${MV} TIFFOpen.3t open.3t ${MV} TIFFPrintDirectory.3t print.3t ${MV} TIFFReadEncodedStrip.3t rdestrip.3t ${MV} TIFFReadencodedTile.3t rdetile.3t ${MV} TIFFReadRawStrip.3t rdrstrip.3t ${MV} TIFFReadRawTile.3t rdrtile.3t ${MV} TIFFReadDirectory.3t readdir.3t ${MV} TIFFReadScanline.3t readline.3t ${MV} TIFFReadTile.3t readtile.3t ${MV} TIFFSetDirectory.3t setdir.3t ${MV} TIFFSetField.3t setfield.3t ${MV} TIFFWarning.3t warning.3t ${MV} TIFFWriteEncodedStrip.3t wrestrip.3t ${MV} TIFFWriteEncodedTile.3t wretile.3t ${MV} TIFFWriteDirectory.3t writedir.3t ${MV} TIFFWriteRawStrip.3t wrrstrip.3t ${MV} TIFFWriteRawTile.3t wrrtile.3t ${MV} TIFFWriteScanline.3t writeline.3t drstrip.3t ${MV} TIFFReadRawTile.3t rdrtile.3t ${MV} TIFFReadDirectory.3t readdir.3t ${MV} TIFFReadScanline.3t readline.3t ${MV} TIFFReadTile.3t readtile.3t ${MV} TIFFSetDirectory.3t setdir.3t ${MV} TIFFSetField.3t setfield.3t ${MV} TIFFWarning.3t tiff-v3.4beta018/man/fax2tiff.1000444 004341 000024 00000013414 06003062775 015727 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/fax2tiff.1,v 1.16 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH FAX2TIFF 1 "September 24, 1994" .SH NAME fax2tiff \- create a .SM TIFF Class F fax file from raw fax data .SH SYNOPSIS .B fax2tiff [ .I options ] [ .B \-o .I output.tif ] .I input.g3 .SH DESCRIPTION .I Fax2tiff creates a .SM TIFF file containing .SM CCITT Group 3 or Group 4 encoded data from one or more files containing ``raw'' Group 3 encoded data (typically obtained directly from a fax modem). By default, each row of data in the resultant .SM TIFF file is 2-dimensionally encoded and padded or truncated to 1728 pixels, as needed. The resultant image is a set of low resolution (98 lines/inch) or medium resolution (196 lines/inch) pages, each of which is a single strip of data. The generated file conforms to the .SM TIFF Class F (\c .SM FAX\c ) specification for storing facsimile data. This means, in particular, that each page of the data does .B not include the trailing .I "return to control" (\c .SM RTC\c ) code; as required for transmission by the .SM CCITT Group 3 specifications. The old, ``classic'', format is created if the .B \-c option is used. (The Class F format can also be requested with the .B \-f option.) .PP The default name of the output image is .IR fax.tif ; this can be changed with the .B \-o option. Each input file is assumed to be a separate page of facsimile data from the same document. The order in which input files are specified on the command line is the order in which the resultant pages appear in the output file. .SH OPTIONS Options that affect the interpretation of input data are: .TP .B \-2 Assume input data is 2-d Huffman encoded. .TP .B \-B Assume input data was encoded with black as 0 and white as 1. .TP .B \-L Treat input data as having bits filled from least significant bit (\c .SM LSB\c ) to most significant bit (\c .SM MSB\c ). (This is the default.) .TP .B \-M Treat input data as having bits filled from most significant bit (\c .SM MSB\c ) to most least bit (\c .SM LSB\c ). .TP .B \-R Specify the vertical resolution, in lines/inch, of the input images. By default input are assumed to have a vertical resolution of 196 lines/inch. If images are low resolution facsimile, a value of 98 lines/inch should be specified. .TP .B \-W Assume input data was encoded with black as 1 and white as 0. (This is the default.) .PP Options that affect the output file format are: .TP .B \-1 Force output to be compressed with the 1-dimensional version of the .SM CCITT Group 3 Huffman encoding algorithm. .TP .B \-4 Force output to be compressed with the .SM CCITT Group 4 Huffman encoding. .TP .B \-o Specify the name of the output file. .TP .B \-p Force the last bit of each .I "End Of Line" (\c .SM EOL\c ) code to land on a byte boundary. This ``zero padding'' will be reflected in the contents of the .I Group3Options tag of the resultant .SM TIFF file. .TP .B \-s Stretch the input image vertically by writing each input row of data twice to the output file. .TP .B \-v Force .I fax2tiff to print the number of rows of data it retrieved from the input file. .SH DIAGNOSTICS The following warnings and errors come from the decoding routines in the library. .PP .BR "Warning, %s: Premature EOL at scanline %d (x %d).\en" . The input data had a row that was shorter than the expected value of 1728. The row is padded with white. .PP .BR "%s: Premature EOF at scanline %d (x %d).\en" . The decoder ran out of data in the middle of a scanline. The resultant row is padded with white. .PP .BR "%s: Bad code word at row %d, x %d\en" . An invalid Group 3 .I code was encountered while decoding the input file. The row number and horizontal position is given. The remainder of the input row is discarded, while the corresponding output row is padded with white. .PP .BR "%s: Bad 2D code word at scanline %d.\en" . An invalid Group 4 or 2D Group 3 .I code was encountered while decoding the input file. The row number and horizontal position is given. The remainder of the input row is discarded, while the corresponding output row is padded with white. .SH BUGS Should not have the constant width 1728 built into it. Input data are assumed to have a a ``top left'' orientation; it should be possible to override this assumption from the command line. .SH "SEE ALSO" .I "\s-1CCITT\s+1 Recommendation T.4" (Standardization of Group 3 Facsimile Apparatus for Document Transmission). .PP .IR "The Spirit of TIFF Class F" , an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. .PP .IR tiffinfo (1), .IR tiffdither (1), .IR tiffgt (1), .IR libtiff (3). BUGS Should not have the constant width 1728 built into it. Input data are assumed to have a a ``top left'' orientation; it should be possible to override this assumption from the command line. .SH "SEE ALSO" .I "\s-1CCITT\s+1 Recommendation T.tiff-v3.4beta018/man/fax2ps.1000444 004341 000024 00000011241 06003062775 015415 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/fax2ps.1,v 1.9 1995/07/05 18:52:42 sam Exp $ .\" .\" Copyright (c) 1991-1995 Sam Leffler .\" Copyright (c) 1991-1995 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. .\" .if n .po 0 .ds Ps P\s-2OST\s+2S\s-2CRIPT\s+2 .TH FAX2PS 1 "March 16, 1995" .SH NAME fax2ps \- convert a .SM TIFF facsimile to compressed \*(Ps\(tm .SH SYNOPSIS .B fax2ps [ .I options ] [ .IR file ... ] .SH DESCRIPTION .I fax2ps reads one or more .SM TIFF facsimile image files and prints a compressed form of \*(Ps on the standard output that is suitable for printing. .PP By default, each page is scaled to reflect the image dimensions and resolutions stored in the file. The .B \-x and .B \-y options can be used to specify the horizontal and vertical image resolutions (lines/inch), respectively. If the .B \-S option is specified, each page is scaled to fill an output page. The default output page is 8.5 by 11 inches. Alternate page dimensions can be specified in inches with the .B \-W and .B \-H options. .PP By default .I fax2ps generates \*(Ps for all pages in the file. The .B \-p option can be used to select one or more pages from a multi-page document. .PP .I fax2ps generates a compressed form of \*(Ps that is optimized for sending pages of text to a \*(Ps printer attached to a host through a low-speed link (such as a serial line). Each output page is filled with white and then only the black areas are drawn. The \*(Ps specification of the black drawing operations is optimized by using a special font that encodes the move-draw operations required to fill the black regions on the page. This compression scheme typically results in a substantially reduced \*(Ps description, relative to the straightforward imaging of the page with a \*(Ps .I image operator. This algorithm can, however, be ineffective for continuous-tone and white-on-black images. For these images, it sometimes is more efficient to send the raster bitmap image directly; see .IR tiff2ps (1). .SH OPTIONS .TP 10 .BI \-p " number" Print only the indicated page. Multiple pages may be printed by specifying this option more than once. .TP 10 .BI \-x " resolution" Use .I resolution as the horizontal resolution, in dots/inch, of the image data. By default this value is taken from the file. .TP 10 .BI \-y " resolution" Use .I resolution as the vertical resolution, in lines/inch, of the image data. By default this value is taken from the file. .TP 10 .B \-S Scale each page of image data to fill the output page dimensions. By default images are presented according to the dimension information recorded in the .SM TIFF file. .TP 10 .BI \-W " width" Use .I width as the width, in inches, of the output page. The default page width is 8.5 inches. .TP 10 .BI \-H " height" Use .I height as the height, in inches, of the output page. The default page height is 11 inches. .SH DIAGNOSTICS Some messages about malformed .SM TIFF images come from the .SM TIFF library. .PP Various messages about badly formatted facsimile images may be generated due to transmission errors in received facsimile. .I fax2ps attempts to recover from such data errors by resynchronizing decoding at the end of the current scanline. This can result in long horizontal black lines in the resultant \*(Ps image. .SH NOTES If the destination printer supports \*(Ps Level II then it is always faster to just send the encoded bitmap generated by the .IR tiff2ps (1) program. .SH BUGS .I fax2ps should probably figure out when it is doing a poor job of compressing the output and just generate \*(Ps to image the bitmap raster instead. .SH "SEE ALSO" .IR tiff2ps (1), .IR libtiff (3) s by resynchronizing decoding at the end of the current scanline. This can result in long horizontal black lines in the resultant \*(Ps image. .SH NOTES If the destination printer supports \*(Ps Level II then it is always faster to just send the encoded bitmap generated by the .IR tiff2ps (1) program. .SH BUGS .I fax2ps should probably figure out whtiff-v3.4beta018/man/gif2tiff.1000444 004341 000024 00000004745 06003062775 015725 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/gif2tiff.1,v 1.6 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH GIF2TIFF 1 "September 26, 1994" .SH NAME gif2tiff \- create a .SM TIFF file from a GIF87 format image file .SH SYNOPSIS .B gif2tiff [ .I options ] .I input.gif .I output.tif .SH DESCRIPTION .I Gif2tiff converts a file in the GIF87 format to .SM TIFF. The .SM TIFF image is created as a palette image, with samples compressed with the Lempel-Ziv & Welch algorithm (\c .IR Compression =5). These characteristics can overriden, or explicitly specified with the options described below. .SH OPTIONS .TP .B \-c Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .SH NOTES The program is based on Paul Haeberli's .I fromgif program which, in turn, is based on Marcel J.E. Mol's GIF reader. .SH BUGS Should have more options to control output format. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) thm), and .B "\-c lzw" for tiff-v3.4beta018/man/pal2rgb.1000444 004341 000024 00000006304 06003062776 015550 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/pal2rgb.1,v 1.11 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH PAL2RGB 1 "September 26, 1994" .SH NAME pal2rgb \- convert a palette color .SM TIFF image to a full color image .SH SYNOPSIS .B pal2rgb [ .I options ] .I input.tif .I output.tif .SH DESCRIPTION .I Pal2rgb converts a palette color .SM TIFF image to a full color image by applying the colormap of the palette image to each sample to generate a full color .SM RGB image. .SH OPTIONS Options that affect the interpretation of input data are: .TP .B \-C This option overrides the default behaviour of .I pal2rgb in determining whether or not colormap entries contain 16-bit or 8-bit values. By default the colormap is inspected and if no colormap entry greater than 255 is found, the colormap is assumed to have only 8-bit values; otherwise 16-bit values (as required by the .SM TIFF specification) are assumed. The .B \-C option can be used to explicitly specify the number of bits for colormap entries: .B "\-C 8" for 8-bit values, .B "\-C 16" for 16-bit values. .PP Options that affect the output file format are: .TP .B \-p Explicitly select the planar configuration used in organizing data samples in the output image: .B "\-p contig" for samples packed contiguously, and .B "\-p separate" for samples stored separately. By default samples are packed. .TP .B \-c Use the specific compression algorithm to encoded image data in the output file: .B "\-c packbits" for Macintosh Packbits, .B "\-c lzw" for Lempel-Ziv & Welch, .B "\-c none" for no compression. If no compression-related option is specified, the input file's compression algorithm is used. .TP .B \-r Explicitly specify the number of rows in each strip of the output file. If the .B \-r option is not specified, a number is selected such that each output strip has approximately 8 kilobytes of data in it. .SH BUGS Only 8-bit images are handled. .SH "SEE ALSO" .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) its, .B "\-c lzw" for Lempel-Ziv & Welch, .B "\-c none" for no compression. If no compression-related option is specified, the input file's compression algorithm is used. .TP .B \-r Explicitly specify the number of rows in each strip of the output file. If the .B \-r option is not specified, a number is selected sutiff-v3.4beta018/man/ppm2tiff.1000444 004341 000024 00000005325 06003062776 015750 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/ppm2tiff.1,v 1.7 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH PPM2TIFF 1 "September 26, 1994" .SH NAME ppm2tiff \- create a .SM TIFF file from a .SM PPM image file .SH SYNOPSIS .B ppm2tiff [ .I options ] ] [ .I input.ppm ] .I output.tif .SH DESCRIPTION .I ppm2tiff converts a file in the .SM PPM image format to .SM TIFF. By default, the .SM TIFF image is created with data samples packed (\c .IR PlanarConfiguration =1), compressed with the Lempel-Ziv & Welch algorithm (\c .IR Compression =5), and with each strip no more than 8 kilobytes. These characteristics can be overriden, or explicitly specified with the options described below .PP If the .SM PPM file contains greyscale data, then the .I PhotometricInterpretation tag is set to 1 (min-is-black), otherwise it is set to 2 (RGB). .PP If no .SM PPM file is specified on the command line, .I ppm2tiff will read from the standard input. .SH OPTIONS .TP .B \-c Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .TP .B \-R Mark the resultant image to have the specified X and Y resolution (in dots/inch). .SH "SEE ALSO" .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each stiff-v3.4beta018/man/ras2tiff.1000444 004341 000024 00000005470 06003062777 015743 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/ras2tiff.1,v 1.11 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH RAS2TIFF 1 "May 2, 1989" .SH NAME ras2tiff \- create a .SM TIFF file from a Sun rasterfile .SH SYNOPSIS .B ras2tiff [ .I options .I input.ras .I output.tif .SH DESCRIPTION .I ras2tiff converts a file in the Sun rasterfile format to .SM TIFF. By default, the .SM TIFF image is created with data samples packed (\c .IR PlanarConfiguration =1), compressed with the Lempel-Ziv & Welch algorithm (\c .IR Compression =5), and with each strip no more than 8 kilobytes. These characteristics can overriden, or explicitly specified with the options described below. .PP Any colormap information in the rasterfile is carried over to the .SM TIFF file by including a .I Colormap tag in the output file. If the rasterfile has a colormap, the .I PhotometricInterpretation tag is set to 3 (palette); otherwise it is set to 2 (RGB) if the depth is 24 or 1 (min-is-black) if the depth is not 24. .SH OPTIONS .TP .B \-c Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .SH BUGS Does not handle all possible rasterfiles. In particular, .I ras2tiff does not handle run-length encoded images. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by defaultiff-v3.4beta018/man/rgb2ycbcr.1000444 004341 000024 00000005347 06003062777 016105 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/rgb2ycbcr.1,v 1.5 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH RGB2YCBCR 1 "September 26, 1994" .SH NAME rgb2ycbcr \- convert non-YCbCr .SM TIFF images to a YCbCr .SM TIFF image .SH SYNOPSIS .B rgb2ycbcr [ .B \-c .I compression ] [ .B \-h .I hsample ] [ .B \-v .I vsample ] [ .B \-r .I rows/strip ] .I "src1.tif src2.tif ... dst.tif" .SH DESCRIPTION .I Rgb2ycbcr converts .SM RGB color, greyscale, or bi-level .SM TIFF images to YCbCr images by transforming and sampling pixel data. If multiple files are specified on the command line, .I rgb2ycbcr converts all but the last file, writing a separate directory for each source in the destination file. .PP By default, chrominance samples are created by sampling 2 by 2 blocks of luminance values. The .B \-h and .B \-v options can be used to specify alternate horizontal and vertical sampling dimensions, respectively. Note that only 1, 2, and 4 should be used for portability. .PP By default, output data are compressed with the .SM LZW compression scheme. A different scheme can be selected with the .B \-c option; one of: .I none (for no compression), .I packbits (for PackBits compression), and .I lzw (for .SM LZW compression). .PP By default, output data are compressed in strips with the number of rows in each strip selected so that the size of a strip is never more than 8 kilobytes. The .B \-r option can be used to explicitly set the number of rows per strip. .SH "SEE ALSO" .IR tiffinfo (1), .IR tiffcp (1), .IR libtiff (3) h the .SM LZW compression scheme. A different scheme can be selected with the .B \-c option; one of: .I none (for no compression), .I packbits (for PackBits compression), and .I lzw (for .SM LZW compression). .PP By default, output data are compressed in strips with the number of tiff-v3.4beta018/man/sgi2tiff.1000444 004341 000024 00000005220 06003063000 015705 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/sgi2tiff.1,v 1.6 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH SGI2TIFF 1 "September 26, 1994" .SH NAME sgi2tiff \- create a .SM TIFF file from an .SM SGI image file .SH SYNOPSIS .B sgi2tiff [ .I options ] .I input.rgb .I output.tif .SH DESCRIPTION .I sgi2tiff converts a file in the .SM SGI image format to .SM TIFF. By default, the .SM TIFF image is created with data samples packed (\c .IR PlanarConfiguration =1), compressed with the Lempel-Ziv & Welch algorithm (\c .IR Compression =5), and with each strip no more than 8 kilobytes. These characteristics can overriden, or explicitly specified with the options described below. .SH OPTIONS .TP .B \-c Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-p Explicitly select the planar configuration used in organizing data samples in the output image: .B "\-p contig" for samples packed contiguously, and .B "\-p separate" for samples stored separately. By default samples are packed. .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .SH BUGS Does not record colormap information. .SH "SEE ALSO" .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) select the planar configuration used in organizing data samples in the output image: .B "\-p contig" for samples packed contiguously, and .B "\-p separate" for samples stored separately. By default samples are packed. .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8tiff-v3.4beta018/man/thumbnail.1000444 004341 000024 00000005435 06003063000 016163 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/thumbnail.1,v 1.2 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1994 Sam Leffler .\" Copyright (c) 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH THUMBNAIL 1 "September 26, 1994" .SH NAME thumbnail \- create a .SM TIFF file with thumbnail images .SH SYNOPSIS .B thumbnail [ .I options ] .I input.tif .I output.tif .SH DESCRIPTION .I thumbnail is a program written to show how one might use the SubIFD tag (#330) to store thumbnail images. .I thumbnail copies a .SM TIFF Class F facsimile file to the output file and for each image an 8-bit greyscale .IR "thumbnail sketch" . The output file contains the thumbnail image with the associated full-resolution page linked below with the SubIFD tag. .PP By default, thumbnail images are 216 pixels wide by 274 pixels high. Pixels are calculated by sampling and filtering the input image with each pixel value passed through a contrast curve. .SH OPTIONS .TP .B \-w Specify the width of thumbnail images in pixels. .TP .B \-h Specify the height of thumbnail images in pixels. .TP .B \-c Specify a contrast curve to apply in generating the thumbnail images. By default pixels values are passed through a linear contrast curve that simply maps the pixel value ranges. Alternative curves are: .B exp50 for a 50% exponential curve, .B exp60 for a 60% exponential curve, .B exp70 for a 70% exponential curve, .B exp80 for a 80% exponential curve, .B exp90 for a 90% exponential curve, .B exp for a pure exponential curve, .B linear for a linear curve. .SH BUGS There are no options to control the format of the saved thumbnail images. .SH "SEE ALSO" .IR tiffdump (1), .IR tiffgt (1), .IR tiffinfo (1), .IR libtiff (3) a linear contrast curve that simply maps the pixel value ranges. Alternative curves are: .B exp50 for a 50% exponential curve, .B exp60 for a 60% exponential curve, .B exp70 for a 70% exponential curve, .B exp80 for a 80% expontiff-v3.4beta018/man/tiff2bw.1000444 004341 000024 00000005120 06003063000 015532 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiff2bw.1,v 1.12 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFF2BW 1 "September 26, 1994" .SH NAME tiff2bw \- convert a color .SM TIFF image to greyscale .SH SYNOPSIS .B tiff2bw [ options ] .I input.tif .I output.tif .SH DESCRIPTION .I Tiff2bw converts an .SM RGB or Palette color .SM TIFF image to a greyscale image by combining percentages of the red, green, and blue channels. By default, output samples are created by taking 28% of the red channel, 59% of the green channel, and 11% of the blue channel. To alter these percentages, the .BR \-R , .BR \-G , and .BR \-B options may be used. .SH OPTIONS .TP .B \-c Specify a compression scheme to use when writing image data: .B "\-c none" for no compression, .B "-c packbits" for the PackBits compression algorithm), and .B "\-c lzw" for Lempel-Ziv & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .TP .B \-R Specify the percentage of the red channel to use (default 28). .TP .B \-G Specify the percentage of the green channel to use (default 59). .TP .B \-B Specify the percentage of the blue channel to use (default 11). .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) & Welch (the default). .TP .B \-r Write data with a specified number of rows per strip; by default the number of rows/strip is selected so that each strip is approximately 8 kilobytes. .TP .B \-R Specify the percentage of the red channel to use (default 28). .TP .B \-G Specify the percentage of the green channel to use (default 59). .TP .B \-B Specify the percentage of the blue channel to use (default 11). .SH "SEE ALSO" .IR paltiff-v3.4beta018/man/tiff2ps.1000444 004341 000024 00000011050 06003063001 015544 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiff2ps.1,v 1.16 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFF2PS 1 "September 26, 1994" .SH NAME tiff2ps \- convert a .SM TIFF image to PostScript\(tm .SH SYNOPSIS .B tiff2ps [ .I options ] .I input.tif .SH DESCRIPTION .I tiff2ps reads a .SM TIFF image and writes PostScript or Encapsulated PostScript (EPS) on the standard output. By default, .I tiff2ps writes Encapsulated PostScript for the first image in the specified .SM TIFF image file. .PP By default, .I tiff2ps will generate PostScript that fills a printed area specified by the .SM TIFF tags in the input file. If the file does not contain .I XResolution or .I YResolution tags, then the printed area is set according to the image dimensions. The .B \-w and .B \-h options (see below) can be used to set the dimensions of the printed area in inches; overriding any relevant .SM TIFF tags. .PP The PostScript generated for .SM RGB, palette, and .SM CMYK images uses the .I colorimage operator. The PostScript generated for greyscale and bilevel images uses the .I image operator. When the .I colorimage operator is used, PostScript code to emulate this operator on older PostScript printers is also generated. Note that this emulation code can be very slow. .PP Color images with associated alpha data are composited over a white background. .SH OPTIONS .TP .B \-1 Generate PostScript Level I (the default). .TP .B \-2 Generate PostScript Level II. .TP .B \-a Generate output for all IFDs (pages) in the input file. .TP .B \-d Set the initial .SM TIFF directory to the specified directory number. (NB: directories are numbered starting at zero.) This option is useful for selecting individual pages in a multi-page (e.g. facsimile) file. .TP .B \-e Force the generation of Encapsulated PostScript. .TP .B \-h Specify the vertical size of the printed area (in inches). .TP .B \-o Set the initial .SM TIFF directory to the .SM IFD at the specified file offset. This option is useful for selecting thumbnail images and the like which are hidden using the SubIFD tag. .TP .B \-p Force the generation of (non-Encapsulated) PostScript. .TP .B \-s Generate output for a single IFD (page) in the input file. .TP .B \-w Specify the horizontal size of the printed area (in inches). .SH EXAMPLES The following generates PostScript Level II for all pages of a facsimile: .RS .nf tiff2ps -a2 fax.tif | lpr .fi .RE Note also that if you have version 2.6.1 or newer of Ghostscript then you can efficiently preview facsimile generated with the above command. .PP To generate Encapsulated PostScript for a the image at directory 2 of an image use: .RS .nf tiff2ps -d 1 foo.tif .fi .RE (notice that directories are numbered starting at zero.) .SH BUGS Because PostScript does not support the notion of a colormap, 8-bit palette images produce 24-bit PostScript images. This conversion results in output that is six times bigger than the original image and which takes a long time to send to a printer over a serial line. Matters are even worse for 4-, 2-, and 1-bit palette images. .SH BUGS Does not use PostScript Level II support for printing color images (only bilevel and greyscale images). Does not handle tiled images. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffgt (1), .IR tiffmedian (1), .IR tiff2bw (1), .IR tiffsv (1), .IR libtiff (3) ges. This conversion results in output that is six times bigger than the original image and which takes a long time to send to a printer over a serial line. Matters are even worse for 4-, 2-, and 1-bit palette images. .SH BUGS Does not use PostScript Level II support for printing color images (only bilevel and greyscale images). Does not handle tiled images. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffgt (1), .IR tiffmedian (1), .IR tiff2tiff-v3.4beta018/man/tiffcmp.1000444 004341 000024 00000004701 06003063001 015624 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffcmp.1,v 1.17 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFCMP 1 "September 26, 1994" .SH NAME tiffcmp \- compare two .SM TIFF files .SH SYNOPSIS .B tiffcmp [ .I options ] .I "file1.tif file2.tif" .SH DESCRIPTION .I Tiffcmp compares the tags and data in two files created according to the Tagged Image File Format, Revision 6.0. The schemes used for compressing data in each file are immaterial when data are compared\-data are compared on a scanline-by-scanline basis after decompression. Most directory tags are checked; notable exceptions are: .IR GrayResponseCurve , .IR ColorResponseCurve , and .IR ColorMap tags. Data will not be compared if any of the .IR BitsPerSample , .IR SamplesPerPixel , or .I ImageWidth values are not equal. By default, .I tiffcmp will terminate if it encounters any difference. .SH OPTIONS .TP .B \-l List each byte of image data that differs between the files. .TP .B \-t Ignore any differences in directory tags. .SH BUGS Tags that are not recognized by the library are not compared; they may also generate spurious diagnostics. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) the .IR BitsPerSample , .IR SamplesPerPixel , or .I ImageWidthtiff-v3.4beta018/man/tiffcp.1000444 004341 000024 00000013021 06003063002 015443 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffcp.1,v 1.20 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFCP 1 "September 26, 1994" .SH NAME tiffcp \- copy (and possibly convert) a .SM TIFF file .SH SYNOPSIS .B tiffcp [ .I options ] .I "src1.tif ... srcN.tif dst.tif" .SH DESCRIPTION .I tiffcp combines one or more files created according to the Tag Image File Format, Revision 6.0 into a single .SM TIFF file. Because the output file may be compressed using a different algorithm than the input files, .I tiffcp is most often used to convert between different compression schemes. .PP By default, .I tiffcp will copy all the understood tags in a .SM TIFF directory of an input file to the associated directory in the output file. .PP .I tiffcp can be used to reorganize the storage characteristics of data in a file, but it is explicitly intended to not alter or convert the image data content in any way. .SH OPTIONS .TP .B \-c Specify the compression to use for data written to the output file: .B none for no compression, .B packbits for PackBits compression, .B lzw for Lempel-Ziv & Welch compression, .B g3 for CCITT Group 3 (T.4) compression, .B g4 for CCITT Group 4 (T.6) compression. By default .I tiffcp will compress data according to the value of the .I Compression tag found in the source file. .IP The .SM CCITT Group 3 and Group 4 compression algorithms can only be used with bilevel data. .IP Group 3 compression can be specified together with several T.4-specific options: .B 1d for 1-dimensional encoding, .B 2d for 2-dimensional encoding, and .B fill to force each encoded scanline to be zero-filled so that the terminating EOL code lies on a byte boundary. Group 3-specific options are specified by appending a ``:''-separated list to the ``g3'' option; e.g. .B "\-c g3:2d:fill" to get 2D-encoded data with byte-aligned EOL codes. .IP .SM LZW compression can be specified together with a .I predictor value. A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it is encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a ``:''-separated list to the ``lzw'' option; e.g. .B "\-c lzw:2" for .SM LZW compression with horizontal differencing. .TP .B \-f Specify the bit fill order to use in writing output data. By default, .I tiffcp will create a new file with the same fill order as the original. Specifying .B "\-f lsb2msb" will force data to be written with the FillOrder tag set to .SM LSB2MSB , while .B "\-f msb2lsb" will force data to be written with the FillOrder tag set to .SM MSB2LSB . .TP .B \-l Specify the length of a tile (in pixels). .I tiffcp attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile. .TP .B \-p Specify the planar configuration to use in writing image data that has one 8-bit sample per pixel. By default, .I tiffcp will create a new file with the same planar configuration as the original. Specifying .B "\-p contig" will force data to be written with multi-sample data packed together, while .B "\-p separate" will force samples to be written in separate planes. .TP .B \-r Specify the number of rows (scanlines) in each strip of data written to the output file. By default, .I tiffcp attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip. .TP .B \-s Force the output file to be written with data organized in strips (rather than tiles). .TP .B \-t Force the output file to be written wtih data organized in tiles (rather than strips). options can be used to force the resultant image to be written as strips or tiles of data, respectively. .TP .B \-w Specify the width of a tile (in pixels). .I tiffcp attempts to set the tile dimensions so that no more than 8 kilobytes of data appear in a tile. .SH EXAMPLES The following concatenates two files and writes the result using .SM LZW encoding: .RS .nf tiffcp -c lzw a.tif b.tif result.tif .fi .RE .PP To convert a G3 1d-encoded .SM TIFF to a single strip of G4-encoded data the following might be used: .RS .nf tiffcp -c g4 -r 10000 g3.tif g4.tif .fi .RE (1000 is just a number that is larger than the number of rows in the source file.) .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcmp (1), .IR tiffmedian (1), .IR tiffsplit (1), .IR libtiff (3) H EXAMPLES The following concatenates two files and writes the result using .SM LZW encoding: .RS .nf tiffcp -c lzw a.tif b.tif result.tif .fi .RE .PP To convert a G3 1d-encoded .SM TIFF to a single strip of G4-encoded data the following might be used: .RS .nf tiffcp -c g4 -r 10000 g3.tif g4.tif .fi .RE (1000 is just a number that is larger than the number of rows in the source file.) .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcmp (1), .IR tiffmedian (1), .IR tiffsplit (1),tiff-v3.4beta018/man/tiffdither.1000444 004341 000024 00000007266 06003063002 016336 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffdither.1,v 1.14 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFDITHER 1 "September 26, 1994" .SH NAME tiffdither \- convert a greyscale image to bilevel using dithering .SH SYNOPSIS .B tiffdither [ .I options ] .I input.tif .I output.tif .SH DESCRIPTION .I tiffdither converts a single channel 8-bit greyscale image to a bilevel image using Floyd-Steinberg error propagation with threholding. .SH OPTIONS .TP .B \-c Specify the compression to use for data written to the output file: .B none for no compression, .B packbits for PackBits compression, .B lzw for Lempel-Ziv & Welch compression, .B g3 for CCITT Group 3 (T.4) compression, .B g4 for CCITT Group 4 (T.6) compression. By default .I tiffdither will compress data according to the value of the .I Compression tag found in the source file. .IP The .SM CCITT Group 3 and Group 4 compression algorithms can only be used with bilevel data. .IP Group 3 compression can be specified together with several T.4-specific options: .B 1d for 1-dimensional encoding, .B 2d for 2-dimensional encoding, and .B fill to force each encoded scanline to be zero-filled so that the terminating EOL code lies on a byte boundary. Group 3-specific options are specified by appending a ``:''-separated list to the ``g3'' option; e.g. .B "\-c g3:2d:fill" to get 2D-encoded data with byte-aligned EOL codes. .IP .SM LZW compression can be specified together with a .I predictor value. A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it is encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a ``:''-separated list to the ``lzw'' option; e.g. .B "\-c lzw:2" for .SM LZW compression with horizontal differencing. .TP .B \-f Specify the bit fill order to use in writing output data. By default, .I tiffdither will create a new file with the same fill order as the original. Specifying .B "\-f lsb2msb" will force data to be written with the FillOrder tag set to .SM LSB2MSB , while .B "\-f msb2lsb" will force data to be written with the FillOrder tag set to .SM MSB2LSB . .TP .B \-t Set the threshold value for dithering. By default the threshold value is 128. .SH NOTES The dither algorithm is taken from the .IR tiffmedian (1) program (written by Paul Heckbert). .SH "SEE ALSO" .IR pal2rgb (1), .IR fax2tiff (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiff2bw (1), .IR libtiff (3) l. Specifying .B "\-f lsb2msb" will force data to be written with the FillOrder tag set to .SM LSB2MSB , while .B "\-f msb2lsb" will force data to be written with the FillOrder tag set to .SM MSB2LSB . .TP .B \-t Set the threshold value for dithering. By default the threshold value is 128. .SH NOTES The dither algorithm is takentiff-v3.4beta018/man/tiffdump.1000444 004341 000024 00000005245 06003063002 016017 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffdump.1,v 1.12 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFDUMP 1 "September 26, 1994" .SH NAME tiffdump \- print verbatim information about .SM TIFF files .SH SYNOPSIS .B tiffdump [ .I options ] .I "name \&..." .SH DESCRIPTION .I tiffdump displays directory information from files created according to the Tag Image File Format, Revision 6.0. The header of each .SM TIFF file (magic number, version, and first directory offset) is displayed, followed by the tag contents of each directory in the file. For each tag, the name, datatype, count, and value(s) is displayed. When the symbolic name for a tag or datatype is known, the symbolic name is displayed followed by it's numeric (decimal) value. Tag values are displayed enclosed in ``<>'' characters immediately preceded by the value of the count field. For example, an .I ImageWidth tag might be displayed as ``ImageWidth (256) SHORT (3) 1<800>''. .PP .I Tiffdump is particularly useful for investigating the contents of .SM TIFF files that .I libtiff does not understand. .SH OPTIONS .TP .B \-h Force numeric data to be printed in hexadecimal rather than the default decimal. .TP .B \-o Dump the contents of the .SM IFD at the a particular file offset. The file offset may be specified using the usual C-style syntax; i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. .SH "SEE ALSO" .IR tiffinfo (1), .IR libtiff (3) ) SHORT (3) 1<800>''. .PP .I Tiffdump is particularly useful for investigating the contents of .SM TIFF files that .I libtiff does not understand. .SH OPTIONS .TP .B \-h Force numeric data to be printed in hexadecimal rather than the default decimal. .TP .B \-o Dump the contents of the .SM IFD at the a particular file offset. The file offset matiff-v3.4beta018/man/tiffgt.1000444 004341 000024 00000010566 06003063003 015467 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffgt.1,v 1.18 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFGT 1 "September 26, 1994" .SH NAME tiffgt \- display an image stored in a .SM TIFF file (Silicon Graphics version) .SH SYNOPSIS .B tiffgt [ .I options ] .I input.tif .SH DESCRIPTION .I tiffgt displays an image stored in a file with the Tag Image File Format, Revision 6.0. The image is placed in a fixed size window that the user must position on the display. If the display has fewer than 24 bitplanes, or if the image does not warrant full color, then .SM RGB color values are mapped to the closest values that exist in the colormap (this is done using the .I rgbi routine found in the graphics utility library .BR \-lgutil .) .PP .I tiffgt correctly handles files with any of the following characteristics: .sp .5 .in +0.5i .ta \w'\fIPhotometricInterpretation\fP 'u .nf BitsPerSample 1, 2, 4, 8, 16 SamplesPerPixel 1, 3, 4 (the 4th sample is ignored) PhotometricInterpretation 0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 (palette), 6 (YCbCr) PlanarConfiguration 1 (contiguous), 2 (separate) Orientation 1 (top-left), 4 (bottom-left) .fi .in -0.5i .sp .5 Data may be organized as strips or tiles and may be compressed with any of the compression algorithms supported by the .IR libtiff (3) library. .PP For palette images (\c .IR PhotomatricInterpretation =3), .I tiffgt inspects the colormap values and assumes either 16-bit or 8-bit values according to the maximum value. That is, if no colormap entry greater than 255 is found, .I tiffgt assumes the colormap has only 8-bit values; otherwise it assumes 16-bit values. This inspection is done to handle old images written by previous (incorrect) versions of .IR libtiff . .SH OPTIONS .TP .B \-c Force image display in a colormap window. .TP .B \-d Specify an image to display by directory number. By default the first image in the file is displayed. Directories are numbered starting at zero. .TP .B \-f Force .I tiffgt to run as a foreground process. By default .I tiffgt will place itself in the background once it has opened the requested image file. .TP .B \-l Force the presumed bit ordering to be .SM LSB to .SM MSB. .TP .B \-m Force the presumed bit ordering to be .SM MSB to .SM LSB. .TP .B \-o Specify an image to display by directory offset. By default the first image in the file is displayed. Directories offsets may be specified using C-style syntax; i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. .TP .B \-r Force image display in a full color window. .TP .B \-s Stop on the first read error. By default all errors in the input data are ignored and .I tiffgt does it's best to display as much of an image as possible. .TP .B \-v Place information in the title bar describing what type of window (full color or colormap) is being used, the name of the input file, and the directory index of the image (if non-zero). By default, the window type is not shown in the title bar. .SH BUGS Images wider and taller than the display are silently truncated to avoid crashing old versions of the window manager. .SH "SEE ALSO" .IR tiffdump (1), .IR tiffinfo (1), .IR tiffcp (1), .IR libtiff (3) t to display as much of an image as possible. .TP .B \-v Place information in the title bar describing what type of window (full color or tiff-v3.4beta018/man/tiffinfo.1000444 004341 000024 00000005132 06003063003 016001 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffinfo.1,v 1.15 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFINFO 1 "May 2, 1990" .SH NAME tiffinfo \- print information about .SM TIFF files .SH SYNOPSIS .B tiffinfo [ .I options ] .I "input.tif \&..." .SH DESCRIPTION .I Tiffinfo displays information about files created according to the Tag Image File Format, Revision 6.0. By default, the contents of each .SM TIFF directory in each file is displayed, with the value of each tag shown symbolically (where sensible). .SH OPTIONS .TP .B \-c Display the colormap and color/gray response curves, if present. .TP .B \-D In addition to displaying the directory tags, read and decompress all the data in each image (but not display it). .TP .B \-d In addition to displaying the directory tags, print each byte of decompressed data in hexadecimal. .TP .B \-j Display any \s-2JPEG\s0-related tags that are present. .TP .B \-o Set the initial .SM TIFF directory according to the specified file offset. The file offset may be specified using the usual C-style syntax; i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. .TP .B \-s Display the offsets and byte counts for each data strip in a directory. .PP .B \-# Set the initial .SM TIFF directory to .IR # . .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffcp (1), .IR tiffcmp (1), .IR tiffmedian (1), .IR libtiff (3) lay any \s-2JPEG\s0-related tags that are present. .TP .B \-o Set the initial .SM TIFF directory according to the specified file offset. The file offset may be specified using the usual C-style syntax; i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. .TP .B \-s Display the offsets and byte counts for each data strip in a directory. .PP .B \-# Set the initial .SM TIFF directory to .IR # . .SH "SEE ALtiff-v3.4beta018/man/tiffmedian.1000444 004341 000024 00000006375 06003063004 016316 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffmedian.1,v 1.16 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFMEDIAN 1 "September 26, 1994" .SH NAME tiffmedian \- apply the median cut algorithm to data in a .SM TIFF file .SH SYNOPSIS .B tiffmedian [ .I options ] .I input.tif .I output.tif .SH DESCRIPTION .I tiffmedian applys the median cut algorithm to an .SM RGB image in .I input.tif to generate a palette image that is written to .IR output.tif . The generated colormap has, by default, 256 entries. The image data is quantized by mapping each pixel to the closest color values in the colormap. .SH OPTIONS .TP .B \-c Specify the compression to use for data written to the output file: .B none for no compression, .B packbits for PackBits compression, .B lzw for Lempel-Ziv & Welch compression, By default .I tiffmedian will compress data according to the value of the .I Compression tag found in the source file. .IP .SM LZW compression can be specified together with a .I predictor value. A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it is encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a ``:''-separated list to the ``lzw'' option; e.g. .B "\-c lzw:2" for .SM LZW compression with horizontal differencing. .TP .B \-C Specify the number of entries to use in the generated colormap. By default all 256 entries/colors are used. .TP .B \-f Apply Floyd-Steinberg dithering before selecting a colormap entry. .TP .B \-r Specify the number of rows (scanlines) in each strip of data written to the output file. By default, .I tiffmedian attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip. .SH NOTES This program is derived from Paul Heckbert's .I median program. .SH "SEE ALSO" .IR pal2rgb (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffcmp (1), .IR libtiff (3) .PP "Color Image Quantization for Frame Buffer Display", Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307. rmap entry. .TP .B \-r Specify the number of rows (scanlines) in each strip of data written to the output file. By default, .I tiffmedian attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip. .SH NOTES This program is derivedtiff-v3.4beta018/man/tiffsplit.1000444 004341 000024 00000004077 06003063004 016211 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffsplit.1,v 1.4 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFCP 1 "September 26, 1994" .SH NAME tiffsplit \- split a multi-image .SM TIFF into single-image .SM TIFF files .SH SYNOPSIS .B tiffsplit .I src.tif [ .I prefix ] .SH DESCRIPTION .I tiffsplit takes a multi-directory (page) .SM TIFF file and creates one or more single-directory (page) .SM TIFF files from it. The output files are given names created by concatenating a prefix, a lexically ordered suffix in the range [\fIaa\fP-\fIzz\fP], the suffix .I .tif (e.g. .IR xaa.tif , .IR xab.tif , \... .IR xzz.tif ). If a prefix is not specified on the command line, the default prefix of .I x is used. .SH OPTIONS None. .SH BUGS Only a select set of ``known tags'' is copied when spliting. .SH "SEE ALSO" .IR tiffcp (1), .IR tiffinfo (1), .IR libtiff (3) creates one or more single-directory (page) .SM TIFF files from it. The output files are given names created by concatenating a prefix, a lexically ordered suffix in the range [\fIaa\fP-\fIzz\fP], the suffix .I .tif (e.g. .IR xaa.tif , .IR xab.tif , \... .IR xzz.tif ). If a prefix is not specified on the command line, the default prefix of .I x is used. .SH OPTIONS None. .SH BUGS Only a select set of ``known tags'' is copied when spliting. .Stiff-v3.4beta018/man/tiffsv.1000444 004341 000024 00000007725 06003063004 015511 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tiffsv.1,v 1.14 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFSV 1 "September 26, 1994" .SH NAME tiffsv \- save an image from the framebuffer in a .SM TIFF file (Silicon Graphics version) .SH SYNOPSIS .B tiffsv [ .I options ] .I output.tif [ .I "x1 x2 y1 y2" ] .SH DESCRIPTION .I tiffsv saves all or part of the framebuffer in a file using the Tag Image File Format, Revision 6.0. By default, the image is saved with data samples packed (\c .IR PlanarConfiguration =1), compressed with the Lempel-Ziv & Welch algorithm (\c .IR Compression =5), and with each strip no more than 8 kilobytes. These characteristics can be overriden, or explicitly specified with the options described below. .SH OPTIONS .TP .B \-b Save the image as a greyscale image as if it were processed by .IR tiff2bw (1). This option is included for compatibility with the standard .IR scrsave (6D) program. .TP .B \-c Specify the compression to use for data written to the output file: .B none for no compression, .B packbits for PackBits compression, .B lzw for Lempel-Ziv & Welch compression (default). .IP .SM LZW compression can be specified together with a .I predictor value. A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it is encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options are specified by appending a ``:''-separated list to the ``lzw'' option; e.g. .B "\-c lzw:2" for .SM LZW compression with horizontal differencing. .TP .B \-p Specify the planar configuration to use in writing image data. By default, .I tiffsv will create a new file with the data samples packed contiguously. Specifying .B "\-p contig" will force data to be written with multi-sample data packed together, while .B "\-p separate" will force samples to be written in separate planes. .TP .B \-r Specify the number of rows (scanlines) in each strip of data written to the output file. By default, .I tiffsv attempts to set the rows/strip that no more than 8 kilobytes of data appear in a strip. .SH NOTE Except for the use of .SM TIFF, this program is equivalent to the standard .I scrsave program. This means, for example, that you can use it in conjunction with the standard .IR icut program simply by creating a link called .IR scrsave , or by creating a shell script called .I scrsave that invokes .I tiffgt with the appropriate options. .SH BUGS If data are saved compressed and in separate planes, then the rows in each strip is silently set to one to avoid limitations in the .IR libtiff (3) library. .SH "SEE ALSO" .IR scrsave (6D) .IR pal2rgb (1), .IR tiffdump (1), .IR tiffgt (1), .IR tiffinfo (1), .IR tiffcp (1), .IR tiffmedian (1), .IR libtiff (3) njunction with the standard .IR icut progratiff-v3.4beta018/man/TIFFClose.3t000444 004341 000024 00000003711 06003063005 016104 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFClose.3t,v 1.9 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFClose 3T "May 2, 1990" .SH NAME TIFFClose \- close a previously opened .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "void TIFFClose(TIFF* tif)" .SH DESCRIPTION .IR TIFFClose closes a file that was previously opened with .IR TIFFOpen (3T). Any buffered data are flushed to the file, including the contents of the current directory (if modified); and all resources are reclaimed. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. Likewise, warning messages are directed to the .IR TIFFWarning (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T) SYNOPSIS .B "#include " .br .B "void TIFFClostiff-v3.4beta018/man/TIFFError.3t000444 004341 000024 00000005023 06003063005 016126 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFError.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFError 3T "December 2, 1991" .SH NAME TIFFError, TIFFSetErrorHandler \- library error handling interface .SH SYNOPSIS .B "#include " .br .B "void TIFFError(const char* module, const char* fmt, ...)" .sp .5 .B "#include " .br .B "typedef void (*TIFFErrorHandler)(char* module, char* fmt, va_list ap);" .br .B "TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler);" .SH DESCRIPTION .I TIFFError invokes the library-wide error handling function to (normally) write an error message to the .BR stderr . The .I fmt parameter is a .IR printf (3S) format string, and any number arguments can be supplied. The .I module parameter, if non-zero, is printed before the message; it typically is used to identify the software module in which an error is detected. .PP Applications that desire to capture control in the event of an error should use .IR TIFFSetErrorHandler to override the default error handler. A .SM NULL (0) error handling function may be installed to suppress error messages. .SH "RETURN VALUES" .IR TIFFSetErrorHandler returns a reference to the previous error handling function. .SH "SEE ALSO" .IR intro (3T), .IR TIFFWarning (3T), .IR printf (3S) ed before the message; it typically is used to identify the software module in which an error is detected. .PP Applications that desire to capture control in the event of an error should use .IR TIFFSetErrorHandler to override the default error handler. A .SM NULL (0) error handling function may be installed to suppress error messages. .SH "RETURN VALUES" .IR TIFFSetErrorHandler returns a reference to the previous error handling function. .SH "SEE ALSO" .IR intro (3T), .IR TIFFWarning (3Ttiff-v3.4beta018/man/TIFFFlush.3t000444 004341 000024 00000004657 06003063006 016133 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFFlush.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFFlush 3T "December 16, 1991" .SH NAME TIFFFlush, TIFFFlushData \- flush pending writes to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFFlush(TIFF* tif)" .br .B "int TIFFFlushData(TIFF* tif)" .SH DESCRIPTION .IR TIFFFlush causes any pending writes for the specified file (including writes for the current directory) to be done. In normal operation this call is never needed\- the library automatically does any flushing required. .PP .IR TIFFFlushData flushes any pending image data for the specified file to be written out; directory-related data are not flushed. In normal operation this call is never needed\- the library automatically does any flushing required. .SH "RETURN VALUES" 0 is returned if an error is encountered, otherwise 1 is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteEncodedStrip (3T), .IR TIFFWriteEncodedTile (3T), .IR TIFFWriteRawStrip (3T), .IR TIFFWriteRawTile (3T), .IR TIFFWriteScanline (3T), .IR TIFFWriteTile (3T) ata are not flushed. In normal operation this call is never needed\- the library tiff-v3.4beta018/man/TIFFGetField.3t000444 004341 000024 00000014320 06003063006 016521 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFGetField.3t,v 1.13 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFGetField 3T "February 14, 1992" .SH NAME TIFFGetField, TIFFVGetField \- get the value(s) of a tag in an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFGetField(TIFF* tif, ttag_t tag, ...)" .sp 5p .B "#include " .br .B "int TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)" .sp 5p .B "int TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...)" .br .B "int TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)" .SH DESCRIPTION .IR TIFFGetField returns the value of a tag in the current directory associated with the open .SM TIFF file .IR tif . The file must have been previously opened with .IR TIFFOpen (3T). The tag is identified by .IR tag , one of the values defined in the include file .B tiff.h (see also the table below). The type and number of values returned is dependent on the tag being requested. The programming interface uses a variable argument list as prescribed by the .IR stdarg (3) interface (\c or, on some machines, the .IR varargs (3) interface.) The returned values should only be interpreted if .IR TIFFGetField returns 1. .PP .IR TIFFVGetField is functionally equivalent to .IR TIFFGetField except that it takes a pointer to a variable argument list. .I TIFFVGetField is useful for layering interfaces on top of the functionality provided by .IR TIFFGetField . .PP .IR TIFFGetFieldDefaulted and .IR TIFFVGetFieldDefaulted are identical to .IR TIFFGetField and .IR TIFFVGetField , except that if a tag is not defined in the current directory and it has a default value, then the default value is returned. .PP The tags understood by .IR libtiff , the number of parameter values, and the types for the returned values are shown below. The data types are specified as in C and correspond to the types used to specify tag values to .IR TIFFSetField (3T). Remember that .IR TIFFGetField returns parameter values, so all the listed data types are pointers to storage where values should be returned. Consult the .SM TIFF specification for information on the meaning of each tag and their possible values. .PP .nf .ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'uint16*,uint16**'u+2n \fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP .sp 5p TIFFTAG_ARTIST 1 char** TIFFTAG_BADFAXLINES 1 uint32* TIFFTAG_BITSPERSAMPLE 1 uint16* TIFFTAG_CLEANFAXDATA 1 uint16* TIFFTAG_COLORMAP 3 uint16** 1<" .B "TIFF* TIFFOpen(const char* filename, const char* mode)" .sp 5p .B "TIFF* TIFFFdOpen(const int fd, const char* filename, const char* mode)" .sp 5p .B "typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);" .B "typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);" .B "typedef int (*TIFFCloseProc)(thandle_t);" .B "typedef toff_t (*TIFFSizeProc)(thandle_t);" .B "typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);" .B "typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);" .sp 5p .B "TIFF* TIFFClientOpen(const char* filename, const char* mode, thandle_t clientdata," .B " TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc," .B " TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc," .B " TIFFUnmapFileProc unmapproc)" .fi .SH DESCRIPTION .IR TIFFOpen opens a .SM TIFF file whose name is .I filename and returns a handle to be used in subsequent calls to routines in .IR libtiff . If the open operation fails, then zero is returned. The .I mode parameter specifies if the file is to be opened for reading (``r''), writing (``w''), or appending (``a''). When a file is opened for appending, existing data will not be touched; instead new data will be written as additional subfiles. If an existing file is opened for writing, all previous data is overwritten. .PP If a file is opened for reading, the first .SM TIFF directory in the file is automatically read (also see .IR TIFFSetDirectory (3T) for reading directories other than the first). If a file is opened for writing or appending, a default directory is automatically created for writing subsequent data. This directory has all the default values specified in .SM TIFF Revision 6.0: .IR BitsPerSample =1, .IR ThreshHolding "=bilevel art scan," .IR FillOrder =1 (most significant bit of each data byte is filled first), .IR Orientation =1 (the 0th row represents the visual top of the image, and the 0th column represents the visual left hand side), .IR SamplesPerPixel =1, .IR RowsPerStrip =infinity, .IR ResolutionUnit =2 (inches), and .IR Compression =1 (no compression). To alter these values, or to define values for additional fields, .IR TIFFSetField (3T) must be used. .PP It is not possible to append data to a file that has a byte ordering opposite to the native byte ordering of a machine. That is, for example, the library will not allow a file with little-endian byte ordering to be appended to on a machine that has a native big-endian byte ordering. .PP .IR TIFFFdOpen is like .IR TIFFOpen except that it opens a .SM TIFF file given an open file descriptor .IR fd . The file's name and mode must reflect that of the open descriptor. The object associated with the file descriptor .BR "must support random access" . .PP .IR TIFFClientOpen is like .IR TIFFOpen except that the caller supplies a collection of functions that the library will use to do \s-1UNIX\s+1-like I/O operations. The .I readproc and .I writeproc are called to read and write data at the current file position. .I seekproc is called to change the current file position a la .IR lseek (2). .I closeproc is invoked to release any resources associated with an open file. .I sizeproc is invoked to obtain the size in bytes of a file. .I mapproc and .I unmapproc are called to map and unmap a file's contents in memory; c.f. .IR mmap (2) and .IR munmap (2). The .I clientdata parameter is an opaque ``handle'' passed to the client-specified routines passed as parameters to .IR TIFFClientOpen . .SH "RETURN VALUES" Upon successful completion .IR TIFFOpen , .IR TIFFFdOpen , and .IR TIFFClientOpen return a .SM TIFF pointer. Otherwise, NULL is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. Likewise, warning messages are directed to the .IR TIFFWarning (3T) routine. .PP \fB"%s": Bad mode\fP. The specified .I mode parameter was not one of ``r'' (read), ``w'' (write), or ``a'' (append). .PP .BR "%s: Cannot open" . .IR TIFFOpen () was unable to open the specified filename for read/writing. .PP .BR "Cannot read TIFF header" . An error occurred while attempting to read the header information. .PP .BR "Error writing TIFF header" . An error occurred while writing the default header information for a new file. .PP .BR "Not a TIFF file, bad magic number %d (0x%x)" . The magic number in the header was not (hex) 0x4d4d or (hex) 0x4949. .PP .BR "Not a TIFF file, bad version number %d (0x%x)" . The version field in the header was not 42 (decimal). .PP .BR "Cannot append to file that has opposite byte ordering" . A file with a byte ordering opposite to the native byte ordering of the current machine was opened for appending (``a''). This is a limitation of the library. .SH "SEE ALSO" .IR intro (3T), .IR TIFFClose (3T) .PP .BR "Not a TIFF file, bad magic number %d (0x%x)" . The magic number in the header was not (hex) 0x4d4d or (hex) 0x4949. .PP .BR "Not a TIFF file, bad version number %d (0x%x)" . The version field in the header was not 42 (decimal). .PP .BR "Cannot append to file that has opposite byte ordertiff-v3.4beta018/man/TIFFPrintDirectory.3t000444 004341 000024 00000005017 06003063007 020023 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFPrintDirectory.3t,v 1.5 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFPrintDirectory 3T "December 12, 1991" .SH NAME TIFFPrintDirectory \- print a description of a .SM TIFF directory .SH SYNOPSIS .B "#include " .br .B "void TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)" .SH DESCRIPTION .I TIFFPrintDirectory prints a description of the current directory in the specified .SM TIFF file to the standard I/O output stream .IR fd . The .I flags parameter is used to control the .I "level of detail" of the printed information; it is a bit-or of the flags defined in .BR tiffio.h : .sp .5 .nf .ta \w'#define 'u +\w'TIFFPRINT_JPEGDCTABLES 'u +\w'0x200 'u #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ .fi .SH NOTES In C++ the .I flags parameter defaults to 0. .SH "RETURN VALUES" None. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadDirectory (3T), .IR TIFFSetDirectory (3T) rips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ .fi .SH NOTES In C++ the .I flags parameter defaults to 0. .SH "RETURN VALUES" None. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadDirectory (3T), .IR TIFFSettiff-v3.4beta018/man/TIFFReadDirectory.3t000444 004341 000024 00000013631 06003063007 017603 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadDirectory.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadDirectory 3T "December 16, 1991" .SH NAME TIFFReadDirectory \- get the contents of the next directory in an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFReadDirectory(TIFF* tif)" .SH DESCRIPTION Read the next directory in the specified file and make it the current directory. Applications only need to call .I TIFFReadDirectory to read multiple subfiles in a single .SM TIFF file\(em the first directory in a file is automatically read when .IR TIFFOpen is called. .SH NOTES If the library is compiled with .SM STRIPCHOP_SUPPORT enabled, then images that have a single uncompressed strip or tile of data are automatically treated as if they were made up of multiple strips or tiles of approximately 8 kilobytes each. This operation is done only in-memory; it does not alter the contents of the file. However, the construction of the ``chopped strips'' is visible to the application through the number of strips/tiles. .SH "RETURN VALUES" If the next directory was successfully read, 1 is returned. Otherwise, 0 is returned if an error was encountered, or if there are no more directories to be read. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. All warning messages are directed to the .IR TIFFWarning (3T) routine. .PP \fBSeek error accessing TIFF directory\fP. An error occurred while positioning to the location of the directory. .PP \fBWrong data type %d for field "%s"\fP. The tag entry in the directory had an incorrect data type. For example, an .I ImageDescription tag with a .SM SHORT data type. .PP \fBTIFF directory is missing required "%s" field\fP. The specified tag is required to be present by the .SM TIFF 5.0 specification, but is missing. The directory is (usually) unusable. .PP \fB%s: Rational with zero denominator\fP. A directory tag has a .SM RATIONAL value whose denominator is zero. .PP \fBIncorrect count %d for field "%s" (%lu, expecting %lu); tag ignored\fP. The specified tag's count field is bad. For example, a count other than 1 for a .I SubFileType tag. .PP \fBCannot handle different per-sample values for field "%s"\fP. The tag has .I SamplesPerPixel values and they are not all the same; e.g. .IR BitsPerSample . The library is unable to handle images of this sort. .PP \fBCount mismatch for field "%s"; expecting %d, got %d\fP. The count field in a tag does not agree with the number expected by the library. This should never happen, so if it does, the library refuses to read the directory. .PP \fBInvalid TIFF directory; tags are not sorted in ascending order\fP. The directory tags are not properly sorted as specified in the .SM TIFF 5.0 specification. This error is not fatal. .PP \fBIgnoring unknown field with tag %d (0x%x)\fP. An unknown tag was encountered in the directory; the library ignores all such tags. .PP \fBTIFF directory is missing requred "ImageLength" field\fP. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. .PP \fBTIFF directory is missing requred "PlanarConfig" field\fP. The image violates the specification by not having a necessary field. There is no way for the library to recover from this error. .PP \fBTIFF directory is missing requred "StripOffsets" field\fP. The image has multiple strips, but is missing the tag that specifies the file offset to each strip of data. There is no way for the library to recover from this error. .PP \fBTIFF directory is missing requred "TileOffsets" field\fP. The image has multiple tiles, but is missing the tag that specifies the file offset to each tile of data. There is no way for the library to recover from this error. .PP \fBTIFF directory is missing required "StripByteCounts" field\fP. The image has multiple strips, but is missing the tag that specifies the size of each strip of data. There is no way for the library to recover from this error. .PP \fBTIFF directory is missing required "StripByteCounts" field, calculating from imagelength\fP. The image violates the specification by not having a necessary field. However, when the image is comprised of only one strip or tile, the library will estimate the missing value based on the file size. .PP \fBBogus "StripByteCounts" field, ignoring and calculating from imagelength\fP. Certain vendors violate the specification by writing zero for the StripByteCounts tag when they want to leave the value unspecified. If the image has a single strip, the library will estimate the missing value based on the file size. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteDirectory (3T), .IR TIFFSetDirectory (3T) y one strip or tile, the library will estimate the missing value based on the file size. .PP \fBBogus "tiff-v3.4beta018/man/TIFFReadEncodedStrip.3t000444 004341 000024 00000005455 06003063010 020221 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadEncodedStrip.3t,v 1.12 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadEncodedStrip 3T "December 16, 1991" .SH NAME TIFFReadEncodedStrip \- read and decode a strip of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)" .SH DESCRIPTION Read the specified strip of data and place .I size bytes of decompressed information in the (user supplied) data buffer. .SH NOTES The value of .I strip is a ``raw strip number.'' That is, the caller must take into account whether or not the data are organized in separate planes (\c .IR PlanarConfiguration =2). To read a full strip of data the data buffer should typically be at least as large as the number returned by .IR TIFFStripSize (3T). .PP The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the .I FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .SH "RETURN VALUES" The actual number of bytes of data that were placed in .I buf is returned; .IR TIFFReadEncodedStrip returns \-1 if an error was encountered. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadRawStrip (3T), .IR TIFFReadScanline (3T) native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .SH "RETURN VALUES" The actual number of bytestiff-v3.4beta018/man/TIFFReadEncodedTile.3t000444 004341 000024 00000005572 06003063010 020015 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadEncodedTile.3t,v 1.8 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadEncodedTile 3T "December 16, 1991" .SH NAME TIFFReadEncodedTile \- read and decode a tile of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFReadEncodedTile(TIFF* tif, u_long tile, u_char* buf, u_long size)" .SH DESCRIPTION Read the specified tile of data and place .I size bytes of decompressed information in the (user supplied) data buffer. .SH NOTES The value of .I tile is a ``raw tile number.'' That is, the caller must take into account whether or not the data are organized in separate planes (\c .IR PlanarConfiguration =2). .IR TIFFComputeTile automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number. To read a full tile of data the data buffer should be at least as large as the value returned by .IR TIFFTileSize . .PP The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the .I FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .SH "RETURN VALUES" The actual number of bytes of data that were placed in .I buf is returned; .IR TIFFReadEncodedTile returns \-1 if an error was encountered. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadRawTile (3T), .IR TIFFReadTile (3T) o the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order oppositiff-v3.4beta018/man/TIFFReadRGBAImage.3t000444 004341 000024 00000013443 06003063010 017310 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRGBAImage.3t,v 1.6 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadRGBAImage 3T "February 14, 1992" .SH NAME TIFFReadRGBAImage \- read and decode an image into a fixed-format raster .SH SYNOPSIS .nf .B "#include " .ta \w'\fB#define \fP'u +\w'\fBTIFFGetR(abgr) \fP'u .B "#define TIFFGetR(abgr) ((abgr) & 0xff)" .B "#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)" .B "#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)" .B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" .sp 5p .B "int TIFFReadRGBAImage(TIFF* tif, u_long width, u_long height, u_long* raster, int stopOnError)" .SH DESCRIPTION .IR TIFFReadRGBAImage reads a strip- or tile-based image into memory, storing the result in the user supplied .IR raster . The raster is assumed to be an array of .I width times .I height 32-bit entries, where .I width must be less than or equal to the width of the image (\c .I height may be any non-zero size). If the raster dimensions are smaller than the image, the image data is cropped to the raster bounds. If the raster height is greater than that of the image, then the image data are placed in the lower part of the raster. (Note that the raster is assume to be organized such that the pixel at location (\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; with the raster origin in the lower-left hand corner.) .PP Raster pixels are 8-bit packed red, green, blue, alpha samples. The macros .IR TIFFGetR , .IR TIFFGetG , .IR TIFFGetB , and .I TIFFGetA should be used to access individual samples. Images without Associated Alpha matting information have a constant Alpha of 1.0 (255). .PP .I TIFFReadRGBAImage converts non-8-bit images by scaling sample values. Palette, grayscale, bilevel, CMYK, and YCbCr images are converted to .SM RGB transparently. Raster pixels are returned uncorrected by any colorimetry information present in the directory. .PP The paramater .I stopOnError specifies how to act if an error is encountered while reading the image. If .I stopOnError is non-zero, then an error will terminate the operation; otherwise .I TIFFReadRGBAImage will continue processing data until all the possible data in the image have been requested. .SH NOTES In C++ the .I stopOnError parameter defaults to 0. .PP Samples must be either 1, 2, 4, 8, or 16 bits. Samples/pixel must be either 1, 3, or 4. .PP Palettte image colormaps that appear to be incorrectly written as 8-bit values are automatically scaled to 16-bits. .SH "RETURN VALUES" 1 is returned 1 if the image was successfully read and converted. Otherwise, 0 is returned if an error was encountered and .I stopOnError is zero. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP .BR "Sorry, can not handle %d-bit pictures" . The image had .I BitsPerSample other than 1, 2, 4, 8, or 16. .PP .BR "Sorry, can not handle %d-channel images" . The image had .I SamplesPerPixel other than 1, 3, or 4. .PP \fBMissing needed "PhotometricInterpretation" tag\fP. The image did not have a tag that describes how to display the data. .PP \fBNo "PhotometricInterpretation" tag, assuming RGB\fP. The image was missing a tag that describes how to display it, but because it has 3 or 4 samples/pixel, it is assumed to be .SM RGB. .PP \fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP. The image was missing a tag that describes how to display it, but because it has 1 sample/pixel, it is assumed to be a grayscale or bilevel image. .PP .BR "No space for photometric conversion table" . There was insufficient memory for a table used to convert image samples to 8-bit .SM RGB. .PP \fBMissing required "Colormap" tag\fP. A Palette image did not have a required .I Colormap tag. .PP .BR "No space for tile buffer" . There was insufficient memory to allocate an i/o buffer. .PP .BR "No space for strip buffer" . There was insufficient memory to allocate an i/o buffer. .PP .BR "Can not handle format" . The image has a format (combination of .IR BitsPerSample , .IR SamplesPerPixel , and .IR PhotometricInterpretation ) that .I TIFFReadRGBAImage can not handle. .PP .BR "No space for B&W mapping table" . There was insufficient memory to allocate a table used to map grayscale data to .SM RGB. .PP .BR "No space for Palette mapping table" . There was insufficient memory to allocate a table used to map data to 8-bit .SM RGB. .SH BUGS Alpha is not currently returned or set to 1.0. Orientations other than bottom-left, or top-left are not handled correctly. The pixel packing organization is optimized for a specific machine architecture. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T) ace for B&W mapping table" . There was insufficient memory to allocate a table used to map grayscale data to .SM RGB. .PP .BR "No space for Palette mapping table" . There was insufficient memory to allocate a table used ttiff-v3.4beta018/man/TIFFReadRawStrip.3t000444 004341 000024 00000004600 06003063011 017401 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRawStrip.3t,v 1.9 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadRawStrip 3T "December 16, 1991" .SH NAME TIFFReadRawStrip \- return the undecoded contents of a strip of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)" .SH DESCRIPTION Read the contents of the specified strip into the (user supplied) data buffer. Note that the value of .I strip is a ``raw strip number.'' That is, the caller must take into account whether or not the data is organized in separate planes (\c .IR PlanarConfiguration =2). To read a full strip of data the data buffer should typically be at least as large as the number returned by .IR TIFFStripSize . .SH "RETURN VALUES" The actual number of bytes of data that were placed in .I buf is returned; .IR TIFFReadEncodedStrip returns \-1 if an error was encountered. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadEncodedStrip (3T), .IR TIFFReadScanline (3T) \c .IR PlanarConfiguration =2). To read a full strip of data the data buffer should typically be at least as large as the numbertiff-v3.4beta018/man/TIFFReadRawTile.3t000444 004341 000024 00000004730 06003063011 017201 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadRawTile.3t,v 1.8 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadRawTile 3T "December 16, 1991" .SH NAME TIFFReadRawTile \- return an undecoded tile of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size)" .SH DESCRIPTION Read the contents of the specified tile into the (user supplied) data buffer. Note that the value of .I tile is a ``raw tile number.'' That is, the caller must take into account whether or not the data is organized in separate planes (\c .IR PlanarConfiguration =2). .IR TIFFComputeTile () automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number. To read a full tile of data the data buffer should typically be at least as large as the value returned by .IR TIFFTileSize (). .SH "RETURN VALUES" The actual number of bytes of data that were placed in .I buf is returned; .IR TIFFReadEncodedTile returns \-1 if an error was encountered. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadEncodedTile (3T), .IR TIFFReadTile (3T) coordinate quadruple to a tile number. Ttiff-v3.4beta018/man/TIFFReadScanline.3t000444 004341 000024 00000007220 06003063012 017364 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadScanline.3t,v 1.12 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadScanline 3T "December 16, 1991" .SH NAME TIFFReadScanline \- read and decode a scanline of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)" .SH DESCRIPTION Read the data for the specified row into the (user supplied) data buffer .IR buf . The data are returned decompressed and, in the native byte- and bit-ordering, but are otherwise packed (see further below). The buffer must be large enough to hold an entire scanline of data. Applications should call the routine .IR TIFFScanlineSize to find out the size (in bytes) of a scanline buffer. The .I row parameter is always used by .IR TIFFReadScanline ; the .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). .SH NOTES The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the .I FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .PP In C++ the .I sample parameter defaults to 0. .SH "RETURN VALUES" .IR TIFFReadScanline returns \-1 if it detects an error; otherwise 1 is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP .BR "Compression algorithm does not support random access" . Data was requested in a non-sequential order from a file that uses a compression algorithm and that has .I RowsPerStrip greater than one. That is, data in the image is stored in a compressed form, and with multiple rows packed into a strip. In this case, the library does not support random access to the data. The data should either be accessed sequentially, or the file should be converted so that each strip is made up of one row of data. .SH BUGS Reading subsampled YCbCR data does not work correctly because, for .IR PlanarConfiguration =2 the size of a scanline is not calculated on a per-sample basis, and for .IR PlanarConfiguration =1 the library does not unpack the block-interleaved samples. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadEncodedStrip (3T), .IR TIFFReadRawStrip (3T) o the data. The data should either be accessed sequentially, or the file should be converted so that each strip is made up of one row of data. .SH BUGS Reading subsampled YCbCR data does not work correctly because, for .IR PlanarConfiguration =2 the size of a scanline is not calculated on a per-sample basis, and for .IR PlanarConfiguration =1 the library does not utiff-v3.4beta018/man/TIFFReadTile.3t000444 004341 000024 00000006017 06003063012 016530 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFReadTile.3t,v 1.9 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFReadTile 3T "December 16, 1991" .SH NAME TIFFReadTile \- read and decode a tile of data from an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFReadTile(TIFF* tif, tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t sample)" .SH DESCRIPTION Return the data for the tile .I containing the specified coordinates. The data placed in .I buf are returned decompressed and, typically, in the native byte- and bit-ordering, but are otherwise packed (see further below). The buffer must be large enough to hold an entire tile of data. Applications should call the routine .IR TIFFTileSize to find out the size (in bytes) of a tile buffer. The .I x and .I y parameters are always used by .IR TIFFReadTile . The .I z parameter is used if the image is deeper than 1 slice (\c .IR ImageDepth >1). The .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). .SH NOTES The library attempts to hide bit- and byte-ordering differences between the image and the native machine by converting data to the native machine order. Bit reversal is done if the .I FillOrder tag is opposite to the native machine bit order. 16- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .SH "RETURN VALUES" .IR TIFFReadTile returns \-1 if it detects an error; otherwise the number of bytes in the decoded tile is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFCheckTile (3T), .IR TIFFComputeTile (3T), .IR TIFFOpen (3T), .IR TIFFReadEncodedTile (3T), .IR TIFFReadRawTile (3T) 6- and 32-bit samples are automatically byte-swapped if the file was written with a byte order opposite to the native machine byte order, .SH "RETURN VALUES" .IR TIFFReadTile returns \-1 if it detects an error; otherwise the number of bytes in the decoded tile is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .SH "SEE ALSO" .IR intro (3T), .IR TIFFCheckTile (3T), .IR TIFFComputeTile (3T), .IR TIFFOpen (3T), .IR TIFFReadEncodedTile (3T), .IR TIFFRetiff-v3.4beta018/man/TIFFSetDirectory.3t000444 004341 000024 00000004767 06003063012 017471 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFSetDirectory.3t,v 1.9 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFSetDirectory 3T "December 16, 1991" .SH NAME TIFFSetDirectory \- set the current directory for an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFSetDirectory(TIFF* tif, tdir_t dirnum)" .SH DESCRIPTION Set the specified directory to be the current directory and read the directory's contents with .IR TIFFReadDirectory . The parameter .I dirnum specifies the subfile/directory as an integer number, with the first directory numbered zero. .SH "RETURN VALUES" On successful return 1 is returned. Otherwise, 0 is returned if .I dirnum specifies a non-existent directory, or if an error was encountered while reading the directory's contents. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP .BR "%s: Error fetching directory count" . An error was encountered while reading the ``directory count'' field. .PP .BR "%s: Error fetching directory link" . An error was encountered while reading the ``link value'' that points to the next directory in a file. .SH "SEE ALSO" .IR intro (3T), .IR TIFFCurrentDirectory (3T), .IR TIFFOpen (3T), .IR TIFFReadDirectory (3T), .IR TIFFWriteDirectory (3T) the directiff-v3.4beta018/man/TIFFSetField.3t000444 004341 000024 00000013732 06003063013 016541 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFSetField.3t,v 1.12 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFSetField 3T "February 14, 1992" .SH NAME TIFFSetField \- set the value(s) of a tag in a .SM TIFF file open for writing .SH SYNOPSIS .B "#include " .br .B "int TIFFSetField(TIFF* tif, ttag_t tag, ...)" .br .B "#include " .br .B "int TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)" .SH DESCRIPTION .IR TIFFSetField sets the value of a field in the current directory associated with the open .SM TIFF file .IR tif . The file must have been previously opened for writing with .IR TIFFOpen (3T). The field is identified by .IR tag , one of the values defined in the include file .B tiff.h (see also the table below). The actual value is specified using a variable argument list, as prescribed by the .IR stdarg (3) interface (\c or, on some machines, the .IR varargs (3) interface.) .PP .IR TIFFVSetField is functionally equivalent to .IR TIFFSetField except that it takes a pointer to a variable argument list. .I TIFFVSetField is useful for writing routines that are layered on top of the functionality provided by .IR TIFFSetField . .PP The tags understood by .IR libtiff , the number of parameter values, and the expected types for the parameter values are shown below. The data types are: .I char* is null-terminated string and corresponds to the .SM ASCII data type; .I uint16 is an unsigned 16-bit value; .I uint32 is an unsigned 32-bit value; .I uint16* is an array of unsigned 16-bit values. Consult the .SM TIFF specification for information on the meaning of each tag. .PP .nf .ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'uint16,uint16* \(dg'u+2n \fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP .sp 5p TIFFTAG_ARTIST 1 char* TIFFTAG_BADFAXLINES 1 uint32 TIFFTAG_BITSPERSAMPLE 1 uint16 \(dg TIFFTAG_CLEANFAXDATA 1 uint16 TIFFTAG_COLORMAP 3 uint16* 1< 0 TIFFTAG_SAMPLEFORMAT 1 uint16 \(dg TIFFTAG_SAMPLESPERPIXEL 1 uint16 \(dg value must be <= 4 TIFFTAG_SOFTWARE 1 char* TIFFTAG_SUBFILETYPE 1 uint32 TIFFTAG_TARGETPRINTER 1 char* TIFFTAG_THRESHHOLDING 1 uint16 TIFFTAG_TILEDEPTH 1 uint32 \(dg TIFFTAG_TILELENGTH 1 uint32 \(dg must be a multiple of 8 TIFFTAG_TILEWIDTH 1 uint32 \(dg must be a multiple of 8 TIFFTAG_TRANSFERFUNCTION 1 or 3 \(dd uint16* 1<" .br .B "void TIFFWarning(const char* module, const char* fmt, ...)" .sp .5 .B "#include " .br .B "typedef void (*TIFFWarningHandler)(char* module, char* fmt, va_list ap);" .br .B "TIFFWarningHandler TIFFSetWarningHandler(TIFFWarningHandler handler);" .SH DESCRIPTION .I TIFFWarning invokes the library-wide warning handler function to (normally) write a warning message to the .BR stderr . The .I fmt parameter is a .IR printf (3S) format string, and any number arguments can be supplied. The .I module parameter is interpreted as a string that, if non-zero, should be printed before the message; it typically is used to identify the software module in which a warning is detected. .PP Applications that desire to capture control in the event of a warning should use .IR TIFFSetWarningHandler to override the default warning handler. A .SM NULL (0) warning handler function may be installed to suppress error messages. .SH "RETURN VALUES" .IR TIFFSetWarningHandler returns a reference to the previous error handling function. .SH "SEE ALSO" .IR intro (3T), .IR TIFFError (3T), .IR printf (3S) re the message; it typically is used to identify the software module in which a warning is detected. .PP Applications that desire to capture control in the event of a warning should use .IR TIFFSetWarningHandler to override the default warning handler. A .SM NULL (0) warning handler function may be installed to suppress error messages. .SH "RETURN VALUES" .IR TIFFSetWarningHandler returns a reference to the previous error handltiff-v3.4beta018/man/TIFFWriteDirectory.3t000444 004341 000024 00000007474 06003063013 020027 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteDirectory.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteDirectory 3T "December 16, 1991" .SH NAME TIFFWriteDirectory \- write the current directory in an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFWriteDirectory(TIFF* tif)" .SH DESCRIPTION Write the contents of the current directory to the file and setup to create a new subfile in the same file. Applications only need to call .IR TIFFWriteDirectory when writing multiple subfiles to a single .SM TIFF file. .IR TIFFWriteDirectory is automatically called by .IR TIFFClose and .IR TIFFFlush to write a modified directory if the file is open for writing. .SH "RETURN VALUES" 1 is returned when the contents are successfully written to the file. Otherwise, 0 is returned if an error was encountered when writing the directory contents. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP .BR "Error post-encoding before directory write" . Before writing the contents of the current directory, any pending data are flushed. This message indicates that an error occurred while doing this. .PP .BR "Error flushing data before directory write" . Before writing the contents of the current directory, any pending data are flushed. This message indicates that an error occurred while doing this. .PP .BR "Cannot write directory, out of space" . There was not enough space to allocate a temporary area for the directory that was to be written. .PP .BR "Error writing directory count" . A write error occurred when writing the count of fields in the directory. .PP .BR "Error writing directory contents" . A write error occurred when writing the directory fields. .PP .BR "Error writing directory link" . A write error occurred when writing the link to the next directory. .PP \fBError writing data for field "%s"\fP. A write error occurred when writing indirect data for the specified field. .PP .BR "Error writing TIFF header" . A write error occurred when re-writing header at the front of the file. .PP .BR "Error fetching directory count" . A read error occurred when fetching the directory count field for a previous directory. This can occur when setting up a link to the directory that is being written. .PP .BR "Error fetching directory link" . A read error occurred when fetching the directory link field for a previous directory. This can occur when setting up a link to the directory that is being written. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFError (3T), .IR TIFFReadDirectory (3T), .IR TIFFSetDirectory (3T) ctory count" . A read error occurred when fetching the directory count field for a previous directory. This can occur when setting up a link to the directory that is being written. .PP .BR "Error tiff-v3.4beta018/man/TIFFWriteEncodedStrip.3t000444 004341 000024 00000006330 06003063014 020435 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteEncodedStrip.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteEncodedStrip 3T "December 16, 1991" .SH NAME TIFFWritedEncodedStrip \- compress and write a strip of data to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)" .SH DESCRIPTION Compress .I size bytes of raw data from .I buf and .B append the result to the end of the specified strip. Note that the value of .I strip is a ``raw strip number.'' That is, the caller must take into account whether or not the data are organized in separate places (\c .IR PlanarConfiguration =2). .SH NOTES The library writes encoded data using the native machine byte order. Correctly implemented .SM TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8. .SH "RETURN VALUES" \-1 is returned if an error was encountered. Otherwise, the value of .IR size is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP \fB%s: File not open for writing\fP. The file was opened for reading, not writing. .PP \fBCan not write scanlines to a tiled image\fP. The image is assumed to be organized in tiles because the .I TileWidth and .I TileLength tags have been set with .IR TIFFSetField (3T). .PP \fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: No space for strip arrays"\fP. There was not enough space for the arrays that hold strip offsets and byte counts. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteScanline (3T), .IR TIFFWriteRawStrip (3T) t before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: No tiff-v3.4beta018/man/TIFFWriteEncodedTile.3t000444 004341 000024 00000006506 06003063014 020236 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteEncodedTile.3t,v 1.8 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteEncodedTile 3T "December 16, 1991" .SH NAME TIFFWritedEncodedTile \- compress and write a tile of data to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size)" .SH DESCRIPTION Compress .I size bytes of raw data from .I buf and .B append the result to the end of the specified tile. Note that the value of .I tile is a ``raw tile number.'' That is, the caller must take into account whether or not the data are organized in separate places (\c .IR PlanarConfiguration =2). .IR TIFFComputeTile automatically does this when converting an (x,y,z,sample) coordinate quadruple to a tile number. .SH NOTES The library writes encoded data using the native machine byte order. Correctly implemented .SM TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8. .SH "RETURN VALUES" \-1 is returned if an error was encountered. Otherwise, the value of .IR size is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP \fB%s: File not open for writing\fP. The file was opened for reading, not writing. .PP \fBCan not write tiles to a stripped image\fP. The image is assumed to be organized in strips because neither of the .I TileWidth or .I TileLength tags have been set with .IR TIFFSetField (3T). .PP \fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: No space for tile arrays"\fP. There was not enough space for the arrays that hold tile offsets and byte counts. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteTile (3T), .IR TIFFWriteRawTile (3T) t be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data htiff-v3.4beta018/man/TIFFWriteRawStrip.3t000444 004341 000024 00000005556 06003063015 017637 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteRawStrip.3t,v 1.9 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteRawstrip 3T "December 16, 1991" .SH NAME TIFFWriteRawStrip \- write a strip of raw data to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)" .SH DESCRIPTION Append .I size bytes of raw data to the specified strip. .SH "RETURN VALUES" \-1 is returned if an error occurred. Otherwise, the value of .IR size is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP \fB%s: File not open for writing\fP. The file was opened for reading, not writing. .PP \fBCan not write scanlines to a tiled image\fP. The image is assumed to be organized in tiles because the .I TileWidth and .I TileLength tags have been set with .IR TIFFSetField (3T). .PP \fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: No space for strip arrays"\fP. There was not enough space for the arrays that hold strip offsets and byte counts. .PP \fB%s: Strip %d out of range, max %d\fP. The specified strip is not a valid strip according to the currently specified image dimensions. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteEncodedStrip (3T), .IR TIFFWriteScanline (3T) ata\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%stiff-v3.4beta018/man/TIFFWriteRawTile.3t000444 004341 000024 00000005555 06003063015 017432 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteRawTile.3t,v 1.8 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteRawtile 3T "December 16, 1991" .SH NAME TIFFWriteRawTile \- write a tile of raw data to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "tsize_t TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size)" .SH DESCRIPTION Append .I size bytes of raw data to the specified tile. .SH "RETURN VALUES" \-1 is returned if an error occurred. Otherwise, the value of .IR size is returned. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP \fB%s: File not open for writing\fP. The file was opened for reading, not writing. .PP \fBCan not write tiles to a stripped image\fP. The image is assumed to be organized in strips because neither of the .I TileWidth or .I TileLength tags have been set with .IR TIFFSetField (3T). .PP \fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: No space for tile arrays"\fP. There was not enough space for the arrays that hold tile offsets and byte counts. .PP \fB%s: Specified tile %d out of range, max %d\fP. The specified tile is not valid according to the currently specified image dimensions. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteEncodedTile (3T), .IR TIFFWriteScanline (3T) g data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fBtiff-v3.4beta018/man/TIFFWriteScanline.3t000444 004341 000024 00000012736 06003063015 017616 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/TIFFWriteScanline.3t,v 1.11 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFWriteScanline 3T "December 16, 1991" .SH NAME TIFFWriteScanline \- write a scanline to an open .SM TIFF file .SH SYNOPSIS .B "#include " .br .B "int TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)" .SH DESCRIPTION Write data to a file at the specified row. The .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). The data are assumed to be uncompressed and in the native bit- and byte-order of the host machine. The data written to the file is compressed according to the compression scheme of the current .SM TIFF directory (see further below). If the current scanline is past the end of the current subfile, the .I ImageLength field is automatically increased to include the scanline (except for .IR PlanarConfiguration =2, where the .I ImageLength cannot be changed once the first data are written). If the .I ImageLength is increased, the .I StripOffsets and .I StripByteCounts fields are similarly enlarged to reflect data written past the previous end of image. .SH NOTES The library writes encoded data using the native machine byte order. Correctly implemented .SM TIFF readers are expected to do any necessary byte-swapping to correctly process image data with BitsPerSample greater than 8. The library attempts to hide bit-ordering differences between the image and the native machine by converting data from the native machine order. .PP In C++ the .I sample parameter defaults to 0. .PP Once data are written to a file for the current directory, the values of certain tags may not be altered; see .IR TIFFSetField (3T) for more information. .PP It is not possible to write scanlines to a file that uses a tiled organization. The routine .IR TIFFIsTiled can be used to determine if the file is organized as tiles or strips. .SH "RETURN VALUES" .IR TIFFWriteScanline returns \-1 if it immediately detects an error and 1 for a successful write. .SH DIAGNOSTICS All error messages are directed to the .IR TIFFError (3T) routine. .PP .BR "%s: File not open for writing . The file was opened for reading, not writing. .PP .BR "Can not write scanlines to a tiled image" . An attempt was made to write a scanline to a tiled image. The image is assumed to be organized in tiles because the .I TileWidth and .I TileLength tags have been set with .IR TIFFSetField (3T). .PP .BR "Compression algorithm does not support random access" . Data was written in a non-sequential order to a file that uses a compression algorithm and that has .I RowsPerStrip greater than one. That is, data in the image is to be stored in a compressed form, and with multiple rows packed into a strip. In this case, the library does not support random access to the data. The data should either be written as entire strips, sequentially by rows, or the value of .I RowsPerStrip should be set to one. .PP \fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not be set before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization of data has not be defined before the first write. See .IR TIFFSetField (3T) for information on how to do this. .PP \fBCan not change "ImageLength" when using separate planes\fP. Separate image planes are being used (\c .IR PlanarConfiguration =2), but the number of rows has not been specified before the first write. The library supports the dynamic growth of an image only when data are organized in a contiguous manner (\c .IR PlanarConfiguration =1). .PP .BR "%d: Sample out of range, max %d" . The .I sample parameter was greater than the value of the SamplesPerPixel tag. .PP .BR "%s: No space for strip arrays . There was not enough space for the arrays that hold strip offsets and byte counts. .SH BUGS Writing subsampled YCbCR data does not work correctly because, for .IR PlanarConfiguration =2 the size of a scanline is not calculated on a per-sample basis, and for .IR PlanarConfiguration =1 the library does not pack the block-interleaved samples. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFWriteEncodedStrip (3T), .IR TIFFWriteRawStrip (3T) mplesPerPixel tag. .PP .BR "%s: Notiff-v3.4beta018/man/intro.3t000444 004341 000024 00000030252 06003063016 015523 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/intro.3t,v 1.17 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH INTRO 3T "February 14, 1992" .SH NAME intro \- introduction to .IR libtiff , a library for reading and writing .SM TIFF files .SH SYNOPSIS .B "#include " .br cc file.c .B -ltiff .SH DESCRIPTION .I Libtiff is a library for reading and writing data files encoded with the .I "Tag Image File" format, Revision 6.0 (or revision 5.0 or revision 4.0). This file format is suitable for archiving multi-color and monochromatic image data. .PP The library supports several compression algorithms, as indicated by the .I Compression field, including: no compression (1), .SM CCITT 1D Huffman compression (2), .SM CCITT Group 3 Facsimile compression (3), .SM CCITT Group 4 Facsimile compression (4), Lempel-Ziv & Welch compression (5), word-aligned 1D Huffman compression (32771), and PackBits compression (32773). In addition, several nonstandard compression algorithms are supported: the 4-bit compression algorithm used by the .I ThunderScan program (32809) (decompression only), and NeXT's 2-bit compression algorithm (32766) (decompression only). 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 .SM MSB\c ) to Least Significant Bit (\c .SM LSB\c ) or .SM LSB to .SM MSB. Finally, the library does not support files in which the .IR BitsPerSample , .IR Compression , .IR MinSampleValue , or .IR MaxSampleValue fields are defined differently on a per-sample basis (in Rev. 6.0 the .I Compression tag is not defined on a per-sample basis, so this is immaterial). .SH "DATA TYPES" The library makes extensive use of C typedefs to promote portability. Two sets of typedefs are used, one for communication with clients of the library and one for internal data structures and parsing of the .SM TIFF format. The following typedefs are exposed to users either through function definitions or through parameters passed through the varargs interfaces. .in +.5i .sp 5p .ta +\w'typedef unsigned uint32; 'u .nf typedef unsigned short uint16; 16-bit unsigned integer typedef unsigned uint32; 32-bit unsigned integer .sp 5p typedef unsigned int ttag_t; directory tag typedef uint16 tdir_t; directory index typedef uint16 tsample_t; sample number typedef uint32 tstrip_t; strip number typedef uint32 ttile_t; tile number typedef int32 tsize_t; i/o size in bytes typedef void* tdata_t; image data ref typedef void* thandle_t; client data handle typedef int32 toff_t; file offset .fi .sp 5p .in -.5i Note that .IR tstrip_t , .IR ttile_t , and .I tsize_t are constrained to be no more than 32-bit quantities by 32-bit fields they are stored in in the .SM TIFF image. Likewise .I tsample_t is limited by the 16-bit field used to store the .I SamplesPerPixel tag. .I tdir_t constrains the maximum number of .SM IFDs that may appear in an image and may be an arbitrary size (w/o penalty). .I ttag_t must be either int, unsigned int, pointer, or double because the library uses a varargs interface and .SM "ANSI C" restricts the type of the parameter before an ellipsis to be a promoted type. .I toff_t is defined as int32 because TIFF file offsets are (unsigned) 32-bit quantities. A signed value is used because some interfaces return \-1 on error. Finally, note that user-specified data references are passed as opaque handles and only cast at the lowest layers where their type is presumed. .SH "LIST OF ROUTINES" The following routines are available. Consult specific manual pages for details on their operation. (The manual page names give here are for systems where the full function names can not be encoded in the filesystem; on most systems doing ``man function-name'' will work.) .sp 5p .nf .ta \w'TIFFWriteEncodedStrip'u+2n +\w'Appears on Page'u+2n \fIName\fP \fIAppears on Page\fP \fIDescription\fP .sp 5p TIFFCheckTile tile.3t very x,y,z,sample is within image TIFFClientOpen open.3t open a file for reading or writing TIFFClose close.3t close an open file TIFFComputeStrip strip.3t return strip containing y,sample TIFFComputeTile tile.3t return tile containing x,y,z,sample TIFFCurrentDirectory query.3t return index of current directory TIFFCurrentRow query.3t return index of current scanline TIFFCurrentStrip query.3t return index of current strip TIFFCurrentTile query.3t return index of current tile TIFFError error.3t library error handler TIFFFdOpen open.3t open a file for reading or writing TIFFFileName query.3t return name of open file TIFFFileno query.3t return open file descriptor TIFFFlush flush.3t flush all pending writes TIFFFlushData flush.3t flush pending data writes TIFFGetBitRevTable swab.3t return bit reversal table TIFFGetField getfield.3t return tag value in current directory TIFFGetFieldDefaulted getfield.3t return tag value in current directory TIFFGetMode query.3t return open file mode TIFFGetVersion query.3t return library version string TIFFIsTiled query.3t return true if image data is tiled TIFFIsByteSwapped query.3t return true if image data is byte-swapped TIFFNumberOfStrips strip.3t return number of strips in an image TIFFNumberOfTiles tile.3t return number of tiles in an image TIFFOpen open.3t open a file for reading or writing TIFFPrintDirectory print.3t print description of the current directory TIFFReadBufferSetup rdbuf.3t specify i/o buffer for reading TIFFReadDirectory readdir.3t read the next directory TIFFReadEncodedStrip rdestrip.3t read and decode a strip of data TIFFReadEncodedTile rdetile.3t read and decode a tile of data TIFFReadRawStrip rdrstrip.3t read a raw strip of data TIFFReadRawTile rdrtile.3t read a raw tile of data TIFFReadRGBAImage rdimage.3t read an image into a fixed format raster TIFFReadScanline readline.3t read and decode a row of data TIFFReadTile readtile.3t read and decode a tile of data TIFFReverseBits swab.3t reverse bits in an array of bytes TIFFScanlineSize size.3t return size of a scanline TIFFSetDirectory setdir.3t set the current directory TIFFSetErrorHandler error.3t set error handler function TIFFSetField setfield.3t set a tag's value in the current directory TIFFSetWarningHandler error.3t set warning handler function TIFFStripSize size.3t return size of a strip TIFFSwabShort swab.3t swap bytes of short TIFFSwabLong swab.3t swap bytes of long TIFFSwabArrayOfShort swab.3t swap bytes of an array of shorts TIFFSwabArrayOfLong swab.3t swap bytes of an array of longs TIFFTileRowSize size.3t return size of a row in a tile TIFFTileSize size.3t return size of a tile TIFFVGetField getfield.3t return tag value in current directory TIFFVGetFieldDefaulted getfield.3t return tag value in current directory TIFFVSetField setfield.3t set a tag's value in the current directory TIFFWarning warning.3t library warning handler TIFFWriteDirectory writedir.3t write the current directory TIFFWriteEncodedStrip wrestrip.3t compress and write a strip of data TIFFWriteEncodedTile wretile.3t compress and write a tile of data TIFFWriteRawStrip wrrstrip.3t write a raw strip of data TIFFWriteRawTile wrrtile.3t write a raw tile of data TIFFWriteScanline writeline.3t write a scanline of data TIFFWriteTile wrrtile.3t compress and write a tile of data .fi .SH "TAG USAGE" The table below lists the .SM TIFF tags that are recognized and handled by the library. If no use is indicated in the table, then the library reads and writes the tag, but does not use it internally. .sp 5p .nf .ta \w'PhotometricInterpretation'u+2n +\w'Value'u+2n +\w'R/W'u+2n \fITag Name\fP \fIValue\fP \fIR/W\fP \fILibrary's Use\fP .sp 5p .nf Artist 315 R/W BadFaxLines 326 R/W BitsPerSample 258 R/W lots CellLength 265 parsed but ignored CellWidth 264 parsed but ignored CleanFaxData 327 R/W ColorMap 320 R/W ColorResponseUnit 300 parsed but ignored Compression 259 R/W choosing compression routines ConsecutiveBadFaxLines 328 R/W DataType 32996 R DateTime 306 R/W DocumentName 269 R/W DotRange 336 R/W ExtraSamples 338 R/W lots FillOrder 266 R/W control bit order FreeByteCounts 289 parsed but ignored FreeOffsets 288 parsed but ignored GrayResponseCurve 291 parsed but ignored GrayResponseUnit 290 parsed but ignored Group3Options 292 R/W used by Group 3 code Group4Options 293 R/W HostComputer 316 R/W ImageDepth 32997 R/W tile/strip calculations ImageDescription 270 R/W ImageLength 257 R/W lots ImageWidth 256 R/W lots InkNames 333 R/W InkSet 332 R/W JPEGACTables 521 R/W JPEG code JPEGDCTables 520 R/W JPEG code JPEGProc 512 R/W JPEG code JPEGQRestartInterval 515 R/W JPEG code JPEGQTables 519 R/W JPEG code Make 271 R/W Matteing 32995 R MaxSampleValue 281 R/W MinSampleValue 280 R/W Model 272 R/W NewSubFileType 254 R/W (called SubFileType) Orientation 274 R/W PageName 285 R/W PageNumber 297 R/W PhotometricInterpretation 262 R/W Group 3 and JPEG code PlanarConfiguration 284 R/W data i/o Predictor 317 R/W used by LZW code PrimaryChromacities 319 R/W ReferenceBlackWhite 532 R/W ResolutionUnit 296 R/W RowsPerStrip 278 R/W data i/o SampleFormat 339 R/W SamplesPerPixel 277 R/W lots Software 305 R/W StripByteCounts 279 R/W data i/o StripOffsets 273 R/W data i/o SubFileType 255 R/W (called OSubFileType) TargetPrinter 337 R/W Thresholding 263 R/W TileByteCounts 324 R/W data i/o TileDepth 32998 R/W tile/strip calculations TileLength 323 R/W data i/o TileOffsets 324 R/W data i/o TileWidth 322 R/W data i/o TransferFunction 301 R/W WhitePoint 318 R/W XPosition 286 R/W XResolution 282 R/W YCbCrCoefficients 529 R/W used by TIFFReadRGBAImage YCbCrPositioning 531 R/W tile/strip size calulcations YCbCrSubsampling 530 R/W YPosition 286 R/W YResolution 283 R/W used by Group 3 2d encoding .SH DIAGNOSTICS All error messages are directed through the .IR TIFFError routine. By default messages are directed to .B stderr in the form: .IR "module: message\en." Warning messages are likewise directed through the .IR TIFFWarning routine. .SH "SEE ALSO" .IR fax2tiff (1), .IR gif2tiff (1), .IR pal2rgb (1), .IR ppm2tiff (1), .IR rgb2ycbcr (1), .IR ras2tiff (1), .IR sgi2tiff (1), .IR tiff2bw (1), .IR tiffdither (1), .IR tiffdump (1), .IR tiffcp (1), .IR tiffcmp (1), .IR tiffgt (1), .IR tiffinfo (1), .IR tiffmedian (1), .IR tiffsplit (1), .IR tiffsv (1), .PP .IR "Tag Image File Format Specification \(em Revision 6.0" , an Aldus Technical Memorandum, to be released. .PP .IR "The Spirit of TIFF Class F" , an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. .PP .IR "Appendix ALPHA: Associated Alpha Information" , a proposed appendix to the TIFF 6.0 specification. .SH BUGS The library does not support multi-sample images where some samples have different bits/sample. .PP It is not possible to overwrite the contents of a strip with .IR TIFFWriteEncodedStrip or .IR TIFFWriteRawStrip since they .I append to a strip. Likewise, .IR TIFFWriteEncodedTile and .IR TIFFWriteRawTile append to a tile. .PP The library does not support random access to compressed data that is organized with more than one row per tile or strip. The library discards unknown tags. The library should do more validity checking of a directory's contents. ages where some samples have different bits/sample. .PP It is not possible to overwrite the contents of a strip with .IR TIFFWriteEncodedStrip or .IR TIFFWriteRawStrip since they .I append to a strip. Likewise, .IR TIFFWriteEncodedTile and .IR TIFFWriteRawTile append to a tile. .PP The library does not support random access to compressed datiff-v3.4beta018/man/query.3t000444 004341 000024 00000006714 06003063016 015543 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/query.3t,v 1.11 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH QUERY 3T "December 16, 1991" .SH NAME TIFFCurrentRow, TIFFCurrentStrip, TIFFCurrentTile, TIFFCurrentDirectory, TIFFFileno, TIFFFileName, TIFFGetMode, TIFFIsTiled, TIFFIsByteSwapped \- query routines .SH SYNOPSIS .B "#include " .br .B "uint32 TIFFCurrentRow(TIFF* tif)" .br .B "tstrip_t TIFFCurrentStrip(TIFF* tif)" .br .B "ttile_t TIFFCurrentTile(TIFF* tif)" .br .B "tdir_t TIFFCurrentDirectory(TIFF* tif)" .br .B "int TIFFFileno(TIFF* tif)" .br .B "char* TIFFFileName(TIFF* tif)" .br .B "int TIFFGetMode(TIFF* tif)" .br .B "int TIFFIsTiled(TIFF* tif)" .br .B "int TIFFIsByteSwapped(TIFF* tif)" .br .B "const char* TIFFGetVersion(void)" .SH DESCRIPTION The following routines return status information about an open .SM TIFF file. .PP .IR TIFFCurrentDirectory returns the index of the current directory (directories are numbered starting at 0). This number is suitable for use with the .IR TIFFSetDirectory routine. .PP .IR TIFFCurrentRow , .IR TIFFCurrentStrip , and .IR TIFFCurrentTile , return the current row, strip, and tile, respectively, that is being read or written. These values are updated each time a read or write is done. .PP .IR TIFFFileno returns the underlying file descriptor used to access the .SM TIFF image in the filesystem. .PP .IR TIFFFileName returns the pathname argument passed to .IR TIFFOpen or .IR TIFFFdOpen . .PP .IR TIFFGetMode returns the mode with which the underlying file was opened. On .SM UNIX systems, this is the value passed to the .IR open (2) system call. .PP .IR TIFFIsTiled returns a non-zero value if the image data has a tiled organization. Zero is returned if the image data is organized in strips. .PP .IR TIFFIsByteSwapped returns a non-zero value if the image data was in a different byte-order than the host machine. Zero is returned if the image data and local host byte-orders are the same. Data samples that are more than 8 bits wide must be byte-swapped by the application. .PP .IR TIFFGetVersion returns an .SM ASCII string that has a version stamp for the .SM TIFF library software. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFFdOpen (3T) is organized in strips. .PP .IR TIFFIsByteSwapped rtiff-v3.4beta018/man/size.3t000444 004341 000024 00000005531 06003063017 015345 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/size.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH SIZE 3T "December 16, 1991" .SH NAME TIFFScanlineSize, TIFFStripSize, TIFFTileSize \- return the size (in bytes) of a scanline, strip, or tile for an open .SM TIFF file .SH SYNOPSIS .nf .B "#include " .B "tsize_t TIFFScanlineSize(TIFF* tif)" .B "tsize_t TIFFStripSize(TIFF* tif)" .B "tsize_t TIFFVStripSize(TIFF* tif, uint32 nrows)" .B "tsize_t TIFFTileSize(TIFF* tif)" .B "tsize_t TIFFVTileSize(TIFF* tif, uint32 nrows)" .SH DESCRIPTION .IR TIFFScanlineSize returns the size in bytes of a row of data as it would be returned in a call to .IR TIFFReadScanline , or as it would be expected in a call to .IR TIFFWriteScanline . .PP .IR TIFFStripSize returns the equivalent size for a strip of data as it would be returned in a call to .IR TIFFReadEncodedStrip or as it would be expected in a call to .IR TIFFWriteEncodedStrip . .PP .IR TIFFTileSize returns the equivalent size for a tile of data as it would be returned in a call to .IR TIFFReadTile or as it would be expected in a call to .IR TIFFWriteTile . .PP .IR TIFFVStripSize returns the number of bytes in a strip with .I nrows rows of data. Likewise, .IR TIFFVTileSize returns the number of bytes in a row-aligned tile with .I nrows of data. .PP These sizes are typically used when dynamically allocating I/O buffers. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFOpen (3T), .IR TIFFReadScanline (3T), .IR TIFFReadEncodedStrip (3T), .IR TIFFReadTile (3T), .IR TIFFWriteScanline (3T), .IR TIFFWriteEncodedStrip (3T), .IR TIFFWriteTile (3T) teTile . .PP .IR TIFFVStripSize returns the number of bytes in a strip with .I nrows rows of data. Likewise, .IR TIFFVTileSize returns the number of bytes in a row-alitiff-v3.4beta018/man/strip.3t000444 004341 000024 00000004310 06003063017 015526 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/strip.3t,v 1.4 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFComputeStrip 3T "February 14, 1992" .SH NAME TIFFComputeStrip, TIFFNumberOfStrips \- strip-related utility routines .SH SYNOPSIS .B "#include " .br .B "tstrip_t TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample)" .br .B "tstrip_t TIFFNumberOfStrips(TIFF* tif)" .SH DESCRIPTION .IR TIFFComputeStrip returns the strip that contains the specified coordinates. A valid strip is always returned; out-of-range coordinate values are clamped to the bounds of the image. The .I row parameter is always used in calculating a strip. The .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). .PP .IR TIFFNumberOfStrips returns the number of strips in the image. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFReadEncodedStrip (3T), .IR TIFFReadRawStrip (3T), .IR TIFFWriteEncodedStrip (3T), .IR TIFFWriteRawStrip (3T) lid strip is always returned; out-of-range coordinate values are clamped to the bounds of the image. The .I row parameter is always used in calculating a strip. The .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). .PP .IR TIFFNumberOfStrips returns the ntiff-v3.4beta018/man/swab.3t000444 004341 000024 00000005223 06003063017 015325 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/swab.3t,v 1.8 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH SWAB 3T "December 16, 1991" .SH NAME TIFFReverseBits, TIFFSwabShort, TIFFSwabLong, TIFFSwabArrayOfShort, TIFFSwabArrayOfLong \- byte- and bit-swapping routines .SH SYNOPSIS .B "#include " .br .B "const unsigned char* TIFFGetBitRevTable(int reversed);" .br .B "void TIFFReverseBits(u_char* data, unsigned long nbytes)" .br .B "void TIFFSwabShort(uint16* data)" .br .B "void TIFFSwabLong(uint32* data)" .br .B "void TIFFSwabArrayOfShort(uint16* data, unsigned long nshorts)" .br .B "void TIFFSwabArrayOfLong(uint32* data, unsigned long nlongs)" .SH DESCRIPTION The following routines are used by the library to swap 16- and 32-bit data and to reverse the order of bits in bytes. .PP .IR TIFFSwabShort and .IR TIFFSwabLong swap the bytes in a single 16-bit and 32-bit item, respectively. .IR TIFFSwabArrayOfShort and .IR TIFFSwabArrayOfLong swap the bytes in an array of 16-bit and 32-bit items, respectively. .PP .IR TIFFReverseBits replaces each byte in .I data with the equivalent bit-reversed value. This operation is done with a lookup table, .I TIFFBitRevTable which is declared public. A second table, .I TIFFNoBitRevTable is also declared public; it is a lookup table that can be used as an .IR "identity function" ; i.e. .IR "TIFFNoBitRevTable[n] == n" . .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), OfShort and .IR TIFFSwabArrayOfLong swap the bytes in an array of 16-bit and 32-bit items, respectively. .PP .IR TIFFReverseBits replaces each byte in .I data with the equivalent bit-reversed value. This operation is done with a lookup table, .I TIFFBitRevTable which is declared public. A second table, .I TIFFNoBitRevTable is also declared public; it is a lookup tiff-v3.4beta018/man/tile.3t000444 004341 000024 00000005717 06003063020 015330 0ustar00samuser000000 000000 .\" $Header: /usr/people/sam/tiff/man/RCS/tile.3t,v 1.10 1995/07/07 23:29:04 sam Exp $ .\" .\" Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler .\" Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. .\" .\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided .\" that (i) the above copyright notices and this permission notice appear in .\" all copies of the software and related documentation, and (ii) the names of .\" Sam Leffler and Silicon Graphics may not be used in any advertising or .\" publicity relating to the software without the specific, prior written .\" permission of Sam Leffler and Silicon Graphics. .\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR .\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, .\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, .\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE. .\" .if n .po 0 .TH TIFFComputeTile 3T "February 14, 1992" .SH NAME TIFFComputeTile, TIFFCheckTile, TIFFNumberOfTiles \- tile-related utility routines .SH SYNOPSIS .B "#include " .br .B "ttile_t TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t sample)" .br .B "int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t sample)" .br .B "ttile_t TIFFNumberOfTiles(TIFF* tif)" .SH DESCRIPTION .IR TIFFComputeTile returns the tile that contains the specified coordinates. A valid tile is always returned; out-of-range coordinate values are clamped to the bounds of the image. The .I x and .I y parameters are always used in calculating a tile. The .I z parameter is used if the image is deeper than 1 slice (\c .IR ImageDepth >1). The .I sample parameter is used only if data are organized in separate planes (\c .IR PlanarConfiguration =2). .PP .IR TIFFCheckTile returns a non-zero value if the supplied coordinates are within the bounds of the image and zero otherwise. The .I x parameter is checked against the value of the .I ImageWidth tag. The .I y parameter is checked against the value of the .I ImageLength tag. The .I z parameter is checked against the value of the .I ImageDepth tag (if defined). The .I sample parameter is checked against the value of the .I SamplesPerPixel parameter if the data are organized in separate planes. .PP .IR TIFFNumberOfTiles returns the number of tiles in the image. .SH DIAGNOSTICS None. .SH "SEE ALSO" .IR intro (3T), .IR TIFFReadEncodedTile (3T), .IR TIFFReadRawTile (3T), .IR TIFFReadTile (3T), .IR TIFFWriteEncodedTile (3T), .IR TIFFWriteRawTile (3T), .IR TIFFWriteTile (3T) gth tag. The .I z parameter is checked against thtiff-v3.4beta018/html/Makefile.in000444 004341 000024 00000004624 06003063020 016355 0ustar00samuser000000 000000 # $Header: /usr/people/sam/tiff/html/RCS/Makefile.in,v 1.4 1995/07/19 01:54:06 sam Exp $ # # @WARNING@ # # Tag Image File Format Library Manual Pages # # Copyright (c) 1991-1995 Sam Leffler # Copyright (c) 1991-1995 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 Stanford 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. # DEPTH = .. SRCDIR = ${DEPTH}/@SRCDIR@/html VPATH = ../@SRCDIR@/html PORT = ${DEPTH}/port # # VERSION: @VERSION@ # DATE: @DATE@ # TARGET: @TARGET@ # CCOMPILER: @CCOMPILER@ # SHELL = /bin/sh NULL = ECHO = echo MV = mv RM = rm -f INSTALL = @INSTALL@ HTML = @DIR_HTML@ HTMLFILES=\ bugs.html \ build.html \ contrib.html \ document.html \ images.html \ index.html \ internals.html \ intro.html \ libtiff.html \ misc.html \ support.html \ tools.html \ v3.4beta007.html \ v3.4beta016.html \ v3.4beta018.html \ ${NULL} IMAGES=\ images/back.gif \ images/bali.jpg \ images/cat.gif \ images/cover.jpg \ images/cramps.gif \ images/jello.jpg \ images/jim.gif \ images/note.gif \ images/oxford.gif \ images/quad.jpg \ images/ring.gif \ images/smallliz.jpg \ images/strike.gif \ images/strike.jpg \ images/warning.gif \ ${NULL} TARGETS= all: ${TARGETS} install: all ${INSTALL} -m 755 -dir -idb tiff.html.sw ${HTML} ${HTML}/images for i in ${HTMLFILES} ${IMAGES}; do \ ${INSTALL} -idb tiff.html.sw -m 444 -F ${HTML} \ -src ${SRCDIR}/$$i -O $$i; \ done clean:; cat.gif \ images/cover.jpg \ images/cramps.gif \ images/jello.jpg \ images/jim.gif \ images/note.gif tiff-v3.4beta018/html/bugs.html000444 004341 000024 00000003547 06003063021 016142 0ustar00samuser000000 000000 Bugs and the TIFF Mailing List

Bugs and the TIFF Mailing List

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 Netscape Navigator.

This software is free. The only thing that I ask in return is that you tell me when you find a problem or fix a bug. I also gladly accept software contributions, although I hesitate to include such software in my regular stuff if I am personally unable to test it.

A mailing list for users of this software is located on sgi.com. If you want to join this mailing list or have a list-related request such as getting your name removed from it, send a request to

For example, to subscribe, send the line
    subscribe
    
in the body of your message. The line help will return a list of the commands understood by the mailing list management software.

Submissions (including bug reports) should be directed to:

When corresponding about this software please always specify what version you have and what system you are running on.

If all else fails, I can be reached by sending mail to the address shown below. (but beware that I'm more likely to respond to mail sent to the mailing list than mail sent directly to me).


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/28 23:57:28 $
com When corresponding about this software please always specify what version you have and what system you are running on.

If all else faitiff-v3.4beta018/html/build.html000444 004341 000024 00000076164 06003063021 016306 0ustar00samuser000000 000000 Building the TIFF Software Distribution

Building the Software Distribution

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 Netscape Navigator.

This chapter contains step-by-step instructions on how to configure and build the TIFF software distribution. The software is most easily built on a UNIX system, but with a little bit of work it can easily be built and used on other non-UNIX platforms.

Building on a UNIX System

To build the software on a UNIX system you need to first run the configure shell script that is located in the top level of the source directory. This script probes the target system for necessary tools and functions and constructs a build environment in which the software may be compiled. Once configuration is done, you simply run make to build the software and then make install to do the installation; for example:
    hyla% cd tiff-v3.4beta099
    hyla% ./configure
        ...lots of messages...
    hyla% make
        ...lots of messages...
    hyla# make install
    
In general, the software is designed such that the following should be ``make-able'' in each directory:
    make [all]	build stuff
    make install	build&install stuff
    make clean	remove .o files and cruft, but not executables
    make clobber	remove everything that can be recreated
    make distclean	remove absolutely everything that can be recreated
    
Note that after running "make clobber" or "make distclean" the configure script must be run again to create the Makefiles and other make-related files.


Build Trees

There are two schemes for configuring and building the software. If you intend to build the software for only one target system, you can configure the software so that it is built in the same directories as the source code.
    hyla% cd tiff-v3.4beta099
    hyla% ls
    COPYRIGHT       VERSION         config.sub      dist            man
    Makefile.in     config.guess    configure       html            port
    README          config.site     contrib         libtiff         tools
    hyla% ./configure
    

Otherwise, you can configure a build tree that is parallel to the source tree hierarchy but which contains only configured files and files created during the build procedure.

    hyla% cd tiff-v3.4beta099
    hyla% mkdir obj obj/mycpu
    hyla% cd obj/mycpu
    hyla% ../../configure
    
This second scheme is useful for:
  • building multiple targets from a single source tree
  • building from a read-only source tree (e.g. if you receive the distribution on CD-ROM)
Beware that if you choose to use the second scheme for configuring the software you must not use an absolute pathname when you run configure (i.e. a pathname that begins with ``/'') and the make that you use to build the software must correctly support the VPATH facility.

NOTE: HPUX 9.05: The standard make incorrectly processes VPATH; either use gmake or configure builds in the source tree.


Configuration Files

The configuration process is critical to the proper compilation, installation, and operation of the software. The configure script runs a series of tests to decide whether or not the target system supports required functionality and, if it does not, whether it can emulate or workaround the missing functions. This procedure is fairly complicated and, due to the nonstandard nature of most UNIX systems, prone to error. The first time that you configure the software for use you should check the output from the configure script and look for anything that does not make sense for your system. A sample configure run is shown below together with an explanation of some of the work that is done.

A second function of the configure script is to set the default configuration parameters for the software. Of particular note are the directories where the software is to be installed. By default the software is installed in the /usr/local hierarchy. To change this behaviour the appropriate parameters can be specified either:

  • on the command line to configure,
  • in a site-wide configuration file, or
  • in a target-specific configuration file.
configure reads any site-wide configure file first, and then any target-specific configuration file. This permits target-specific definitions to override site-wide definitions.

Site-wide configuration files are named config.site and are automatically searched for first in any directory specified on the command line to configure (using the -site option), or if that fails, in the directory in in which the configure script is located.

Target-specific configuration files are named config.local and are looked for first in the top-level configuration directory, or, if that fails, in the directory in which the configure script is located.

Configuration files are just shell scripts that define shell variables that control the configuration process. For example, the following file might be used on a BSDI system to configure the software for installation in the /usr/contrib area and to make use of the Adobe Font Metric files that are already distributed as part of the BSDI 1.1 distribution:

#
# Parameters suitable for BSDI 1.1
#
DIR_BIN="/usr/contrib/bin"		# directory for client apps
DIR_LIB="/usr/contrib/lib"		# directory for libraries
DIR_MAN="/usr/contrib/man"		# directory for manual pages
DIR_HTML="/usr/contrib/html/tiff"	# directory for HTML documentation

For a complete list of the possible configuration parameters, look at the sample config.site file provided in the distribution or check the section below.


Configuring Optional Packages/Support

The TIFF software comes with several packages that are installed only as needed, or only if specifically configured at the time the configure script is run. Packages can be configured in a config.site or config.local file, or by using a -with-<PACKAGE> option when invoking configure; e.g. configure -with-AFM.
DSO Support
The DSO support controls whether or not to configure the software to build a Dynamic Shared Object for the TIFF library. Use of DSOs can significantly reduce the disk space needed for users of the TIFF software. If DSOs are not used then the code is statically linked into each application that uses it. By default this support is configured only if the system appears to suport DSOs in a way that fits into the normal build scheme (auto). If DSO support is explicitly enabled and there is no support for using DSOs in the expected way then DSOs are not used.

HTML Package
The HTML package contains this HTML documentation about TIFF. By default this package is not configured for installation since HTML documentation can be viewed directly from the source directory. You may want to configure the installation of the HTML materials if these documents are going to be shared by many people.

JPEG Support
The JPEG package enables support for the handling of TIFF images with JPEG-encoded data. Support for JPEG-encoded data requires the Independent JPEG Group (IJG) libjpeg distribution. By default JPEG support is not configured.

ZIP Support
The ZIP support enables support for the handling of TIFF images with deflate-encoded data. Support for deflate-encoded data requires the freely available zlib distribution written by Jean-loup Gailly and Mark Adler. By default this package is not configured.


A Sample Configuration Session

This section shows a sample configuration session and describes the work done. The session is shown indented in a fixed width font with user-supplied input in a bold font. Comments are shown in a normal or italic font. This session was collected on a 486 machine running BSDI 1.1.
    
    wullbrandt% mkdir tiff
    wullbrandt% cd tiff
    wullbrandt% ln -s /hosts/oxford/usr/people/sam/tiff src
    
A build tree separate from the source tree is used here. In fact, in this case the distribution is accessed from a read-only NFS-mounted filesystem.
    
    wullbrandt% src/configure
    Configuring TIFF Software v3.4beta015.
    
    Reading site-wide parameters from ../tiff-v3.4beta015/config.site.
    Reading local parameters from config.local.
    Gosh, aren't you lucky to have a i386-unknown-bsdi1.1 system!
    
Note that configure announces the distribution version and the deduced target configuration (i386-unknown-bsdi1.1 here).
    
    Using /usr/local/bin/gcc for a C compiler (set CC to override).
    Looks like /usr/local/bin/gcc supports the -g option.
    Using " -g" for C compiler options.
    
configure checked the normal shell search path for potential ANSI C compilers. The compiler is selected according to it properly compiling a small ANSI C test program. A specific compiler may be requested by setting the CC environment variable to the appropriate pathname, by supplying the parameter on the command line, e.g. -with-CC=gcc, or by setting CC in a configuration file.

Note that an ANSI C compiler is required to build the software. If a C compiler requires options to enable ANSI C compilation, they can be specified with the ENVOPTS parameter.

Once a compiler is selected configure does several checks to see:

  • if the compiler accepts a -g option to enable the generation of debugging symbols, and
  • if the compiler includes an ANSI C preprocessor.
    
    Using /usr/ucb/make to configure the software.
    
Next various system-specific libraries that may or may not be needed are checked for (none are needed in this case). If your system requires a library that is not automatically included it can be specified by setting the MACHDEPLIBS parameter.

Creating port.h. The port.h file is included by all the C code in the system. It includes definitions for functions and type definitions that are missing from system include files, #defines to enable or disable system-specific functionality, and other odds and ends.

    
    Creating port.h with necessary definitions.
    ... using LSB2MSB bit order for your i386 cpu
    ... using big-endian byte order for your i386 cpu
    ... configure use of mmap for memory-mapped files
    ... O_RDONLY is in 
    ... using double for promoted floating point parameters
    ... enabling use of inline functions
    Done creating port.h.
    
This file can take a long time to create so configure generates the file only when it is needed, either because the file does not exist or because a different target or compiler is to be used. Note that running "make distclean" in the top-level directory of the build tree will remove the port.h file (along with all the other files generated by configure).

Selecting emulated library functions. Certain functions used by the software are not present on all systems and can be emulated using other system functionality. configure checks for the presence of such functions and if they are missing, will configure emulation code from the port directory to use instead. Building the TIFF software on unsupported systems may require adding to the code to the port directory.

    
    Checking system libraries for functionality to emulate.
    Done checking system libraries.
    
If a routine must be emulated and configure does not automatically check for it, the routine name can be specified using the PORTFUNCS parameter. To add emulation support for a new function foo, create a file port/foo.c that contains the emulation code and then set PORTFUNCS=foo in a configuration file or modify the configure script to automatically check for the missing function.
    
    Checking for Dynamic Shared Object (DSO) support.
    Done checking for DSO support.
    
If the DSO package is enabled (DSO=auto or DSO=yes), then configure will verify the system and compiler are capable of constructing SVR4-style DSO's in the expected way. Note that while a system may support DSO's the compiler may not be capable of generating the required position-independent code and/or the compiler may not pass the needed options through to the loader.

Selecting utility programs. configure locates various system utility programs that are used during installation of the software.

    
    Selecting programs used during installation.
    Looks like mv supports the -f option to force a move.
    Looks like /bin/ln supports the -s option to create a symbolic link.
    Done selecting programs.
    

Selecting default configuration parameters. The remainder of the work done by configure involves setting up configuration parameters that control the placement and setup of files during the installation procedure.

    
    Selecting default TIFF configuration parameters.
    
    Looks like manual pages go in /usr/contrib/man.
    Looks like manual pages should be installed with bsd-nroff-gzip-0.gz.
    
    TIFF configuration parameters are:
    
    [ 1] Directory for tools:               /usr/contrib/bin
    [ 2] Directory for libraries:           /usr/contrib/lib
    [ 3] Directory for include files:       /usr/contrib/include
    [ 4] Directory for manual pages:        /usr/contrib/man
    [ 5] Directory for HTML documentation:  /var/httpd/htdocs/tiff
    [ 6] Manual page installation scheme:   bsd-nroff-gzip-0.gz
    
    Are these ok [yes]? 
    
At this point you can interactively modify any of the displayed parameters. Hitting a carriage return or typing yes will accept the current parameters. Typing one of the number displayed along the left hand side causes configure to prompt for a new value of the specified parameter. Typing anything else causes configure to prompt for a new value for each parameter. In general hitting carriage return will accept the current value and typing anything that is unacceptable will cause a help message to be displayed. A description of each of the configuration parameters is given below.

Once acceptable parameters are setup configure will generate all the files that depend on these parameters. Note that certain files may or may not be created based on the configuration of optional packages and/or the functions supported by target system.

    
    Creating Makefile from ../tiff-v3.4beta015/Makefile.in
    Creating libtiff/Makefile from ../tiff-v3.4beta015/libtiff/Makefile.in
    Creating man/Makefile from ../tiff-v3.4beta015/man/Makefile.in
    Creating tools/Makefile from ../tiff-v3.4beta015/tools/Makefile.in
    Creating port/install.sh from ../tiff-v3.4beta015/port/install.sh.in
    Done.
    


Configuration Parameters

This section gives a brief description of the less obvious configuration parameters. Consult the distributed config.site for a complete list of parameters. The list here is sorted alphabetically.

AROPTS The options passed to ar when creating an archive. Note that configure will automatically check to see if ar supports an s to create a symbol table instead of using ranlib.
DIR_BIN The directory where client applications should be installed; by default this is /usr/local/bin.
DIR_HTML The directory where HTML-based documentation should be installed; by default this is /var/httpd/htdocs/tiff (usually appropriate for the NCSA HTTP server).
DIR_LIB The directory to install libraries and DSO's; by default this is /usr/local/lib.
DIR_MAN The top-most directory of the manual area where manual pages should be installed.
DSOOPTS When DSO's are built, the options to specify to CC to create a DSO.
DSOSUF When DSO's are built, the filename suffix for a DSO. If this is set to "a" then statically linked archives are used.
ENVOPTS Options to pass to CC to force ANSI C compilation.
FILLORDER The order of bits in a byte on the server machine; either LSB2MSB or MSB2LSB. This is normally selected according to the target system.
GCOPTS Special options to pass the C compiler. If this parameter is set, then configure may append other options to this list.
INSTALL The pathname of the install program to use. Note that this program must emulate the command line interface used by the IRIX install program.
LIBPORT The pathname of the library that holds code to emulate missing system functionality. Normally this parameter is set by configure based on whether or not emulation code is required for the target.
LLDOPTS Extra command line options passed to CC when linking an executable. This option is usually set only when DSO support is enabled (to force the executable to search for the TIFF DSO in non-standard locations in the filesystem.)
MACHDEPLIBS Target-dependent libraries that should be used when linking tools. Note that if this parameter is specified configure will append to the list of libraries.
MANSCHEME The scheme to use when preparing and installing manual pages. Schemes are constructed according to:
    <organization>-<formatting>-<compression>[-<suffix>]
where: <organization> is either bsd for BSD-style section organization (e.g. file formats in section 5) or sysv for System V-style organization (e.g. file formats in section 4). <formatting> is either nroff to force installation of formatted materials (using nroff) or source to get the nroff source installed. <compression> is either the name of a program to compress the manual pages (gipz, compress, pack) or cat for uncompressed data. <suffix> is either the file suffix to convert installed pages to (e.g. 0.gz for gzip-compressed pages under BSD) or strip to force the normal ".4f" suffix to be converted to ".4" (or ".5" if using the BSD organization). If no -<suffix> is specified then filenames are not converted when they are installed.
PORTFUNCS A list of non-standard functions that should be emulated. Normally this list is constructed by configure based on checks it does. If this parameter is set, configure will append to the specified list.
SETMAKE If make does not automatically set $MAKE to the name of the make program to invoke for subdirectories, then configure will create an explicit definition. If this parameter is set, then it will be used instead. by default bin is used.


Building the Software under MS/DOS or Windows

There is a Makefile for Microsoft C. There is OS support for MS-DOS and for Windows. Someone needs to fill this in....


Building the Software on a Macintosh

The directory contrib/mac-mpw contains support for compiling the library and tools under the MPW Shell on a Macintosh system. This support was contributed by Niles Ritter (ndr@tazboy.jpl.nasa.gov).

[From the file contrib/mac-mpw/README.]

This directory contains all of the utilities and makefile source to build the LIBTIFF library and tools from the MPW Shell. The file BUILD.mpw in this directory is an executable script which uses all of these files to create the MPW makefiles and run them.

The .make files are not MPW makefiles as such, but are when run through the "mactrans" program, which turns the ascii "%nn" metacharacters into the standard weird MPW make characters.

This translation trick is necessary to protect the files when they are put into unix tarfiles, which tend to mangle the special characters.


Building the Software on a VMS System

The VMS port was done by Karsten Spang (krs@kampsax.dk), who also "sort of" maintains it. The VMS specific files are not in the main directories. Instead they are placed under [.CONTRIB.VMS...] in the distribution tree. Installation: It is assumed that you have unpacked the tar file into a VMS directory tree, in this text called DISK:[TIFF].
  1. Move the VMS specific files to their proper directories.
    $ SET DEFAULT DISK:[TIFF.CONTRIB.VMS]
    $ RENAME [.LIBTIFF]*.* [-.-.LIBTIFF]
    $ RENAME [.TOOLS]*.* [-.-.TOOLS]
    
  2. Compile the library.
    $ SET DEFAULT DISK:[TIFF.LIBTIFF]
    $ @MAKEVMS
    
  3. Compile the tools.
    $ SET DEFAULT DISK:[TIFF.TOOLS]
    $ @MAKEVMS
    
  4. Define the programs.
    $ DEFINE TIFFSHR DISK:[TIFF.LIBTIFF]TIFFSHR
    $ TIFFCP    :==$DISK:[TIFF.TOOLS]TIFFCP
    $ TIFFCMP   :==$DISK:[TIFF.TOOLS]TIFFCMP
    $ TIFFINFO  :==$DISK:[TIFF.TOOLS]TIFFINFO
    $ TIFFDUMP  :==$DISK:[TIFF.TOOLS]TIFFDUMP
    $ TIFF2PS   :==$DISK:[TIFF.TOOLS]TIFF2PS
    $ TIFFDITHER:==$DISK:[TIFF.TOOLS]TIFFDITHER
    $ TIFF2BW   :==$DISK:[TIFF.TOOLS]TIFF2BW
    $ TIFFMEDIAN:==$DISK:[TIFF.TOOLS]TIFFMEDIAN
    $ TIFFSPLIT :==$DISK:[TIFF.TOOLS]TIFFSPLIT
    $ FAX2TIFF  :==$DISK:[TIFF.TOOLS]FAX2TIFF
    $ GIF2TIFF  :==$DISK:[TIFF.TOOLS]GIF2TIFF
    $ PAL2RGB   :==$DISK:[TIFF.TOOLS]PAL2RGB
    $ PPM2TIFF  :==$DISK:[TIFF.TOOLS]PPM2TIFF
    $ RAS2TIFF  :==$DISK:[TIFF.TOOLS]RAS2TIFF
    
You will want to add these lines to your LOGIN.COM file, after changing the name of the directory that you have used on your machine.

This release has been tested on OpenVMS/VAX 5.5-2, using VAX C 3.2. A pre-release was tested under OpenVMS/AXP ?.? using DEC C ?.?, it is believed that the release as well works on AXP. The code contains some GNU C specific things. This does *not* imply, however, that the VAX/GCC configuration has been tested, *it has not*.

The command procedures (MAKEVMS.COM) for building the library and tools, is believed to choose the correct options for the VAX and AXP cases automatically.

On the AXP, IEEE floating point is used by default. If you want VAX floating point, remove the /FLOAT=IEEE_FLOAT qualifier, and change HAVE_IEEEFP=1 to HAVE_IEEEFP=0 in the MAKEVMS.COM files in both the libtiff and tools directories.

Compiling your own program on a VMS system:

When compiling a source file in which you "#include ", use the following command
    $ CC/INCLUDE=DISK:[TIFF.LIBTIFF]
This ensures that the header file is found. On the AXP, also add /FLOAT=IEEE_FLOAT (if used when building the library).

Linking your own program to the TIFF library on a VMS system:

You can link to the library in two ways: Either using the shareable library, or using the object library. The possibilities are:
  1. Using the shareable TIFF library.
    $ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS,SYS$INPUT:/OPTIONS
        SYS$SHARE:VAXCRTL/SHAREABLE
    
  2. Using the TIFF object library.
    $ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/LIBRARY,SYS$INPUT:/OPTIONS
        SYS$SHARE:VAXCRTL/SHAREABLE
    
Method 1 uses the shortest link time and smallest .EXE files, but it requires that TIFFSHR is defined as above at link time and at run time. Using the compilation procedure above, the tools are linked in this way.

Method 2 gives somewhat longer link time and larger .EXE files, but does not require TIFFSHR to be defined. This method is recommended if you want to run your program on another machine, and for some reason don't want to have the library on that machine. If you plan to have more than one program (including the tools) on the machine, it is recommended that you copy the library to the other machine and use method 1.

On the AXP, the C runtime library is linked automatically, this means that

    SYS$INPUT:/OPTIONS
	SYS$SHARE:VAXCRTL/SHAREABLE
should not be used.


Building the Software on Other Systems

This section contains information that might be useful if you are working on a non-UNIX system that is not directly supported. All library-related files described below are located in the libtiff directory.

The library requires two files that are generated by on-the-fly. The file tif_fax3sm.c has the state tables for the Group 3 and Group 4 decoders. This file is normally generated by the mkg3states program on a UNIX system; for example,

    
    cd libtiff
    cc -o mkg3states mkg3states.c
    rm -f tif_fax3sm.c
    ./mkg3states -c const tif_fax3sm.c
    
Consult the source code for this program if you have questions.

The second file required to build the library, version.h, contains the version information returned by the TIFFGetVersion routine. This file is built on a UNIX system using commands that can be found in the file Makefile.in. An example copy of version.h is:

    #define VERSION "LIBTIFF, Version 3.4beta015 \nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."

Otherwise, when building the library on a non-UNIX system be sure to consult the files tiffcomp.h and tiffconf.h. The former contains system compatibility definitions while the latter is provided so that the software configuration can be controlled on systems that do not support the make facility for building the software.

Systems without a 32-bit compiler may not be able to handle some of the codecs in the library; especially the Group 3 and 4 decoder. If you encounter problems try disabling support for a particular codec; consult the documentation.

Programs in the tools directory are written to assume an ANSI C compilation environment. There may be a few POSIX'isms as well. The code in the port directory is provided to emulate routines that may be missing on some systems. On UNIX systems the configure script automatically figures out which routines are not present on a system and enables the use of the equivalent emulation routines from the port directory. It may be necessary to manually do this work on a non-UNIX system.


Checking out the Software

Assuming you have working versions of tiffgt and tiffsv, you can just use them to view any of the sample images available for testing (see the section on obtaining the test images). Otherwise, you can do a cursory check of the library with the tiffcp and tiffcmp programs. For example,

    tiffcp -lzw cramps.tif x.tif
    tiffcmp cramps.tif x.tif
    

(tiffcmp should be silent if the files compare correctly).


Table of Contents

The following files makup the core library:
libtiff/tiff.h			TIFF spec definitions
libtiff/tiffcomp.h		non-UNIX OS-compatibility definitions
libtiff/tiffconf.h		non-UNIX configuration definitions
libtiff/tiffio.h		public TIFF library definitions
libtiff/tiffiop.h		private TIFF library definitions
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/version.h		version string (generated by Makefile)

libtiff/tif_apple.c		Apple-related OS support
libtiff/tif_atari.c		Atari-related OS support
libtiff/tif_aux.c		auxilary directory-related functions
libtiff/tif_close.c		close an open TIFF file
libtiff/tif_codec.c		configuration table of builtin codecs
libtiff/tif_compress.c		compression scheme support
libtiff/tif_dir.c		directory tag interface code
libtiff/tif_dirinfo.c		directory known tag support code
libtiff/tif_dirread.c		directory reading code
libtiff/tif_dirwrite.c		directory writing code
libtiff/tif_dumpmode.c		"no" compression codec
libtiff/tif_error.c		library error handler
libtiff/tif_fax3.c		CCITT Group 3 and 4 codec
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_lzw.c		LZW codec
libtiff/tif_msdos.c		MSDOS-related OS support
libtiff/tif_next.c		NeXT 2-bit scheme codec (decoding only)
libtiff/tif_open.c		open and simply query code
libtiff/tif_packbits.c		Packbits codec
libtiff/tif_predict.c		Predictor tag support
libtiff/tif_print.c		directory printing support
libtiff/tif_read.c		image data reading support
libtiff/tif_strip.c		some strip-related code
libtiff/tif_swab.c		byte and bit swapping support
libtiff/tif_thunder.c		Thunderscan codec (decoding only)
libtiff/tif_tile.c		some tile-related code
libtiff/tif_unix.c		UNIX-related OS support
libtiff/tif_version.c		library version support
libtiff/tif_vms.c		VMS-related OS support
libtiff/tif_warning.c		library warning handler
libtiff/tif_win3.c		Windows-related OS support
libtiff/tif_write.c		image data writing support
libtiff/tif_zip.c		Deflate codec

libtiff/mkg3states.c		program to generate G3/G4 decoder state tables
libtiff/mkspans.c		program to generate black-white span tables


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/07 02:34:32 $
OS support libtiff/tif_warning.c library warning handler libtiff/tif_win3.c Windows-related OS support libtiff/tif_write.c image data writing support libtiff/tif_zip.c Deflate codec libtiff/mkg3states.c program to generate G3/G4 decoder state tables libtiff/mkspans.c program to generate black-white span tables


Sam Leffler / Netscape Navigator.

The contrib directory has contributed software that uses the TIFF library.

contrib/vms scripts and files from Karsten Spang for building the library and tools under VMS
contrib/dbs a simple X-based TIFF viewer from Dan & Chris Sears
contrib/ras two programs by Patrick Naughton for converting between Sun rasterfile format and TIFF (these require libpixrect.a, as opposed to the one in tools that doesn't)
contrib/mac-mpw scripts and files from Niles Ritter for building the library and tools under Macintosh/MPW C.
contrib/tags scripts and files from Niles Ritter for adding private tag support at runtime, without changing libtiff.

Don't send me mail asking about these programs. Send questions and/or bug reports directly to the authors.


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/07 02:34:32 $
osh/MPW C. contrib/tags scripts and files from Niles Ritter for adding private tag support at runtime, without changing libtiff.

Don't send me mail asking about these progratiff-v3.4beta018/html/document.html000444 004341 000024 00000002701 06003063022 017010 0ustar00samuser000000 000000 TIFF Documentation

TIFF Documentation

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 Netscape Navigator.


A copy of the 6.0 specification is available by public ftp at

This is a PostScript version of the final 6.0 specification compressed 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 Acrobat format (PDF); this can be found at TIFF Technical Notes can be retrieved from


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/29 00:15:58 $
can be found at
    Netscape Navigator.

    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. The latest archive of test images is located at ftp://ftp.sgi.com/graphics/tiff/v3.0pics.tar.Z.

    There are two other good sources for TIFF test images: the contributed software contrib/dbs includes several programs that generate test images suitable for debugging, and the tiffcp program can be used to generate a variety of images with different storage characteristics.


    Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/28 23:57:28 $
    phics/tiff/v3.0pics.tar.Z.

    There are two other good sources for TIFF test images: the contributed softtiff-v3.4beta018/html/index.html000444 004341 000024 00000005527 06003063022 016312 0ustar00samuser000000 000000 TIFF Software

    TIFF Software

    Latest Release: None
    Latest Software: v3.4beta018
    Master FTP Site: ftp.sgi.com (192.48.153.1), directory graphics/tiff
    Home Page: http://www-mipl.jpl.nasa.gov/~ndr/tiff/
    FAQ Page: forthcoming

    
    
    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 Netscape Navigator.

    This software provides support for the Tag Image File Format (TIFF), a widely used format for storing image data. The latest version of the TIFF specification is available on-line in several different formats, as are a number of TIFF Technical Notes (TTN's).

    Included in this software distribution is a library, libtiff, for reading and writing TIFF, a small collection of tools for doing simple manipulations of TIFF images on UNIX systems, and documentation on the library and tools. A small assortment of TIFF-related software for UNIX that has been contributed by others is also included.

    The library, along with associated tool programs, should handle most of your needs for reading and writing TIFF images on 32- and 64-bit machines. This software can also be used on older 16-bit systems though it may require some effort and you may need to leave out some of the compression support.

    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.


    Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/19 01:54:06 $
    build.html">Building the software distribution
  • Bugs and the TIFF mailing list
  • Test images
  • Netscape Navigator.
    
    

    This chapter provides information about the internal structure of the library, how to control the configuration when building it, and how to add new support to the library. The following sections are found in this chapter:


    Library Configuration

    Information on compiling the library is given elsewhere in this documentation. This section describes the low-level mechanisms used to control the optional parts of the library that are configured at build time. Control is based on a collection of C defines that are specified either on the compiler command line or in a configuration file such as port.h (as generated by the configure script for UNIX systems) or tiffconf.h.

    Configuration defines are split into three areas:

    • those that control which compression schemes are configured as part of the builtin codecs,
    • those that control support for groups of tags that are considered optional, and
    • those that control operating system or machine-specific support.

    If the define COMPRESSION_SUPPORT is not defined 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). To override this behaviour define COMPRESSION_SUPPORT and then one or more additional defines to enable configuration of the appropriate codecs (see the table below); e.g.

      #define	COMPRESSION_SUPPORT
      #define	CCITT_SUPPORT
      #define	PACKBITS_SUPPORT
      
    Several other compression schemes are configured separately from the default set because they depend on ancillary software packages that are not distributed with libtiff.

    Support for JPEG compression is controlled by JPEG_SUPPORT. The JPEG codec that comes with libtiff is designed for use with release 5 or later of the Independent JPEG Group's freely available software distribution. This software can be retrieved from the directory ftp.uu.net:/graphics/jpeg/.

    NOTE: Enabling JPEG support automatically enables support for the TIFF 6.0 colorimetry and YCbCr-related tags.

    Experimental support for the deflate algorithm is controlled by DEFLATE_SUPPORT. The deflate codec that comes with libtiff is designed for use with version 0.92 or later of the freely available libgz library written by Jean-loup Gailly and Mark Adler. The data format used by this library is described in the files zlib-3.1.doc, and deflate-1.1.doc, available in the directory ftp.uu.net:/pub/archiving/zip/doc. The library can be retried from the directory ftp.uu.net:/graphics/jpeg/.

    NOTE: The deflate algorithm is experimental. Do not expect to exchange files using this compression scheme; it is included only because the similar, and more common, LZW algorithm is claimed to be governed by licensing restrictions.

    By default tiffconf.h defines COLORIMETRY_SUPPORT, YCBCR_SUPPORT, and CMYK_SUPPORT.

    DefineDescription
    CCITT_SUPPORT CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771)
    PACKBITS_SUPPORT Macintosh PackBits algorithm (compression 32773)
    LZW_SUPPORT Lempel-Ziv & Welch (LZW) algorithm (compression 5)
    THUNDER_SUPPORT 4-bit run-length encoding scheme from ThunderScan (compression 32809)
    NEXT_SUPPORT 2-bit encoding scheme used by NeXT (compression 32766)
    OJPEG_SUPPORT obsolete JPEG scheme defined in the 6.0 spec (compression 6)
    JPEG_SUPPORT current JPEG scheme defined in TTN2 (compression 7)
    ZIP_SUPPORT experimental Deflate scheme (compression 32946)
    COLORIMETRY_SUPPORT support for the TIFF 6.0 colorimetry tags
    YCBCR_SUPPORT support for the TIFF 6.0 YCbCr-related tags
    CMYK_SUPPORT support for the TIFF 6.0 CMYK-related tags


    General Portability Comments

    This software is developed on Silicon Graphics UNIX systems (big-endian, MIPS CPU, 32-bit ints, IEEE floating point). The configure shell script generates the appropriate include files and make files for UNIX systems. Makefiles exist for non-UNIX platforms that the code runs on -- this work has mostly been done by other people.

    In general, the code is guaranteed to work only on SGI machines. In practice it is highly portable to any 32-bit or 64-bit system and much work has been done to insure portability to 16-bit systems. If you encounter portability problems please return fixes so that future distributions can be improved.

    The software is written to assume an ANSI C compilation environment. If your compiler does not support ANSI function prototypes, const, and <stdarg.h> then you will have to make modifications to the software. In the past I have tried to support compilers without const and systems without <stdarg.h>, but I am no longer interested in these antiquated environments. With the general availability of the freely available GCC compiler, I see no reason to incorporate modifications to the software for these purposes.

    An effort has been made to isolate as many of the operating system-dependencies as possible in two files: tiffcomp.h and libtiff/tif_<os>.c. The latter file contains operating system-specific routines to do I/O and I/O-related operations. The UNIX (tif_unix.c), Macintosh (tif_apple.c), and VMS (tif_vms.c) code has had the most use; the MS/DOS support (tif_msdos.c) assumes some level of UNIX system call emulation (i.e. open, read, write, fstat, malloc, free).

    Native CPU byte order is determined on the fly by the library and does not need to be specified. The HOST_FILLORDER and HOST_BIGENDIAN definitions are not currently used, but may be employed by codecs for optimization purposes.

    The following defines control general portability:

    BSDTYPES Define this if your system does NOT define the usual BSD typedefs: u_char, u_short, u_int, u_long.
    HAVE_IEEEFP Define this as 0 or 1 according to the floating point format suported by the machine. If your machine does not support IEEE floating point then you will need to add support to tif_machdep.c to convert between the native format and IEEE format.
    HAVE_MMAP Define this if there is support for memory mapping files.
    HOST_FILLORDER Define the native CPU bit order: one of FILLORDER_MSB2LSB or FILLORDER_LSB2MSB
    HOST_BIGENDIAN Define the native CPU byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel); this may be used in codecs to optimize code

    On UNIX systems HAVE_MMAP is defined through the running of the configure script; otherwise support for memory-mapped files is disabled. Note that tiffcomp.h defines HAVE_IEEEFP to be 1 (BSDTYPES is not defined).


    Types and Portability

    The software makes extensive use of C typedefs to promote portability. Two sets of typedefs are used, one for communication with clients of the library and one for internal data structures and parsing of the TIFF format. There are interactions between these two to be careful of, but for the most part you should be able to deal with portability purely by fiddling with the following machine-dependent typedefs:

    uint16 16-bit unsigned integer tiff.h
    int16 16-bit signed integer tiff.h
    uint32 32-bit unsigned integer tiff.h
    int32 32-bit signed integer tiff.h
    dblparam_t promoted type for floats tiffcomp.h

    (to clarify dblparam_t, it is the type that float parameters are promoted to when passed by value in a function call.)

    The following typedefs are used throughout the library and interfaces to refer to certain objects whose size is dependent on the TIFF image structure:

    typedef unsigned int ttag_t; directory tag
    typedef uint16 tdir_t; directory index
    typedef uint16 tsample_t; sample number
    typedef uint32 tstrip_t; strip number
    typedef uint32 ttile_t; tile number
    typedef int32 tsize_t; i/o size in bytes
    typedef void* tdata_t; image data ref
    typedef void* thandle_t; client data handle
    typedef int32 toff_t; file offset (should be off_t)
    typedef unsigned char* tidata_t; internal image data

    Note that tstrip_t, ttile_t, and tsize_t are constrained to be no more than 32-bit quantities by 32-bit fields they are stored in in the TIFF image. Likewise tsample_t is limited by the 16-bit field used to store the SamplesPerPixel tag. tdir_t constrains the maximum number of IFDs that may appear in an image and may be an arbitrary size (without penalty). ttag_t must be either int, unsigned int, pointer, or double because the library uses a varargs interface and ANSI C restricts the type of the parameter before an ellipsis to be a promoted type. toff_t is defined as int32 because TIFF file offsets are (unsigned) 32-bit quantities. A signed value is used because some interfaces return -1 on error (sigh). Finally, note that tidata_t is used internally to the library to manipulate internal data. User-specified data references are passed as opaque handles and only cast at the lowest layers where their type is presumed.


    General Comments

    The library is designed to hide as much of the details of TIFF 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 does not care about (e.g. transfer function tables).


    Adding New Tags

    To add support for a new directory tag you have three options. If your tag is specific to a compression algorithm, see below. If you have a lot of tags you may want to try using Niles Ritter's runtime tag-extension scheme in the "contrib/tags" directory, which makes the changes orthogonal to the main libtiff code. Otherwise use the following guidelines to add support to the ``core library''.
    1. Define the tag in tiff.h.
    2. Add a field to the directory structure in tif_dir.h and define a FIELD_* bit.
    3. Add an entry in the TIFFFieldInfo array defined at the top of tif_dirinfo.c. Note that you must keep this array sorted by tag number and that the widest variant entry for a tag should come first (e.g. LONG before SHORT).
    4. Add entries in _TIFFVSetField() and _TIFFVGetField() for the new tag.
    5. (optional) If the value associated with the tag is not a scalar value (e.g. the array for TransferFunction) and requires special processing, then add the appropriate code to TIFFReadDirectory() and TIFFWriteDirectory(). You're best off finding a similar tag and cribbing code.
    6. Add support to TIFFPrintDirectory() in tif_print.c to print the tag's value.

    If you want to maintain portability, beware of making assumptions about data types. Use the typedefs (uint16, etc. when dealing with data on disk and t*_t when stuff is in memory) and be careful about passing items through printf or similar vararg interfaces.


    Adding New Builtin Codecs

    To add builtin support for a new compression algorithm, you can either use the "tag-extension" trick to override the handling of the TIFF Compression tag (see Adding New Tags, above), or do the following to add support directly to the core library:
    1. Define the tag value in tiff.h.
    2. Edit the file tif_codec.c to add an entry to the _TIFFBuiltinCODECS array (see how other algorithms are handled).
    3. Add the appropriate function prototype declaration to tiffiop.h (close to the bottom).
    4. Create a file with the compression scheme code, by convention files are named tif_*.c (except perhaps on some systems where the tif_ prefix pushes some filenames over 14 chars.
    5. Edit Makefile.in (and any other Makefiles) to include the new source file.

    A codec, say foo, can have many different entry points:

    TIFFInitfoo(tif, scheme)/* initialize scheme and setup entry points in tif */
    fooSetupDecode(tif)	/* called once per IFD after tags has been frozen */
    fooPreDecode(tif, sample)/* called once per strip/tile, after data is read,
    			    but before the first row is decoded */
    fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
        fooDecodeRow(...)	/* called to decode a single scanline */
        fooDecodeStrip(...)	/* called to decode an entire strip */
        fooDecodeTile(...)	/* called to decode an entire tile */
    fooSetupEncode(tif)	/* called once per IFD after tags has been frozen */
    fooPreEncode(tif, sample)/* called once per strip/tile, before the first row in
    			    a strip/tile is encoded */
    fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
        fooEncodeRow(...)	/* called to decode a single scanline */
        fooEncodeStrip(...)	/* called to decode an entire strip */
        fooEncodeTile(...)	/* called to decode an entire tile */
    fooPostEncode(tif)	/* called once per strip/tile, just before data is written */
    fooSeek(tif, row)	/* seek forwards row scanlines from the beginning
    			   of a strip (row will always be >0 and <rows/strip */
    fooCleanup(tif)		/* called when compression scheme is replaced by user */
    

    Note that the encoding and decoding variants are only needed when a compression algorithm is dependent on the structure of the data. For example, Group 3 2D encoding and decoding maintains a reference scanline. The sample parameter identifies which sample is to be encoded or decoded if the image is organized with PlanarConfig=2 (separate planes). This is important for algorithms such as JPEG. If PlanarConfig=1 (interleaved), then sample will always be 0.


    Adding New Codec-private Tags

    To add tags that are meaningful only when a particular compression algorithm is used follow these steps:
    1. Define the tag in tiff.h.
    2. Allocate storage for the tag values in the private state block of the codec.
    3. Insure the state block is created when the codec is initialized.
    4. At TIFFInitfoo time override the method pointers in the TIFF structure for getting, setting and printing tag values. For example,
          sp->vgetparent = tif->tif_vgetfield;
          tif->tif_vgetfield = fooVGetField;	/* hook for codec tags */
          sp->vsetparent = tif->tif_vsetfield;
          tif->tif_vsetfield = fooVSetField;	/* hook for codec tags */
          tif->tif_printdir = fooPrintDir;	/* hook for codec tags */
      
      (Actually you may decide not to override the tif_printdir method, but rather just specify it).
    5. Create a private TIFFFieldInfo array for your tags and merge them into the core tags at initialization time using _TIFFMergeFieldInfo; e.g.
          _TIFFMergeFieldInfo(tif, fooFieldInfo, N(fooFieldInfo));
      
      (where N is a macro used liberaly throughout the distributed code).
    6. Fill in the get and set routines. Be sure to call the parent method for tags that you are not handled directly. Also be sure to set the FIELD_* bits for tags that are to be written to the file. Note that you can create ``pseudo-tags'' by defining tags that are processed exclusively in the get/set routines and never written to file (see the handling of TIFFTAG_FAXMODE in tif_fax3.c for an example of this).
    7. Fill in the print routine, if appropriate.
    Note that space has been allocated in the FIELD_* bit space for codec-private tags. Define your bits as FIELD_CODEC+<offset> to keep them away from the core tags. If you need more tags than there is room for, just increase FIELD_SETLONGS at the top of tiffiop.h.


    Other Comments

    The library handles most I/O buffering. There are two data buffers when decoding data: a raw data buffer that holds all the data in a strip, and a user-supplied scanline buffer that compression schemes place decoded data into. When encoding data the data in the user-supplied scanline buffer is encoded into the raw data buffer (from where it is written). Decoding routines should never have to explicitly read data -- a full strip/tile's worth of raw data is read and scanlines never cross strip boundaries. Encoding routines must be cognizant of the raw data buffer size and call TIFFFlushData1() when necessary. Note that any pending data is automatically flushed when a new strip/tile is started, so there's no need do that in the tif_postencode routine (if one exists). Bit order is automatically handled by the library when a raw strip or tile is filled. If the decoded samples are interpreted by the decoding routine before they are passed back to the user, then the decoding logic must handle byte-swapping by overriding the tif_postdecode routine (set it to TIFFNoPostDecode) and doing the required work internally. For an example of doing this look at the horizontal differencing code in the routines in tif_predict.c.

    The variables tif_rawcc, tif_rawdata, and tif_rawcp in a TIFF structure are associated with the raw data buffer. tif_rawcc must be non-zero for the library to automatically flush data. The variable tif_scanlinesize is the size a user's scanline buffer should be. The variable tif_tilesize is the size of a tile for tiled images. This should not normally be used by compression routines, except where it relates to the compression algorithm. That is, the cc parameter to the tif_decode* and tif_encode* routines should be used in terminating decompression/compression. This ensures these routines can be used, for example, to decode/encode entire strips of data.

    In general, if you have a new compression algorithm to add, work from the code for an existing routine. In particular, libitff/tif_dumpmode.c has the trivial code for the "nil" compression scheme, tif_packbits.c is a simple byte-oriented scheme that has to watch out for buffer boundaries, and tif_lzw.c has the LZW scheme that has the most complexity -- it tracks the buffer boundary at a bit level. Of course, using a private compression scheme (or private tags) limits the portability of your TIFF files.


    Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/07 02:34:32 $
    , tif_packbits.c is a simple byte-oriented scheme that has to watch out tiff-v3.4beta018/html/intro.html000444 004341 000024 00000005327 06003063023 016335 0ustar00samuser000000 000000 Introduction to the TIFF Documentation

    Introduction to the TIFF Documentation

    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 Netscape Navigator.

    The following definitions are used throughout this documentation. They are consistent with the terminology used in the TIFF 6.0 specification.

    Sample
    The unit of information stored in an image; often called a channel elsewhere. Sample values are numbers, usually unsigned integers, but possibly in some other format if the SampleFormat tag is specified in a TIFF
    Pixel
    A collection of one or more samples that go together.
    Row
    An Nx1 rectangular collection of pixels.
    Tile
    An NxM rectangular organization of data (or pixels).
    Strip
    A tile whose width is the full image width.
    Compression
    A scheme by which pixel or sample data are stored in an encoded form, specifically with the intent of reducing the storage cost.
    Codec
    Software that implements the decoding and encoding algorithms of a compression scheme.

In order to better understand how TIFF works (and consequently this software) it is important to recognize the distinction between the physical organization of image data as it is stored in a TIFF and how the data is interpreted and manipulated as pixels in an image. TIFF supports a wide variety of storage and data compression schemes that can be used to optimize retrieval time and/or minimize storage space. These on-disk formats are independent of the image characteristics; it is the responsibility of the TIFF reader to process the on-disk storage into an in-memory format suitable for an application. Furthermore, it is the responsibility of the application to properly interpret the visual characteristics of the image data. TIFF defines a framework for specifying the on-disk storage format and image characteristics with few restrictions. This permits significant complexity that can be daunting. Good applications that handle TIFF work by handling as wide a range of storage formats as possible, while constraining the acceptable image characteristics to those that make sense for the application.


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/28 23:57:28 $
storage format and image characteristics with few restrictions. This permits significant complexity that can be daunting. Good applications that handle TIFF work by handling as wide a range of storage formats as possible, while constraining the acceptable image characteristics to those that maktiff-v3.4beta018/html/libtiff.html000444 004341 000024 00000062022 06003063023 016614 0ustar00samuser000000 000000 Using The TIFF Library

Using The TIFF Library

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 Netscape Navigator.


libtiff is a set of C functions (a library) that support the manipulation of TIFF image files. The library requires an ANSI C compilation environment for building and presumes an ANSI C environment for use.

libtiff provides interfaces to image data at several layers of abstraction (and cost). At the highest level image data can be read into an 8-bit/sample, ABGR pixel raster format without regard for the underlying data organization, colorspace, or compression scheme. Below this high-level interface the library provides scanline-, strip-, and tile-oriented interfaces that return data decompressed but otherwise untransformed. These interfaces require that the application first identify the organization of stored data and select either a strip-based or tile-based API for manipulating data. At the lowest level the library provides access to the raw uncompressed strips or tiles, returning the data exactly as it appears in the file.

The material presented in this chapter is a basic introduction to the capabilities of the library; it is not an attempt to describe everything a developer needs to know about the library or about TIFF. Detailed information on the interfaces to the library are given in the


How to tell which version you have

The software version can be found by looking at the file named VERSION that is located at the top of the source tree; the precise alpha number is given in the file dist/tiff.alpha. If you have need to refer to this specific software, you should identify it as:
    TIFF <version> <alpha>
where <version> is whatever you get from "cat VERSION" and <alpha> is what you get from "cat dist/tiff.alpha".

Within an application that uses libtiff the TIFFGetVersion routine will return a pointer to a string that contains software version information.


Library Datatypes

libtiff defines a portable programming interface through the use of a set of C type definitions. These definitions, defined in in the files tiff.h and tiffio.h, isolate the libtiff API from the characteristics of the underlying machine. To insure portable code and correct operation, applications that use libtiff should use the typedefs and follow the function prototypes for the library API.


Memory Management

libtiff uses a machine-specific set of routines for managing dynamically allocated memory. _TIFFmalloc, _TIFFrealloc, and _TIFFfree mimic the normal ANSI C routines. Any dynamically allocated memory that is to be passed into the library should be allocated using these interfaces in order to insure pointer compatibility on machines with a segmented architecture. (On 32-bit UNIX systems these routines just call the normal malloc, realloc, and free routines in the C library.)

To deal with segmented pointer issues libtiff also provides _TIFFmemcpy, _TIFFmemset, and _TIFFmemmove routines that mimic the equivalent ANSI C routines, but that are intended for use with memory allocated through _TIFFmalloc and _TIFFrealloc.


Error Handling

libtiff handles most errors by returning an invalid/erroneous value when returning from a function call. Various diagnostic messages may also be generated by the library. All error messages are directed to a single global error handler routine that can be specified with a call to TIFFSetErrorHandler. Likewise warning messages are directed to a single handler routine that can be specified with a call to TIFFSetWarningHandler


Basic File Handling

The library is modeled after the normal UNIX stdio library. For example, to read from an existing TIFF image the file must first be opened:
    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("foo.tif", "r"); ... do stuff ... TIFFClose(tif); }
The handle returned by TIFFOpen is opaque, that is the application is not permitted to know about its contents. All subsequent library calls for this file must pass the handle as an argument.

To create or overwrite a TIFF image the file is also opened, but with a "w" argument:

    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("foo.tif", "w"); ... do stuff ... TIFFClose(tif); }
If the file already exists it is first truncated to zero length.

Note that unlike the stdio library TIFF image files may not be opened for both reading and writing; there is no support for altering the contents of a TIFF file.

libtiff buffers much information associated with writing a valid TIFF image. Consequently, when writing a TIFF image it is necessary to always call TIFFClose or TIFFFlush to flush any buffered information to a file. Note that if you call TIFFClose you do not need to call TIFFFlush.


TIFF Directories

TIFF supports the storage of multiple images in a single file. Each image has an associated data structure termed a directory that houses all the information about the format and content of the image data. Images in a file are usually related but they do not need to be; it is perfectly alright to store a color image together with a black and white image. Note however that while images may be related their directories are not. That is, each directory stands on its own; their is no need to read an unrelated directory in order to properly interpret the contents of an image.

libtiff provides several routines for reading and writing directories. In normal use there is no need to explicitly read or write a directory: the library automatically reads the first directory in a file when opened for reading, and directory information to be written is automatically accumulated and written when writing (assuming TIFFClose or TIFFFlush are called).

For a file open for reading the TIFFSetDirectory routine can be used to select an arbitrary directory; directories are referenced by number with the numbering starting at 0. Otherwise the TIFFReadDirectory and TIFFWriteDirectory routines can be used for sequential access to directories. For example, to count the number of directories in a file the following code might be used:

    #include "tiffio.h" main(int argc, char* argv[]) { TIFF* tif = TIFFOpen(argv[1], "r"); if (tif) { int dircount = 1; do { dircount++; } while (TIFFReadDirectory(tif)); printf("%d directories in %s\n", dircount, argv[1]); TIFFClose(tif); } exit(0); }

Finally, note that there are several routines for querying the directory status of an open file: TIFFCurrentDirectory returns the index of the current directory and TIFFLastDirectory returns an indication of whether the current directory is the last directory in a file. There is also a routine, TIFFPrintDirectory, that can be called to print a formatted description of the contents of the current directory; consult the manual page for complete details.


TIFF Tags

Image-related information such as the image width and height, number of samples, orientation, colorimetric information, etc. are stored in each image directory in fields or tags. Tags are identified by a number that is usually a value registered with the Aldus (now Adobe) Corporation. Beware however that some vendors write TIFF images with tags that are unregistered; in this case interpreting their contents is usually a waste of time.

libtiff reads the contents of a directory all at once and converts the on-disk information to an appropriate in-memory form. While the TIFF specification permits an arbitrary set of tags to be defined and used in a file, the library only understands a limited set of tags. Any unknown tags that are encountered in a file are ignored. There is a mechanism to extend the set of tags the library handles without modifying the library itself; this is described elsewhere.

libtiff provides two interfaces for getting and setting tag values: TIFFGetField and TIFFSetField. These routines use a variable argument list-style interface to pass parameters of different type through a single function interface. The get interface takes one or more pointers to memory locations where the tag values are to be returned and also returns one or zero according to whether the requested tag is defined in the directory. The set interface takes the tag values either by-reference or by-value. The TIFF specification defines default values for some tags. To get the value of a tag, or its default value if it is undefined, the TIFFGetFieldDefaulted interface may be used.

The manual pages for the tag get and set routines specifiy the exact data types and calling conventions required for each tag supported by the library.


TIFF Compression Schemes

libtiff includes support for a wide variety of data compression schemes. In normal operation a compression scheme is automatically used when the TIFF Compression tag is set, either by opening a file for reading, or by setting the tag when writing.

Compression schemes are implemented by software modules termed codecs that implements 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 TIFFRegisterCODEC routine. This interface can also be used to override the core-library implementation for a compression scheme.


Byte Order

The TIFF specification says, and has always said, that a correct TIFF reader must handle images in big-endian and little-endian byte order. libtiff conforms in this respect. Consequently there is no means to force a specific byte order for the data written to a TIFF image file (data is written in the native order of the host CPU unless appending to an existing file, in which case it is written in the byte order specified in the file).


Data Placement

The TIFF specification requires that all information except an 8-byte header can be placed anywhere in a file. In particular, it is perfectly legitimate for directory information to be written after the image data itself. Consequently TIFF is inherently not suitable for passing through a stream-oriented mechanism such as UNIX pipes. Software that require that data be organized in a file in a particular order (e.g. directory information before image data) does not correctly support TIFF. libtiff provides no mechanism for controlling the placement of data in a file; image data is typically written before directory information.


TIFFRGBAImage Support

libtiff provides a high-level interface for reading image data from a TIFF file. This interface handles the details of data organization and format for a wide variety of TIFF files; at least the large majority of those files that one would normally encounter. Image data is, by default, returned as ABGR pixels packed into 32-bit words (8 bits per sample). Rectangular rasters can be read or data can be intercepted at an intermediate level and packed into memory in a format more suitable to the application. The library handles all the details of the format of data stored on disk and, in most cases, if any colorspace conversions are required: bilevel to RGB, greyscale to RGB, CMYK to RGB, YCbCr to RGB, 16-bit samples to 8-bit samples, associated/unassociated alpha, etc.

There are two ways to read image data using this interface. If all the data is to be stored in memory and manipulated at once, then the routine TIFFReadRGBAImage can be used:

    #include "tiffio.h" main(int argc, char* argv[]) { TIFF* tif = TIFFOpen(argv[1], "r"); if (tif) { uint32 w, h; size_t npixels; uint32* raster; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); npixels = w * h; raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) { if (TIFFReadRGBAImage(tif, raster, w, h, 0)) { ...process raster data... } _TIFFfree(raster); } TIFFClose(tif); } exit(0); }
Note above that _TIFFmalloc is used to allocate memory for the raster passed to TIFFReadRGBAImage; this is important to insure the ``appropriate type of memory'' is passed on machines with segmented architectures.

Alternatively, TIFFReadRGBAImage can be replaced with a more low-level interface that permits an application to have more control over this reading procedure. The equivalent to the above is:

    #include "tiffio.h" main(int argc, char* argv[]) { TIFF* tif = TIFFOpen(argv[1], "r"); if (tif) { TIFFRGBAImage img; char emsg[1024]; if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) { size_t npixels; uint32* raster; npixels = img.width * img.height; raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) { if (TIFFRGBAImageGet(&img, raster, img.width, img.width)) { ...process raster data... } _TIFFfree(raster); } TIFFRGBAImageEnd(&img); } else TIFFError(argv[1], emsg); TIFFClose(tif); } exit(0); }
However this usage does not take advantage of the more fine-grained control that's possible. That is, by using this interface it is possible to:
  • repeatedly fetch (and manipulate) an image without opening and closing the file
  • interpose a method for packing raster pixel data according to application-specific needs (or write the data at all)
  • interpose methods that handle TIFF formats that are not already handled by the core library
The first item means that, for example, image viewers that want to handle multiple files can cache decoding information in order to speedup the work required to display a TIFF image.

The second item is the main reason for this interface. By interposing a ``put method'' (the routine that is called to pack pixel data in the raster) it is possible share the core logic that understands how to deal with TIFF while packing the resultant pixels in a format that is optimized for the application. This alternate format might be very different than the 8-bit per sample ABGR format the library writes by default. For example, if the application is going to display the image on an 8-bit colormap display the put routine might take the data and convert it on-the-fly to the best colormap indices for display.

The last item permits an application to extend the library without modifying the core code. By overriding the code provided an application might add support for some esoteric flavor of TIFF that it needs, or it might substitute a packing routine that is able to do optimizations using application/environment-specific information.

The TIFF image viewer found in tools/sgigt.c is an example of an application that makes use of the TIFFRGBAImage support.


Scanline-based Image I/O

The simplest interface provided by libtiff is a scanline-oriented interface that can be used to read TIFF images that have their image data organized in strips (trying to use this interface to read data written in tiles will produce errors.) A scanline is a one pixel high row of image data whose width is the width of the image. Data is returned packed if the image data is stored with samples packed together, or as arrays of separate samples if the data is stored with samples separated. The major limitation of the scanline-oriented interface, other than the need to first identify an existing file as having a suitable organization, is that random access to individual scanlines can only be provided when data is not stored in a compressed format, or when the number of rows in a strip of image data is set to one (RowsPerStrip is one).

Two routines are provided for scanline-based i/o: TIFFReadScanline and TIFFWriteScanline. For example, to read the contents of a file that is assumed to be organized in strips, the following might be used:

    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32 imagelength; tdata_t buf; uint32 row; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); buf = _TIFFmalloc(TIFFScanlineSize(tif)); for (row = 0; row < imagelength; row++) TIFFReadScanline(tif, buf, row); _TIFFfree(buf); TIFFClose(tif); } }
TIFFScanlineSize returns the number of bytes in a decoded scanline, as returned by TIFFReadScanline. Note however that if the file had been create with samples written in separate planes, then the above code would only read data that contained the first sample of each pixel; to handle either case one might use the following instead:
    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32 imagelength; tdata_t buf; uint32 row; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); buf = _TIFFmalloc(TIFFScanlineSize(tif)); if (config == PLANARCONFIG_CONTIG) { for (row = 0; row < imagelength; row++) TIFFReadScanline(tif, buf, row); } else if (config == PLANARCONFIG_SEPARATE) { uint16 s, nsamples; TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &nsamples); for (s = 0; s < nsamples; s++) for (row = 0; row < imagelength; row++) TIFFReadScanline(tif, buf, row, s); } _TIFFfree(buf); TIFFClose(tif); } }
Beware however that if the following code were used instead to read data in the case PLANARCONFIG_SEPARATE,
    for (row = 0; row < imagelength; row++) for (s = 0; s < nsamples; s++) TIFFReadScanline(tif, buf, row, s);
then problems would arise if RowsPerStrip was not one because the order in which scanlines are requested would require random access to data within strips (something that is not supported by the library when strips are compressed).


Strip-oriented Image I/O

The strip-oriented interfaces provided by the library provide access to entire strips of data. Unlike the scanline-oriented calls, data can be read or written compressed or uncompressed. Accessing data at a strip (or tile) level is often desirable because there are no complications with regard to random access to data within strips.

A simple example of reading an image by strips is:

    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { tdata_t buf; tstrip_t strip; buf = _TIFFmalloc(TIFFStripSize(tif)); for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) TIFFReadEncodedStrip(tif, strip, buf, (tsize_t) -1); _TIFFfree(buf); TIFFClose(tif); } }
Notice how a strip size of -1 is used; TIFFReadEncodedStrip will calculate the appropriate size in this case.

The above code reads strips in the order in which the data is physically stored in the file. If multiple samples are present and data is stored with PLANARCONFIG_SEPARATE then all the strips of data holding the first sample will be read, followed by strips for the second sample, etc.

Finally, note that the last strip of data in an image may have fewer rows in it than specified by the RowsPerStrip tag. A reader should not assume that each decoded strip contains a full set of rows in it.

The following is an example of how to read raw strips of data from a file:

    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { tdata_t buf; tstrip_t strip; uint32* bc; uint32 stripsize; TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); stripsize = bc[0]; buf = _TIFFmalloc(stripsize); for (strip = 0; strip < TIFFNumberOfStrips(tif); strip++) { if (bc[strip] > stripsize) { buf = _TIFFrealloc(buf, bc[strip]); stripsize = bc[strip]; } TIFFReadRawStrip(tif, strip, buf, bc[strip]); } _TIFFfree(buf); TIFFClose(tif); } }
As above the strips are read in the order in which they are physically stored in the file; this may be different from the logical ordering expected by an application.


Tile-oriented Image I/O

Tiles of data may be read and written in a manner similar to strips. With this interface, an image is broken up into a set of rectangular areas that may have dimensions less than the image width and height. All the tiles in an image have the same size, and the tile width and length must each be a multiple of 16 pixels. Tiles are ordered left-to-right and top-to-bottom in an image. As for scanlines, samples can be packed contiguously or separately. When separated, all the tiles for a sample are colocated in the file. That is, all the tiles for sample 0 appear before the tiles for sample 1, etc.

Tiles and strips may also be extended in a z dimension to form volumes. Data volumes are organized as "slices". That is, all the data for a slice is colocated. Volumes whose data is organized in tiles can also have a tile depth so that data can be organized in cubes.

There are actually two interfaces for tiles. One interface is similar to scanlines, to read a tiled image, code of the following sort might be used:

    main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { uint32 imageWidth, imageLength; uint32 tileWidth, tileLength; uint32 x, y; tdata_t buf; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength); TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth); TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileLength); buf = _TIFFmalloc(TIFFTileSize(tif)); for (y = 0; y < imageLength; y += tileLength) for (x = 0; x < imageWidth; x += tileWidth) TIFFReadTile(tif, buf, x, y, 0); _TIFFfree(buf); TIFFClose(tif); } }
(once again, we assume samples are packed contiguously.)

Alternatively a direct interface to the low-level data is provided a la strips. Tiles can be read with TIFFReadEncodedTile or TIFFReadRawTile, and written with TIFFWriteEncodedTile or TIFFWriteRawTile. For example, to read all the tiles in an image:

    #include "tiffio.h" main() { TIFF* tif = TIFFOpen("myfile.tif", "r"); if (tif) { tdata_t buf; ttile_t tile; buf = _TIFFmalloc(TIFFTileSize(tif)); for (tile = 0; tile < TIFFNumberOfTiles(tif); tile++) TIFFReadEncodedTile(tif, tile, buf, (tsize_t) -1); _TIFFfree(buf); TIFFClose(tif); } }


Other Stuff

Some other stuff will almost certainly go here...


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/07 02:34:32 $
alloc(TIFFTileSize(tif)); for (tile = 0; tile < TIFFNumberOfTiles(tif); tile++) TIFFReadEncodedTile(tif, tile, buf, (tsize_t) -1); _TIFFfree(buf); TIFFClose(tif); } }


Other Stuff

Some other stuff will almost certainly go here...


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/07/07 02:34:32 $
tiff-v3.4beta018/html/misc.html000444 004341 000024 00000007155 06003063024 016137 0ustar00samuser000000 000000 Acknowledgments and Other Issues

Acknowledgments and Other Issues

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 Netscape Navigator.


Acknowledgements

The LZW algorithm is derived from the compress program (the proper attribution is included in the source code). The Group 3 fax stuff originated as code from Jef Poskanzer, but has since been rewritten several times. The latest version uses an algorithm from Frank Cringle -- consult libtiff/mkg3states.c and libtiff/tif_fax3.h for further information. The JPEG support was written by Tom Lane and is dependent on the excellent work of Tom Lane and the Independent JPEG Group (IJG) who distribute their work under friendly licensing similar to this software. Many other people have by now helped with bug fixes and code; a few of the more persistent contributors have been:
    Bjorn P. Brox		Dan McCoy
    J.T. Conklin		Richard Minner
    Soren Pingel Dalsgaard	Niles Ritter
    Steve Johnson		Karsten Spang
(my apology to anyone that was inadvertently not listed.)

Warning

It appears that Unisys is actively pursuing copyright control on the LZW compression algorithm. In particular, users of the LZW compression within the TIFF framework. For this reason the TIFF 6.0 spec states that LZW compression is not recommended. It is unclear at this time what compression algorithm will be used in place of it. I have no idea what this means to you or to this library. I make no warranty or guarantees with regard to the LZW support in this library.

Use and Copyright

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.

Copyright (c) 1988-1995 Sam Leffler
Copyright (c) 1991-1995 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.


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/28 23:57:28 $
LE 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.


Sam Leffler / Netscape Navigator.

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 for some of the more esoteric portions of the 6.0 TIFF spec.

Core requirements Both "MM" and "II" byte orders are handled. Both packed and separated planar configuration of samples. Any number of samples per pixel (memory permitting). Any image width and height (memory permitting). Multiple subfiles can be read and written. Editing is not supported in that related subfiles (e.g. a reduced resolution version of an image) are not automatically updated.

Tags handled: ExtraSamples, ImageWidth, ImageLength, NewSubfileType, ResolutionUnit. Rowsperstrip, StripOffsets, StripByteCounts, XResolution, YResolution,

Tiled Images TileWidth, TileLength, TileOffsets, TileByteCounts
Image Colorimetry Information WhitePoint, PrimaryChromaticities, TransferFunction, ReferenceBlackWhite
Class B for bilevel images SamplesPerPixel = 1
BitsPerSample = 1
Compression = 1 (none), 2 (CCITT 1D), or 32773 (PackBits)
PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black)
Class G for grayscale images SamplesPerPixel = 1
BitsPerSample = 4, 8
Compression = 1 (none) 5 (LZW)
PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black)
Class P for palette color images SamplesPerPixel = 1
BitsPerSample = 1-8
Compression = 1 (none) 5 (LZW)
PhotometricInterpretation = 3 (Palette RGB)
ColorMap
Class R for RGB full color images SamplesPerPixel = 3
BitsPerSample = <8,8,8>
PlanarConfiguration = 1, 2
Compression = 1 (none) 5 (LZW)
PhotometricInterpretation = 2 (RGB)
Class F for facsimile (Class B tags plus...)
Compression = 3 (CCITT Group 3), 4 (CCITT Group 4)
FillOrder = 1 (MSB), 2 (LSB)
Group3Options = 1 (2d encoding), 4 (zero fill), 5 (2d+fill)
ImageWidth = 1728, 2048, 2482
NewSubFileType = 2
ResolutionUnit = 2 (Inch), 3 (Centimeter)
PageNumber, XResolution, YResolution, Software, BadFaxLines, CleanFaxData, ConsecutiveBadFaxLines, DateTime, DocumentName, ImageDescription, Orientation
Class S for separated images SamplesPerPixel = 4
PlanarConfiguration = 1, 2
Compression = 1 (none), 5 (LZW)
PhotometricInterpretation = 5 (Separated)
InkSet = 1 (CMYK)
DotRange, InkNames, DotRange, TargetPrinter
Class Y for YCbCr images SamplesPerPixel = 3
BitsPerSample = <8,8,8>
PlanarConfiguration = 1, 2
Compression = 1 (none), 5 (LZW), 7 (JPEG)
PhotometricInterpretation = 6 (YCbCr)
YCbCrCoefficients, YCbCrSubsampling, YCbCrPositioning
(colorimetry info from Appendix H; see above)
Class "JPEG" for JPEG images (per TTN2) PhotometricInterpretation = 1 (grayscale), 2 (RGB), 5 (CMYK), 6 (YCbCr)
(Class Y tags if YCbCr)
(Class S tags if CMYK)
Compression = 7 (JPEG)

In addition, the library supports some optional compression algorithms that are, in some cases, of dubious value.

    Compression = 32766	NeXT 2-bit encoding
    Compression = 32809	ThunderScan 4-bit encoding
    Compression = 34999	PKZIP-style Deflate encoding (experimental)
Note that there is no support for the JPEG-related tags defined in the 6.0 specification; the JPEG support is based on the post-6.0 proposal given in TIFF Technical Note #2.

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 reads and writes the tag, but does not use it internally.

Tag Name Value R/W Library's Use (Comments)
NewSubFileType 254 R/W none (called SubFileType in <tiff.h>)
SubFileType 255 R/W none (called OSubFileType in <tiff.h>)
ImageWidth 256 R/W lots
ImageLength 257 R/W lots
BitsPerSample 258 R/W lots
Compression 259 R/W to select appropriate codec
PhotometricInterpretation 262 R/W lots
Thresholding 263 R/W  
CellWidth 264   parsed but ignored
CellLength 265   parsed but ignored
FillOrder 266 R/W control bit order
DocumentName 269 R/W  
ImageDescription 270 R/W  
Make 271 R/W  
Model 272 R/W  
StripOffsets 273 R/W data i/o
Orientation 274 R/W  
SamplesPerPixel 277 R/W lots
RowsPerStrip 278 R/W data i/o
StripByteCounts 279 R/W data i/o
MinSampleValue 280 R/W  
MaxSampleValue 281 R/W  
XResolution 282 R/W  
YResolution 283 R/W used by Group 3 2d encoder
PlanarConfiguration 284 R/W data i/o
PageName 285 R/W  
XPosition 286 R/W  
YPosition 286 R/W  
FreeOffsets 288   parsed but ignored
FreeByteCounts 289   parsed but ignored
GrayResponseUnit 290   parsed but ignored
GrayResponseCurve 291   parsed but ignored
Group3Options 292 R/W used by Group 3 codec
Group4Options 293 R/W  
ResolutionUnit 296 R/W used by Group 3 2d encoder
PageNumber 297 R/W  
ColorResponseUnit 300   parsed but ignored
TransferFunction 301 R/W  
Software 305 R/W  
DateTime 306 R/W  
Artist 315 R/W  
HostComputer 316 R/W  
Predictor 317 R/W used by LZW codec
WhitePoint 318 R/W  
PrimaryChromacities 319 R/W  
ColorMap 320 R/W  
TileWidth 322 R/W data i/o
TileLength 323 R/W data i/o
TileOffsets 324 R/W data i/o
TileByteCounts 324 R/W data i/o
BadFaxLines 326 R/W  
CleanFaxData 327 R/W  
ConsecutiveBadFaxLines 328 R/W  
SubIFD 330 R/W subimage descriptor support
InkSet 332 R/W  
InkNames 333 R/W  
DotRange 336 R/W  
TargetPrinter 337 R/W  
ExtraSamples 338 R/W lots
SampleFormat 339 R/W  
SMinSampleValue 340 R/W  
SMaxSampleValue 341 R/W  
JPEGTables 347 R/W used by JPEG codec
YCbCrCoefficients 529 R/W used by TIFFReadRGBAImage support
YCbCrSubsampling 530 R/W tile/strip size calculations
YCbCrPositioning 531 R/W  
ReferenceBlackWhite 532 R/W  
Matteing 32995 R none (obsoleted by ExtraSamples tag)
DataType 32996 R none (obsoleted by SampleFormat tag)
ImageDepth 32997 R/W tile/strip calculations
TileDepth 32998 R/W tile/strip calculations

The Matteing and DataType tags have been obsoleted by the 6.0 ExtraSamples and SampleFormat tags. Consult the documentation on the ExtraSamples tag and Associated Alpha for elaboration. Note however that if you use Associated Alpha, you are expected to save data that is pre-multipled by Alpha. If this means nothing to you, check out Porter & Duff's paper in the '84 SIGGRAPH proceedings: "Compositing Digital Images".

The ImageDepth tag is a non-standard, but registered tag that specifies the Z-dimension of volumetric data. The combination of ImageWidth, ImageLength, and ImageDepth, defines a 3D volume of pixels that are further specified by BitsPerSample and SamplesPerPixel. The TileDepth tag (also non-standard, but registered) can be used to specified a subvolume "tiling" of a volume of data.

The Colorimetry, and CMYK tags are additions that appear in TIFF 6.0. Consult the TIFF 6.0 specification included in the doc directory and online.

The JPEG-related tag is specified in TIFF Technical Note #2 which defines a revised JPEG-in-TIFF scheme (revised over that appendix that was part of the TIFF 6.0 specification).


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/30 23:28:32 $
tion included in the doc directory and online.

The JPEG-related tag is specified in TIFF Technical Note #2 which defines a revised JPEG-in-TIFF scheme (revised over that appendix that was part of the TIFF 6.0 specification).


Sam Leffler / TIFF Tools Overview

TIFF Tools Overview

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 Netscape Navigator.

This software distribution comes with a small collection of programs for converting non-TIFF format images to TIFF and for manipulating and interogating the contents of TIFF images. Several of these tools are useful in their own right. Many of them however are more intended to serve as programming examples for using the TIFF library.

Device-dependent Programs

There are two device-dependent programs that serve as simple examples for writing programs to display and save TIFF images.

tiffgt     Display the contents of one or more TIFF images on a Silicon Graphics system using the Silicon Graphics IRIS GL. The software makes extensive use of the TIFFRGBAImage facilities described elsewhere.
tiffsv A program to save all or part of a screen dump on a Silicon Graphics system. As for tiffgt this code, while written to use the IRIS GL, can be easily tailored to other devices.

Device-independent Programs

The remaining programs should be device-independent:

tiffinfo Display information about one or more TIFF files.
tiffdump Display the verbatim contents of the TIFF directory in a file (it's very useful for debugging bogus files that you may get from someone that claims they support TIFF)
tiffcp Copy, concatenate, and convert TIFF images (e.g. switching from Compression=5 to Compression=1)
tiff2ps Convert TIFF images to PostScript
tiffcmp Compare the contents of two TIFF files (it does not check all the directory information, but does check all the data)
tiff2bw A simple program to convert a color image to grayscale
ras2tiff A quick hack that converts Sun rasterfile format images to TIFF -- it's less than complete
rgb2ycbcr Convert an RGB, grayscale, or bilevel TIFF image to a YCbCr TIFF image; it's mainly provided for testing
gif2tiff A quick hack that converts GIF 87a format images to TIFF
ppm2tiff A quick hack that converts PPM format images to TIFF
fax2tiff Convert raw Group 3 or Group 4 facsimile data to TIFF
pal2rgb Convert a Palette-style image to a full color RGB image by applying the colormap
tiffdither Dither a b&w image into a bilevel image (suitable for use in creating fax files)
tiffsplit Create one or more single-image files from a (possibly) multi-image file
fax2ps Convert a Group 3- or Group 4- compressed TIFF to PostScript that is significantly more compressed than is generated by tiff2ps (unless tiff2ps writes PS Level II)
thumbnail Copy a bilevel TIFF to one that includes 8-bit greyscale "thumbnail images" for each page; it is provided as an example of how one might use the SubIFD tag (and the library support for it)
tiffmedian A version of Paul Heckbert's median cut program that reads an RGB TIFF image, and creates a TIFF palette file as a result; it's useful for converting full-color RGB images to 8-bit color for your friends that have cheapo 8-bit framebuffers.
sgi2tiff A program to convert SGI image files to TIFF. This program is only useful on SGI machines as it uses -limage.

Check out the manual pages for details about the above programs.


Sam Leffler / sam@engr.sgi.com. Last updated: $Date: 1995/06/28 23:57:28 $
riends thtiff-v3.4beta018/html/v3.4beta018.html000444 004341 000024 00000005062 06003062672 016766 0ustar00samuser000000 000000 Changes in TIFF v3.4beta018 TIFF CHANGE INFORMATION

This document describes the changes made to the software between the previous and current versions (see above). If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here:


CHANGES IN THE SOFTWARE CONFIGURATION:
  • configure now recognizes IRIX 6.x systems
  • configure now uses ENVOPTS when searching for an ANSI C compiler; this fixes a problem configuring the software under HP/UX with the native C compiler
  • configure now correctly recognizes memory-mapped files are supported under AIX


CHANGES IN LIBTIFF:
  • make install now properly installs the include files
  • some portability fixes from Bjorn Brox
  • the G3/G4 codec now warns about decoded rows that are longer than the image/tile width
  • changes from Frank Cringle to make the library work with the gcc-specific bounds checking software
  • miscellaneous fixes to TIFFPrintDirectory
  • bug fix to correct a problem where TIFFWriteRawStrip could not be used to automatically grow an image's length


CHANGES IN THE TOOLS:
  • fixes from Frank Cringle to update fax2tiff
  • portability fixes to tiff2bw and tiffcmp
  • tiffdump now uses the byte swapping routines in the library
TIFF home page.

Sam Leffler / sam@engr.sgi.com Last updated $Date: 1995/07/19 01:54:02 $.
B>CHANGES IN THE TOOLS:
  • fixes from Frank Cringle to update fax2tiff
  • portability fixes to tiff2bw and tiffcmp
  • tiffdump now uses the byte swapping routines in the library
TIFF home page.

Sam Leffler / sam@engr.sgi.com Last updated $Date: 1tiff-v3.4beta018/html/v3.4beta016.html000444 004341 000024 00000007622 06003063025 016761 0ustar00samuser000000 000000 Changes in TIFF v3.4beta016 TIFF CHANGE INFORMATION

This document describes the changes made to the software between the previous and current versions (see above). If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here:


CHANGES IN THE SOFTWARE CONFIGURATION:
  • support was added for configuring the Deflate codec
  • support was added for the HTML documentation
  • codecs that are not configured for inclusion in the library are no longer compiled


CHANGES IN LIBTIFF:
  • support was added for registering new codecs external to the library and for overriding the codecs that are builtin to the library
  • emulation support for the old DataType tag was improved
  • suppport was added for the SMinSampleValue and SMaxSampleValue tags
  • the library no longer ignores TileWidth and TileLength tags whose values are not a multiple of 16 (per the spec); this permits old, improperly written, images to be read
  • the support for the Predictor tag was placed in a reusable module so that it can be shared by multiple codecs
  • experimental compression support was added for the Deflate algorithm (using the freely available zlib package)
  • a new routine, TIFFWriteBufferSetup was added a la the routine TIFFReadBufferSetup
  • the DSO version of the library is now statically linked with the JPEG and Deflate libraries; this means applications that link against the DSO do not also need to link against these ancillary libraries


CHANGES IN THE TOOLS:
  • all the tools now use common code to process compress-oriented arguments
  • tiffdump should now compile on a Macintosh with MPW


CHANGES IN THE MANUAL PAGES:
  • everything was updated


CHANGES IN THE DOCUMENTATION:
  • everything was updated


CHANGES IN CONTRIBUTED SOFTWARE:
  • contrib/dbs/xtiff was made to compile
  • contrib/mac-mpw is new support for compiling the software on a Macintosh under MPW; consult the documentation for details
  • contrib/tags is information on how to use the tag extenion facilities; consult contrib/tags/README for details
TIFF home page.

Sam Leffler / sam@engr.sgi.com Last updated $Date: 1995/07/03 18:00:03 $.
Macintosh under MPW; consult the documentation for details
  • contrib/tags Changes in TIFF v3.4beta007 TIFF CHANGE INFORMATION

    This document describes the changes made to the software between the previous and current versions (see above). If you don't find something listed here, then it was not done in this timeframe, or it was not considered important enough to be mentioned. The following information is located here:


    CHANGES IN THE SOFTWARE CONFIGURATION:
    • bit order was corrected for Pentium systems
    • a new define, HOST_BIGENDIAN, was added for code that wants to statically use information about native cpu byte order


    CHANGES IN LIBTIFF:
    • the G3/G4 decoder was replaced by a new one that is faster and has smaller state tables
    • Niles Ritter's client tag extension hooks were added
    • a new routine TIFFCurrentDirOffset was added for applications that want to find out the file offset of a TIFF directory
    • the calculation of the number of strips in an image was corected for images with certain esoteric configurations
    • a potential memory leak (very unlikely) was plugged
    • the TIFFReadRGBAImage support was completely rewritten and new, more flexible support was added for reading images into a fixed-format raster
    • YCbCr to RGB conversion done in the TIFFReadRGBAImage support was optimized
    • a bug in JPEG support calculation of strip size was corrected
    • the LZW decoder was changed to initialize the code table to zero to lessen potential problems that arise when invalid data is decoded
    • tiffcomp.h is now aware of OS/2
    • some function prototypes in tiffio.h and tiffiop.h that contained parameter names have been changed to avoid complaints from certain compilers


    CHANGES IN THE PORTABILITY SUPPORT:
    • Makefile.in has been corrected to use the parameters chosen by the configure script


    CHANGES IN THE TOOLS:
    • fax2ps has been rewritten and moved over from the user contributed software
    • an uninitialized variable in pal2rgb has been fixed
    • ras2tiff now converts 24-bit RGB raster data so that samples are written in the proper order
    • tiff2ps has been updated to include fixes and enhancements from Alberto Accomazzi
    • tiffcp now has a -o option to select a directory by file offset
    • tiffinfo is now capable of displaying the raw undecoded image data in a file
    • tiffgt has been rewritten to use the new TIFFRGBAImage support and to handle multiple files
    TIFF home page.

    Sam Leffler / sam@engr.sgi.com Last updated $Date: 1995/07/03 18:00:06 $.
    to select a directory by file offset
  • tiffinfo is now capable of displaying the raw undecoded image data in a file
  • tiffgt has been rewritten to use the new TIFFRGBAImage support and to handle mtiff-v3.4beta018/dist/tiff.alpha000644 004341 000024 00000000021 06003062713 016243 0ustar00samuser000000 000000 define ALPHA 018 L> TIFF home page.

    Sam Leffler / sam@engr.sgi.com Last updated $Date: 1995/07/03 18:00:06 $.
    to select a diory by fµ¢0@«Tet <Frˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆ†ÅĈ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úžten se the new TIFFRÿÅbÿÅw/ÿ®ˆ›p@<à and to handle mtiff-v3.4beta018/dist/tiff.version000644 004341 000024 00000000031 06003062713 016644 0ustar00samuser000000 000000 define TIFF_VNUM 3.4beta REF="index.html"> TIFF home page.

    Sam Leffler / sam@engr.sgi.com Last updated $Date: 1995/07/03 18:00:06 $.
    to select a diory by fµ¢0@«Tet <Fsˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|‰+{ôˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úžten se the new TIFFRÿŃÿŘ/ÿ®Œ›p@<à and to handle mtiff-v3.4beta018/html/images/back.gif000644 004341 000024 00000001750 05775022767 017177 0ustar00samuser000000 000000 GIF87aç$Hm‘¶Úÿ$$$H$m$‘$¶$Ú$ÿ$H$HHHmH‘H¶HÚHÿHm$mHmmm‘m¶mÚmÿm‘$‘H‘m‘‘‘¶‘Ú‘ÿ‘¶$¶H¶m¶‘¶¶¶Ú¶ÿ¶Ú$ÚHÚmÚ‘Ú¶ÚÚÚÿÚÿ$ÿHÿmÿ‘ÿ¶ÿÚÿÿÿU$UHUmU‘U¶UÚUÿU$U$$UH$Um$U‘$U¶$UÚ$Uÿ$UHU$HUHHUmHU‘HU¶HUÚHUÿHUmU$mUHmUmmU‘mU¶mUÚmUÿmU‘U$‘UH‘Um‘U‘‘U¶‘UÚ‘Uÿ‘U¶U$¶UH¶Um¶U‘¶U¶¶UÚ¶Uÿ¶UÚU$ÚUHÚUmÚU‘ÚU¶ÚUÚÚUÿÚUÿU$ÿUHÿUmÿU‘ÿU¶ÿUÚÿUÿÿUª$ªHªmª‘ª¶ªÚªÿª$ª$$ªH$ªm$ª‘$ª¶$ªÚ$ªÿ$ªHª$HªHHªmHª‘Hª¶HªÚHªÿHªmª$mªHmªmmª‘mª¶mªÚmªÿmª‘ª$‘ªH‘ªm‘ª‘‘ª¶‘ªÚ‘ªÿ‘ª¶ª$¶ªH¶ªm¶ª‘¶ª¶¶ªÚ¶ªÿ¶ªÚª$ÚªHÚªmÚª‘Úª¶ÚªÚÚªÿÚªÿª$ÿªHÿªmÿª‘ÿª¶ÿªÚÿªÿÿªÿ$ÿHÿmÿ‘ÿ¶ÿÚÿÿÿ$ÿ$$ÿH$ÿm$ÿ‘$ÿ¶$ÿÚ$ÿÿ$ÿHÿ$HÿHHÿmHÿ‘Hÿ¶HÿÚHÿÿHÿmÿ$mÿHmÿmmÿ‘mÿ¶mÿÚmÿÿmÿ‘ÿ$‘ÿH‘ÿm‘ÿ‘‘ÿ¶‘ÿÚ‘ÿÿ‘ÿ¶ÿ$¶ÿH¶ÿm¶ÿ‘¶ÿ¶¶ÿÚ¶ÿÿ¶ÿÚÿ$ÚÿHÚÿmÚÿ‘Úÿ¶ÚÿÚÚÿÿÚÿÿÿ$ÿÿHÿÿmÿÿ‘ÿÿ¶ÿÿÚÿÿÿÿÿ,ÍíÙú7° Áƒ ’²×ª¡Ã‡Ú#õ¢ÅV)’igk‹­ˆ)>üGÊÓ­P¶B eK;Š¶‚tH  "'¦Ü‰’a+ 71rÜâ“æÃ-À €IÒäNRRN’’ Œ­b%•HÆ-TŠâP'C®À€HJTµ­¤‰CϲmKX"‘­H¦Ü$­nÛ$ujmHª* I’¤HÂ[6pJ2À¢òäIjèG‡d¤ÌtØ´§Ìž)aÊÜ ÒìdÐ=;’"CjËêÖ¯]³–Ý* ;mªÿmª‘ª$‘ªH‘ªm‘ª‘‘ª¶‘ªÚtiff-v3.4beta018/html/images/bali.jpg000644 004341 000024 00000063050 05774153750 017216 0ustar00samuser000000 000000 ÿØÿàJFIFÿÛCÿÛCÿÀkž"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?þßo<[w,ïÛ®Ùfœ[Ý\Ý;ØÙìœÃyÐiKu$OmR i­Vh¤‰Û.î–Œw—÷6Û/&û2ÎË<ÿe†eK™&òÚæ=Ó[έnÏ ²…2ܸˆ çç¯noË—È™HÍa圸K›?&t15­¤öFÞ3hîRhî#Ba—ȶÎóš€óªFa DvÓKu’ó»Ë …mà•ÖI¯d–#ecaÌ Aõò•<:›P¦ùa?sšr’ÖNòªá(ï)5£N8Æ«çö“—«†ÀÉkRRŒn§55gF1sU#Oš•H?g'B­JJ´qtä݇=÷VŠ'k©®gݙ䷼…dAŽ™#X®â/?}ö—62.^ÝÒâM˧§ë6°Mq$ j¬°¸¶™<æd*Â1,P ›¸ ‘I4"ñìAÏüŸÁEà©ÿn¿híWà_ÀO·Ã?†¿.uøÃÆ~Ö§Ó5oø®÷Jíí|Y6ùü1ÿf§>±à_}›ÃðÜè-Ñ5oˆpøŠïÄ6~> åÿbßÛ»â/À¿ü=âOXÛhÞøã;ÿ„žœxb+mWãÄCâ Ýk·w5ÿŒ|s©j÷Þ>Xu-SGñìº7ü ðãÅï­xOV¿º†ëß‚çž9pKÇSàLDñµqXjš™žmEa£”à*`ðõq¸¬%Y×ÄRÄÕxx,} ƼéR§„ÆSÂR£,d1 GúWô^ãÏ€p¼q F_OŒ¯—OÃuጎe<·ˆt~¹*ÑÃTú“Ž'.ž •±!ŽÄS­,&36/û²¼¸Šy£¹š!]áIŒåî&Ž ‹˜72¬~\r¤%[ʘüµy<§ŽMkMBêDÞ÷·=ì²C´Ú±ÃæG*OR‰­å2MþJö¯¹¥¼Ue¶üiÿ‚O~Ó_ÿi€^=ñïÄvmcâ _|mg{u&§qw`þ—NðÝî…†4i¥YøoÂvöóÜhún›gm,SêÚ>«¬j×WZþ¡¯B?X4QÌeØE$R 0–ýë¦ÇX®¼ Îí*$%%ŽQË‹£2þ§‘fx%É2üÿ-¨f¸zXœ Ô#¸Òü â¦òŸ‚?ðP/ÚþoÙÛÞ8Õmþ*øƒâ—Ãÿ‚³Ï†¼ ž'‡ÀSxvûGñŬ«áÏi7ÃâM[SÑ-¿á`øƒÅº|gã_jv7~—Á^!ÔõoÇó¿¸K)Ïó.£…Çf8Œ¶Ž9T¯…t!B¾gƒ´c•P–"¬':¸Š¾Ó G—ÕjcU ¥]baVŸìù'Ñ_ŽsžÉø²®'+ÊðùÆ;.öY}yWÄchdXù{Ùõg†…jP¡†Ã×Âæ50Š´ªG+–'‰–8yAÿpáÈ-–‘›ríYU²òšv‚IKÛP¨ $K³ÊùÉ?m€ßõ»_xûÅ1éz½ÚÅV^ÚÅp·W¯4’ù·I3.žd\,‘A}ó#[¡š±ügûGÛü*ýîÿi_‰ÞÕ|3'†~Åñ_ƾÖ4ívÃYO[kúƒ&¶ºŽ=>Ë\¶Ö¥ Ía6:µªÛOq$Í+/ù™þÑ_~8~ÖÞ0ø‡ñ¿âLjõFñG¼Sªø£KÐtýcPÐ4o O­5Äö>ÒÙ®^GðÍÕìVzN¥©Úê«2ZérÜjɦÂÍõœ[ÇÙå¸ n*_ZÄæÎ’Ëð~Ñáf©ÍGŸˆæ£Qà EΚªœaRR”©Áº´«FŸÈxYà–yâ.e›aè*TðY,jÇŒ¨±?Wž&Š¬£†ÃËzµ+º<ñmAªÚrÊjQ‡ú¡|3øåð³âÝ´òø#ÆZV±ue$pjšm¶§m5ö•y,1^Ge{3ÈažhζŒá®íî­ÕíYeoPp”ØÏÊÎ#gp7ª,6K‚üÐÙp²á°Â=ßäãø*7ÇïØæóÃ^øâÏxSâ=ç‡þë7>'žK kJ×_Gô»ã:]jÒ^ß]êÐé‘A~.a“R0Ki Ή¤YBÿÜüoþ Yðóþ ð£LðÄ=cMðGí7á¬4¿x]ÖôØuNmõ?´ü=möˆ/.%¾‚9îl—~uÅÈÓÅšGö?G„ø£Å9.7–“ÔÌ'^x| yÇÍ„Ž&­,&"–*”aíc‰¥s•ðð’•>z«’¤¾¼6|Ä™¾E…ÇjÇ'©J†.µ*i}_ øü5dª7˜Jõ§IèïFŒ±.Ôý£¥ý³PÛnI.«±3aÞ$ H QÃòá„fFÛ÷ª¹…rÌnª$€†ÞŽ‚Šº<Žf mÛUY€ŒÂïçÚ/‰­5{}E´ÝNßS6Œºª,5++¥Ò¯4ÙUo4ÙííK±jÒ2ÝYÌÐOÏÚæ-­÷#’ëÏdß$ŽñÝB±½Ì‚f·¸“}´³âK†hí ½„C‰/f(Þ ¶¯ªµÌªSœ.ùgNjp¨’»q”y•®¹Smk$Ý‘ùÍL èJtë{“ƒwM4ÚQOUö{.n]'»DÞKäs*ñTÈY –@ÕºC,ÒMú¶2mPÈùÞŽ•:ÝÛ¼‘¬o,+È 3å\1Ñ\½‚Ǽ¼1@Ê7åÇíõÿJý?àŸsx7@øÃiãßx³Çš\þ!µð¯Ã]O^¦ƒmw%•Æ»sgs§ßµ‰šÞâ ?Iðí¾¿®j7—;Ïkot¿%~ÌŸðpWì#ûYün²øðSVø‹s}´Þjž)ðg‰¼ ‘ø£Åºv¹7‡çÓì5í7ûN[+Ïi·^ÖŽµk£jZOˆM1èšÜÚ¬]\ã"¥,ljfÙ})åøŒ c(_ˆÌ«ÒÁàhÕŠ©)ª•ñxŠ”TZ¦êGÛ:WG»GƒsüT2ú¸|›0œ3l6k‹Êå3•<~$ÂUÆfu0³ÕÖ–…•Ý8^UiÒ¨©)MrŸ¾2Îfó!·4¢9Q£’TD~\3„Û÷ŠeÂZ(fž0¢XÒAy K›–T·\G4R=ËBØUX@Ø €:}šY[! 3å!¹•!•­ç{xGuª½µÇœî“»–ž8ómgsi;,²Ûoš-ø ,ö°Ë%Ì3—žFŠs?¼Î—_¸‰ –ÚO*8fYcyØÅåG À–¶±}¡$dV0¹—(`¹Žh¿q^ßÕK“ÞmÙYµ9©r¤Òz¸´î—³5ÛæµÔ|o¨I¨û?yÊN1qmN¢—,cÊ›¼£$Û›ýãWäݺ׵(VÞ'MñÇ™æY¤€MGqûÀ›f’ A€¼ˆ¬6¬–ñ 2¤±»Nñ¶ûÉ”]o ©W*lž`ò Þ¯,úφ&Òuí:ãGžiþ½ÿ‚FßüUÔ¿c}YøáOxÂú—‰ý©?f­z÷ãÇ=m| à ]OT×µ)äð§ˆ5/Š toü]øƒqüÃÆk¨Ü6‡£ü1ƒWñ€¼;mâ]ÏÀž'ðG¶ëÿ´V»ñwᵟí⿉:D_~k²pØø‚ÿ^Ò~"xzÏJÕ¥»ÔüYñfóáÜ-$²ÓôMZÛĶúÿ€kN½ñGPÖ¾Ëwq§G4sA¦øVHà"ÿlKow`–÷7°ÿ~ Ñ|5ªü.ñ'®¼_ ËâM3â>Ÿ¤ÿÂc©ÚikšMÅ”wú^¯¢øJçL»»m:ÛT´X5­Fno÷IÒö-Ôú°¯Ù_Ûþ ðOöyðM‰?¾|Lñf­áÿÙ7û[Nñ?ßi2x#á§í]¤xWÄ>=ñÿ„luÿiÚŸÅmkÆ ø¯CÕ4kžÐt*ÚÖ? èz=Ôk©Åø-ÿðö_Ãßøóƾ=‹ÃºN½†ì¾Yx·_“Yšé|¦x6ãÀ>'{H$‡M¶ÑÆ‹½µò¥žc`É÷Üaˆâ^4Î(ÿ­XÇ…°ø —‡¨¼ß0YDp9®{„úÓâ<& O2ö°¥‡ÅÅâ0•ñ2ÂÏK X|ú¼>¿ùwØŠ„Í05‚†kOœæøéái˘c0y&+0£—e¸™Â8,F ØUJ´«ÕTœ*ã±U(`3Ol|óû}øÇÄ¿<ñsÂ#ø/Y·ðMÕÄZv§íÀÖ­®µû;kå½¾ò¥ðܶ>t²\É*j¾ œéw–COKMSÛ¾jß~üðçÅÿjK |P—ÁŠ£^ÑeñEãÏáëÕÓoO´·Õl ]]A¹ ÞF·Ê¤+ZÚÄîÿr迲GÂOÚ[ãW‚þ üPÔ¾$|ý™uuŸÇ¾/—Å? |;áoÜø_Ã^!×®Z&ñ5­ßŒ´]Bá­cÕî$ñE§‰|5y ªée¾‘usgq¦~dø×㟃ü#ãÏxGÚÔÚ¦ CÃÚ}Ä6––—ú¥¾—¹áZ½Ó®oZâÚÖ}P´¸ÛªZµÌÖ:‚Ë0Ô™nd›zÚòà̵b3&q?ã#áÉqfO‚Ê¥B²«y¦q–`g–ãqÙe<}*8Z”±l=,º†"—Ö)ãi¼ewI,Ezÿ­ø'gí±ñ'áoÇ/‚<ø»ñ#ÄÞ!ðÆ¥ø+ãV±ñ ÄöÇÃÉ{¨èš_…4ˆ×ºŽ³«Xi6wþ»ðÏ‚Ý5y¤Ö›Àz7‰þ×ssòéšgõ¿ûF|i¶øû?|uý ¯ôYüMaðKà÷ÄoŠóxMš;ñ ?<#­xªçI:“y ŒÚŒ:+XGx¶ó½Ì>l­Ì2ÿžwŽ~$|/¿ý|%ão6ßÁþ1ðæ•áO xRgKÕ5«+I¼Y®|Dñ“£]êRiÚ߃®nuOAÿ 6-k6:æ‚Ú^¡$Ò Þ—yk}sú/Ñ»7ϱy/eY•j®¾6Åf™5LT¥S5Ž•U¥MVs•z4ñO ŠªÔgÍŒÌ1N¤f«Æ¥_È>•Y' Ë9àÎ&É0ÃQxyäCk¼v¶Ð¬@ ­Ä]G ÃÄùÀynLáMÄI>cT‚Oç_á¯ü‹ÂšGÁÿ‚IãöÒ®<]¬ü.øy¬êÚÚ}¦Æ_êúV“9×-tíVãLÕ4« ûÍFÒ[­2î;…Òlõ1guwoqy7—£ûJÁzþ|ýžn>"hºM§~2øÖ×PÐþü=Yt­'ûWW¶Ó`–ïWñeò_AŸàýÚ{{ÝF÷C’}Aïͯö]»j×ñ[¿÷fOˆË3¬» aóŒ ‰Áaó*²Î#‰Ë^.Y©bñ´±ø|=l<ðò›Xš¥F½7Ò…*µêªqþÇdYÞ1ÆaÖ^½<[ÂÅà«añpxˆÊ­ÑsÃb*ДªB¥Ò«†­,$ªÖ”áyÓ¥ˆ´ÿ´Oí;ð+öYðÿ¾>üCÐþøVßuœ—ºåÌfÿ\ÔL¦í´I™ÚþÿXy^ót:dr‘´·í*A 7ñ«ÿ ÿ‚ß~Ùÿhß¾;jñk\ø<þ=ðF§¡jz|3uááý‡¦iÚN·d¿Ú–ë¾ ï5D>ÆîòÞʘÚaæmþâ6wOˆ‡s£•e8:j†+Ž³ü=<672œfOõ_ ŽÃûl¯-öܸjyŒêÒÎñ1 íˆË0˜üNGWö\§ÃîÉð´p¼[WšqVgz<3“Î3¥ANwý»˜áçR3”áV¬pPU £ˆ„«†ƒÇÇá…Ÿ4m'OÓ<+Ò%ÅΉoi#ÚÇ=•É¿··µKƒÌ×WÐ>i+KåÇ5̃H‘¥Š™~·ø¯&Š†ÓÅ1ø†ãC:¥¾¿á CVbjRAqg¬é),°ëvDš•üÚuÌúm•Þ¥a£|!Òîg™Åï€Ý~ÍõصÏAð÷^KÝ_HÕ¬ï,4û›Í>âò_°­Õ¦£>ž7¥•ý²ÝtmElí–Í Ž8îHí|û2|B¶øw®j¾0Ýcck¥FÃÁoqk5Õ®®·cÄÚ}ž‘w7ÛSH–uŽ;›22÷ºˆòŒ^þ?žÇ€cV¾e#Áέ\U=l& V&XŒ]X/d°Ð¨åMó5VTëÁQö‘•YÔÃÆ*ÿ}Á¼kpÂäPà¼ÒŽ †§ŒÄfXì°²ê88Tú¶*XÊpK^p…XÁQRÌcFt¥C‹T*Lý-ÿ‚wé_ï-ø'Åö/…~%½Ú&i­Ùhºü!žÒ5-6[.MïL›@EÒ.´Èí­¬Åºè¦òÎ÷G'SÒe{/ÍÙ‡àç‰,&ñ¼×š¦©ºÒ%–æËQ»‚Õt;!¨ZK©És©Ú=†§¨Å—Fû%ÔR~K[2Âÿoæ4°ÜA‰ÂÇ *øª•¥[:ùt2Ú5(TͪÂ9?a ð•¨FéJnU!‰ÄsS”©ÿNeXZô8G(†;†)c±ui×Âá²ú0Íg³|m)ÔËê¹T ©ýz¾3FºRö7_ìÔ«Rœ%Sö[àÿü¿ðkáî‹û.xcàÄ3û>|$ø]áŸü.øß ô÷ö³/…<¢i6—ƒá†­áMKþ †ÒÎ; äø—YÖåÒì´Áuáÿ´jFÊ×àø*Ÿü#á¯íà‚3¼š„þ+m_—K¾ÑäÐuË{ÿ^ßXÇo¥xŽ)lmµK›mDÜHþ¿â¾ñ ÖÑ_B÷p\þm|Rñðºéþ!Ó¬¡¹¼·¶{[[iã–äèÖZ\jW7ö°nk9ôû=BÍ™/㵺i’æ)Hû9Š?‹ÂüC¬ø‚Â94»7Õì4Ÿù³é“Ä—–2éñM©E6«ÃéP[Ç%Æ”º­½Å”:¥ãO$çQņ›cú}o¿¶rl41Ü9(ð«R¯J8(,Dq50¸šq–*8ŠXh*UhWu1r¯Uœ±q2HOÛÌü ‡ƒ•ò¾!Åárn1¥‡âïi•©æ•Ñ¥S†©V‚§„†7ØU£ZŒ.…)NU'u ²u§^Tªö?²7ô]âÛê6cM6å4v¶²·Hg½½ðú£¤RI3>õ,5OíúKàím.‰<-àò­Ïéφþ0|ðïŠu¯ i:"ÃáJÿEÒl´/ ü/¶Ó4Ï#Vµº:‹^Ç—•®sP½¸Õ-®ã{=:8gó%ó"–ôÜ~.ü5øZ|š¹×®oçÔbÔVßCÕtûƒ¦U·šs=Äs`´bñ\›;ˆn iÒMk­µµÓöŸ¼_âíÃSü>ñ׊tÝÁÛhðE«´·ñoˆ4ûÔ‘,tÓ.‹¡3¬m"Ôìã1H‰Òï´ë‹_µ~S‚Ê3 ö¬ðÜEL,*åT§*³Åb§‡¥F­…¥F›ž3R„±0§þÏ Ò©í(rÆ*béþ™“æS•ðé˜äÊž?ïIâ)C–`+f3ÄJ•,Ljž"†.£)QUCZ8ì ^*iâpÇÐðS/Û#Á>#Éð‚ÀM­MàO X|7—Ä,º“Éáý[Â~°²ÓÅ«ØKµþ“áÿ6§o«{©Ž8åuò,à‚ý™¿i !<ß5íDøQ¼BÚoö¶³y ·–lm®î}N)dyfŠ/³Û §¿V&k$2$“ÜÙGwòÞ§ðXÐ|¶6sÙØj:µ¨¹%Ž¯yy}²{€Ó\êvúLº5­ÕµÄ0\E%„8´ÒZc§½EãHõ-;XÕ4M%/uÝWÅw¾"¿Ó–› Ç¯\ùÖþÓã¸kdH¼1â+K­?L´ˆ ¯ÛR})&³–ÂÃBo³ÏÿÕ|ûSê4põèÒ­Ns©__ ËŠÁÖa± ›Ââ°óX˜^¼éGÙѶTܪ{jŠœ!á'ÆÜÄ‘ÄfÕãF¾&œ§VŽ/ÃâòêÔqµ±9|¦Œ!V†"¥,,°°ç›Œ(×þÓ¥G„ÃsWú'ö»ý­êºnG‰xŠŸø¿áï†< á_„ž5Òüsá?Šº7Å߇sk¾#дۉ`ñÂÿxg[»ðÖ»àڵܺ–•ân,-¼M¡H‹oa®x3_ðÆ­§Êc¾¹³Ó½À7zF¡á¸õ-OE³Ô¬4B×–­‰®/šÂ+H–òæHæ–)çEû-„°ùòR3 Ï°:ý}âO |!ðΟg¨Ú&“2x²é¯b–6‘ßYY%µüª.#Ó zdèØ´º˜Ã§\ÜÇu#jV÷¶wémòFŸà©|ªkš_Ùmn-|#â©^òÕ´ÝBi¼Ik¨Çsªøb Í2ò IltkÍ$éfho´ëa0™b¸÷ Ðàóqî­ZXê¾:øâD“PԯƖšÄ—Z†›áó«Y“s$—wö“ÛèÉkkv.éþÃ{=í­¤M$ööð-‡ˆü[øk¦ø_^ñ6§êßèW°N-¬¦´Óo °´ÓoÌd‘ZÕþÌòÜÛ™¡/}x« à´Õçòdýtýƒ¿f=cVøs¢üDÒRØÏ-½Îo5Ì“G¥6¨t«ë5ÓÓV²’Ñ–æÓWH®`w6Msý¥snæ项ûŠÙ «Jl=Z´¨àæêUÄP”ÕZxì4±¸w*•c©cjGÚR§*“÷¾¯W\²ø\—ˆ3,ç>̱y”<5LFK „©R…W/ÌVÂ8j2’”hSÂâ%ìé*”éÂ…J^Î4%…üùo…ë|ŸµíSAð´ÂÂòMNÇL±¾³¹ðü3^-À¶ÓÃ2éõ¦‹JÑo%g´Ò¢mGûVÊ[ ­×ö‡Uÿ‚§ü:ðÏ‚üð‹Ãvž*Ð|=àí3Om5ã×¼1 Ï¾ 7µÔtËÈ®'û ¥Þ›¨Ü\Cs¥ÛÝÈö÷nè!‘nT~a~Ô°ê? >/7_Ò­^ i1D,îmÖ?jq¤w:GöË{Éí…΢óZÙÛé‹¢;Ü.Þ x|ÛDç|5ãOü}¼›Â?~ /XÛMâ_Zhú…,4g°Òo?áÒntÉuk±,Šöz†šú€‡MÓ„š¤×“H÷ñ›I òø‹…pXüŸ‡³\fx̾µ<ÃUâq?Ù¸ ¿—bý½\-Lêòè’ÜxëHvÑWL²¼ü7Šü ÆÏ°œñ5ò©RÂáÛÌ+Õ§‹tÒ¯|LÔiVö˜JÐÃb2ú¸xé¿~è I<¬þÌZN‰à†¸Ðu_ØèÖžø³ñŸà÷í'àq-~iÖ“|Ö^ßÄ~´¹šßVÔ#ð?Á»ë¿|Gñ›¥ê÷·SÜxIVãW°‡R»ŽÚôY³ÜµýÝ–l÷rGö»­FÐÆÙcW’Þæò÷ÅßÖÒxlxÃá ‡Â^#Óaì7O{yôÝ`ÞXÛEv÷«}as i5­Ä `Ãd—6w2Ê“-–œ·Ÿx¿Wñv¡âÍ_Âøúÿ⎭¯ëº-¾ñ á~«â™ü9­^-®©ª]i]Šü¢x·U¹›S¹Ò4™u-;QÓìtKýV»¹_iú†—sÐ^ø¹âÿéoàûÏiúž½§=Þ™ w:PÕ£Ž}U¿‚úÄøˆê:u”·ime§Ûé1ÝÙZIª}®i5ÆÑî-´»]_ôÜ7…YòœòÎ9O ™>&Yl2þYS©ЫBXjΕZX©Uö÷è^¼¥þkKÇîãJ¹î'ˆ2LvM€ M &{‚©8æTshÞXL^–Æxºì,±\|§†æÃûhMVTppU«ôø]‹<)g>?üXøy«­Õ¥­§‚<ð‹öÖ,¡’bööú‡‰¼AûNþÏSiöó[¬Ö1tYô§M\{Ûûµ7]¤^|ø=ý“uñƒÆÞ Ô~"\êVörx+Rð7ÆO|NðP´²¾ÔâñŒ×ÄÞ¸øG©xSQVº}Ž§ðçã¿Ä _R½¾³žÛ@“I»ºÖ´¿0øsñ#LÖ~*]&¿syg¨Þ\F·Úžæ—amsd¶wnÈÍ$¶ºŒ.ïmra–â5{H®ììîbºÍ÷qñSà…¿ÄíWK“Vñ+ÜZiÚdVšm§›.£u§éÒÎú©3´—Ç ÅµÌ’Ã›Îµ´¸¶‘ ªûÛèóªÙ5CÈø— ·ˆÀa¹1y%*8:tñ5èCŒŽ® ÏZ­ ¸{æ…͆;¦9ʪùþÊ8¶X:\EÀ¼_ŒÏö¦fÿ²¸Ò®',Ë €ÅWË°³ÄÐÌkF T¡?m ùmÖ¥ˆ”jÂx\”høÿí;ñJò÷R±Ô|/«Úji׫›a ^ivö·ð®žï#Ú:Øùš„ÖQ[¬VÓÝK2ÆÖÈÒ :êà|¹ñoâ.‹q¬øjñôk-BÛZ×>ÔÑÊnZ GQÔ®›U¶·Ô,õK"⿺¸g•ç¶` Ñ>š×~ ëÞ𵾇¥_i²Ko¨ÛÁª_ÛjJ÷¶:eæ©ZÞëO{­5Ä6GO±ÑtÓ§hQÙøzÃOKëWGføÏ\Ól‰5k$gÔ%»ºYRú+‹»û«‹h K„d»½[™ÅÅÝÅÊ@ˆßlHôèå‹ì—_oÃ8þÎËðxªçT°¸7VxŒN 🵒£N¬wB”aF¿,iT§5R§4©:3öŸ“qöcâ%ךcjf\+,}zXZv0ÆûeV2u*ÑqÃËZ½Z˜(×zQs§:T#5Hb(¥Ôéÿõ‰~Ó&¾ÆîamsöSok‰îÙ [™¢K›!l#¸–î×uÝ«ÜKwg³²·^NjÚØï­å¸mJ݆ëЗ3Mmkh–«q>ÆM °d´‚<3Å,É%¬rF"ºä¯´½NÎêöÚòÊê ›æò)â+q˜™®Ží [îŠe¶¡$¨q«Æqõ+"7É Ä*'åü²’Ldfu_%þÎŽW€¢¥W†ÃÁÕq›Tù=“'*åŠNšN.÷+|Îò”=ÓòŠœSWœpyæaŽThB¥5)Ó© S­î§=YFtêʤ%î¸Ôs„}š’§ Cöçí÷ìá¹µ¿‡*ÓnµI­®üX|agi6“©ßÃÃ[­Sâ~ªë~¶°hæ ºÄVðÏ{¨Lú<Ÿj–Íe¶·Šý¼|usãOÚ›Çþ)ð¼ÐÇŽ ñ…¼E¥ÉmmÓIÒt—/;Ù#ÊöW:-”“Áw©íçh<í:KÈoãÒ5~|Kð¶‡û-|"´óu ë·_lä@Ó¯®ÅÜ~—JC©\Ë®Á¦ÛK¥hÞ0E$ú]új·þ!š)ôÕDŽæÃâ«ícRѼ!­ëZ¦‰mcâV¾o M£.wr“^jºNŸ«‰§¹¶ŸWŠ=NßSÓnn,î®&Ò%´¸H—MVØú~ÁåµøŒ+æ8 -\ÏQC%N£,-|Û2ÂÐÄÕÁâ±UOhð9n‰£Y*7•z8KʦVýo1ÍáS’Rž6³Ë0t!Š­J®½u}W7ê”ù~§˜â3BxºvRÄN)IÖŒhÓðÿ…7ž#ñŠím£¾Ôoïmíæ:e©˜\y—N«—¥ì½²ÌÓµâIæ¤I´ùÈ„ûG‰|Q®ÞxÊ{ XePñ9ÑÒëM lÆ]wDÓìLÿ¢ ¸ï®5U/ ÜÜÉ ÷ñæúóR"(¬4k?žþøÇQøuãir(¸Ð%{ˆ¦†(ÖIÞ(XÇe&æ{Ty¤o³Ë;Ûja HæNÒôÀoÞx»ö˜ðOŠuK«'UƒR¸°€ÝÞßj³Y<÷S^X”Ó…õÍÜú„ÇTEš+{ëÉRÚÂkë}ñ4:©b+UXl6‚£íiT„b•9Õ©S‘F%ì¦è*S‹Ÿ4hÖIV©íhÉE_à2L^Ã-Áâ*ã±9–7‰ÂâêÃ5ˆž¾½,=^j´jPž¥\?5G )óVÃâ$©Âœ>¯ÑeßÍâÏZøÒ Íq¥ÚÞC¨\ͨ[d_ÄV«téyäÇg­¢µâ]]$÷12ÉZ]ÚÇnš„Ÿ¤?ðJmUÔþø×ᯇ¯íuX´ÏˆIâ8–Æ+8o´)|Iám7í—‘Áy|‹ý”¶‘Û@·­¨}žòYµ[kk-Zä~”x;LÔ>'ü<ø¥gã„’éZ½Ôø»Z’ÜiQ'‡Yü3§0ÓgÔÌ°ÌðZ\\]Í}ªÅd–·–'S´·…ä½I¿$ÿà‘z¥Ïí!ûIjº§càÝQÒ¼?¢M%®§t—Z~±âoG êšt œjGðì6¶«ýœ—3Þà_Z‚Úóìxo0ÆgôüC§ÑÂBy7 åú§ÕpØœ,F75£ˆËªáªNŽ§²¥ÂΛ©.xrÎqS§?¶ÆÇ‚¯ÃÏQÒ£›¼Û S)×Óˆx;èú¿ŽïuŸxŸân~ _O ¾¹¡èí&¿á[O F&¸º½Ò´ ZÆÓÃñkZ‡ìì5ð¿ÃŸ>xÄ? þ.j?¼Eyàhµ_'…Àgá7„>/´:õ•Þµ/ÁKŸÞø+Å1èºÆ·­Câ˜%𢶣§ÜkÚ#Þ[Au¤ó°~Êvö¶ºŽâwÒ­µO‰–ð‡X꺅Ž«ýŸ xþê>/ì°Ðô–¸Jû,b-_YÓ!¿ÕàñC¥æ–n¯µìÛnëþ £âø?f?ŽŸgMTiž!Ö|â]_Pµñ=펫ÍÆŸ‘è¿mðÞ‡>~tæµKm#Åiía­Xj¾#¸Ñõ+ «Í þtþaú@ÓÎð¼)ŒÅp†s˜QÌ8k4¡žÕ£“×öÙvg‚ÇÓÁ¬ß UW­G ¥–guêaêQÆQÄZj’ú¼2¬sKôÏrü–§a2~-Âe9†‰òYåXf2xârÌn[KWõ:øO¬âá†Í2èV„*Ç0§W¡F¬±´£B§ö9ðö2Ѽwâ½CÇ´‡¼3ãïjzåæ¡áx®gø¿ð»àêßøz=úOG­|)øq x×Ä—þ"°Ó|mªxÛYð6¨[BíðÿJÒîá½Ö|yâ¥jÝÀ>øâ‡þ ž7á.«¦ø‡Go…k0è¾ °‡T¹¿´†ÏDðî«à7Ód²»³Ö_D»ð宵okª]êzuÊÃ`Öú}­¯›þÉšÖâoèCWоè¾:Ôn`gÖ¬¼o®xÎßÃåõKTðÆ¡ Î~ø-D¨‰§Ýëú¼¾²—@·}N&ñ±ªµø(ÏÄOh^Ñ4¯‰šU¿ˆ"7édÖ#Tñ¤¾X5ËÍ}.üQ,¾$ñ-æ‘u§ÛÜD<o­µ–ªmïá»Ó¡[-gDþÆq†sŸàsLvaÌñÝ|Î7SŸâe*yb¨åŒ£^Ÿ±Ua…˲ՉUy噫ŒªU̱øêsÅÓý¯”2þ*Ér5)C(§‡«^Ó¼Qt¯ëZ‹}¨iVòø‹Â:pÓ´)µëÓ®‹<óÙ^¼ú¦©iÐêš– §{×įŠ>Ñÿo?‡ŸÀºv§ ks‡º„¢‡Mð¾âëXx¶ÉuÇ¿Ò5;è´}Z/M¥èAu$Cvêþ ŽËH¸°þ̳òß¿ þ(h?¼uá¿øœxØê'½ñ ”º5é›á­ý¯Ä´øÃKñ'€c½¾¹Ò¬µõ̺ý­ÎŠ³ÄtyešïT†=Eî¿Ñ °ùneÃœ;†Ï0J›Âpnµ\ßæU±Ì¯õ|áÖ<êâ~´ób¨â§¥ 1¯ŠÁO„ü'p™†OżS,ê`åŒâüm*x|6 ƒŸ°«õlN¥(ÔÀû(â+Q‹ž –t°ø|-Z­1¯Bœ¼Óàv‹áýG准¹Õ|7{~!ð«ÜÞéÐë[i—ú•ÒDn¦?dcs †›uk<÷ ¨Ùê¥ËÁ-´…ö£Zíº:¬ÿ á)eœSbóLã.†#.ž_G ˜W§J«Ê¥˜`ëÖÃUÆûj”½Œ±8‡Wý¢âS¥:³© q­*Ž/‘ýJž3¯G†®êàháëQÂãçGIO‚žtñS«BŽ…Z½yЧ5]Êœxs/nÔ¼yg«Û^A­Z\éZ…êNº|¶¶ì!›2^içP¹·’ò]B-ödž6Ód»žÝfÔGþКÒÕgùÓá ¯xË[×ï-³jú¼p_hòÙ-–£©Ks›mekuuæˆXuIlÑKØÏßf’í{ Á§^k¶f«7¶~m´“ê7z¥Ü$BïXœ}”Ú5ý½„³Ûˤ¥¼BÝRîÎK¹¾Çsš¼.·á‡ÚEØðüt×3Ëi#\Ë}·Ãº‹Úµà[Yïç›L¿Ó,“Ms,º~ë=BÊÃLMRÊgÔ4»Ö¼ùìë€(ðî[˜áøgùs5J.½ITž†U*Pt!T+Ö¡:»ö”牞-VŸ+ÄòÓ¨þÄÔóŒï'Çq7&24q …ÆyóòJ§·¨ñ)ýa(R¦©Ó­ŠK 8áç…TçRr—†ø‹àÆ“âOêº|“KimykªÙý¦ <Èm[J²Ž;[éôØ®â–àÚë~1µŠK}1uŒ¼·m¥ôƒ³ùŸ¨Y=²$‰/›dîÖÑÜÇ Â¤ë o‘à33+Ú¬®Ék™b’hâŠIíà¸Gô+ûø+Ãþ)ý›¿à¤¿¶Ä»sy¦~Ë4Íáƒ[gOÑtߎߴ7ˆGÃï†÷h^wžî85íWU}f)u;I4ëxaÖìâKø,¦Óÿ¼¦Â[u¥xjêHâ±MJÖêûR ÀØéK5µÍÕÀŽ9f{+KI¯dœÁ ’ÂÖñ³¯ÊRO°Ãpî#„òœƒ•ZÙÎ')˳,×í[¥€§˜á£ŠËðôa':ÔðS£*’U#)º°Uî£Z¯å\u‰ÉøŸ3‹Ë+að°­W4X‘£NÅJ¶7 è¬EE8ØÇêÖ®¥ˆ£R­:J4RTþ?ÐïˆZ|ü<ý’¾øM¿×þ#x—À¶ºßö6‡ [PñÅ T/‡l&€ÚÜ\ÝO}­àïhSZ\½Ååí½Ü9ÓmtØìõí_ø*WÃ/~Í´Ž‰û=XÍáßxövøqð¯à†›­h7SË¥ø›â‡|+kñ?ã]íÂ]Þ]_™¢ý þ0|QθŠÚñ,,Æ’²[\išŽß³ÿà˜ÿ µÚÏþ gðºûÃúPƒÀß®t¯ˆž"Õ|Q-Æ£¤øGŸíÑ/â{ (uk]MtƱɦM¤Ýh~¡ ѾŽ/Zþ1~Ò¯¾8üoøÙñ:ëUHì¼mñwâWŒt]2Ùá¸û(ñ—Œ5 zK©¥p Ýí„ ©Í4’ݼv¶Vw¢ xà‹×­†þÎàü·í#:yæqŽÍ±têóWœðx/k–啱©„“ÄWÌ9)û9óa°Ô«Öq®ÕZžf;ù†;C‹†-â¡ŸÙ}W F8L%9GšÄEÒ©>zsÂצœÔë*xxsÒŒ¥/ñn‰g¦kz¥¦™s%õŽ›´"y• •¥Ñ5ÍÂE÷hŒŽÓ+G%º´—1<‘D×ØŸðNkOÚCÂ:ÿ/gÓô-â[ˆïüÛh-­g¶Ó¯%–îò{ÉbˆÚé–[îÌ^l1¤Ëk<×$1ÁwðÕÔw6“¾ZU¸·– ®’]’¯ˆ,Ìà¨2b@F$‡Ë#ÛÈÍ5Ïôÿ¼ý›¼5Â_|Tñrø~mwÄZÆ›¢x;]Ó¿´àÔl¬tæû3Ú8Ô¢íúÖ‘=Õ•ÄâÚÿO·–é¾Íq¦-õצ CŸ0ÄT• XYÅb!û©}ead°Ò©UFq¥Í‰t«JvåpSNQ_½\<;€žiÄuq¸L¨,±XŠ˜^f¡:¸ºÕpØJ8yÒŒ&¥RqöoÙÊŠ¡RT!)Cêý<øßñÎïÁÿÿjŸ‰ß üm,Þ%½Öž]P»Óm¿±ôÍ?Âú}¶•`·æ÷ì²&«YEq¨†šûQ¿Š)ã6™¹¶Ò!ðÿø"ǃî¼ðÿ[ÕšÆþÖûã?ŠµKý_$Žû@ð½¦èZL7)q5¼n²»½ñ¨Ó®‰5 N9/tÙ4›k·¸ù·ö¼ý¡5o‡³—쟣hÚ_…$üxø“á½b×_ƒÄžñÞ¥¦ÝØÛ:]鯨XëcH¼-¦›h–±Þµ¬ c aµR»º†[›«Ø4ö“÷ãöFý¨?f­sÀšm§Œü%6ñ &9µMáëÍJ[m “§Auoe¦ y,ÒæÛì1IßúX‚9f¶FÎ?m-'ÂVÚΣ?Û¼`É¥ê:WÄqÓâÌLrÜ›òÜ¿"Œ18~!Áâ3 >[[3ÇC‚Í2Ü+‹_¡RXHc:jO?~­l,«¥8Ãñ<§ _˜Õ¤ñ9¾?x Æuñ˜\–biªõ°†Ôju¿yW˜ÓtèUÃBU(ÿ5´n§¤üwÖ¼}á߇Z›ßÅð»Âú׊t߇«ªh s©iöÚ^»k®¥ìÞ ¸¶ÿ„ªÏÁzo‚í¥»ÐÕ5OS“GJÃ%¶¥wñÿÀ½wÅ:¿„tßXÙx‰õû_‰­µ¯ j–7ÚN£¨ëš—‰/.ü/¤xWL{]=4Û­vm;CðÕ¦›6- ý½æ‰xú\ÚFÇo‡1ðô¾¹K "›ëÏéZ¨ú†šÖ^"ñ&«¨ÃâÛh7kÔ¡×|E  sG‡Y{‰ç2,Räkö7w×5÷€þøcFñ¯àß]ø“ÁWÞ0×ÛÃZƳ¦iøîoÞkº¯‹,uI-tK'´OÂ'áÛ ÝaôK‹[Ïìë´Ó ´ƒR¶Ó"þ|ñʦ†rŒ> _ŒŽ#7«W‚SS­—ÃE¬ÊT+áe‹UÖ7‹Äó²ÇckÑZXiIHý2¬Gq¾u›ã~¹‚§€È)Ò¥™û8ÓÁׯ™b',^#J¤°Õpx :4ªÆeW Nx¸ÔËêâŸ/î7ì¡ñö üG®Kñãׇ~jÞ7º—äñN…`º-õîŸzŧŒ…á¡ßøCGúâ¯Áÿ¿e¯꿳§‡ü,žK}Xt LtÍóÃñiw6–_ðŠG¨ 6ÎÖ;èomm¿á°¬‘êVÖzÄú„/owø+â_ø>"ßx·ÅðwŠ~ .›âKoÂÓÔ¬üMã íõ}vOë¾³â›MVKÍwOñf¥>¨gk{}JÖþKëž"Ý·‡…œ\'©™a3fe‘cøWÛ`ñ .K>øúûâO|7w’ꈚ5ÄPÙßéï§i2k—¾µ¾°Òtky¬¼4ÐEp¡ymmuCXþÞÒDWˆú·‹¶ ¸ÉÕO[ê5ñc‡Áa°µ?N¿do:'íã«?ã~·ÖtI.ü#á- HUÒt•¾€i‰â]Bëí‚ëˆ.&fºÑ –ò#©E Ì×I¦hše‹yí‹ÿôñ·ìÓw¬A¤ë·!ðƪ»iº®¨Ñ‹½^Âö·Z…ÍúÏpÖ:L÷çRG唕ÏÙo¤¶»»“SÕ­Gû<ø‡^ð,žÖ´\xwOÒÿ¶á ±K›¸t‹»;¿^Io{“qö<W:N±§Àúµµ„K«jww7—zf¨ÃXÔaý€øññ“Cø—ð:THí/ï¼7ö9ôûk}:ÞëRñN¯té¬éÚžŸ,3ÄöÇWXµ»;¶Ó%MråçñΣ4†æëOþÈÄÎŽK =Z^ʦL«G(Í0Thû:xlv W‹æÁªucTñÉûhaun”[¥AA3áéfº•°ŽÜ=J¸øN¼'QN`«R—×'Nƒ’x\E=+AB¯%'R^&_ÏL:ÝŽ‘Ø̶–3ßÛhú†±¨“§Üê0és[­5b¾Ó£»ÔSPÑžóP¼ÕaÒo,o`¸¾‹Ãðim–Ž°-ˆO«ø†ûOÐ4íVúcâKÈ­5mZ÷TmÏíÚ´F@jm3ǬúÞ«®´ÜJMý¿öM'P¼²\OËycâK Íeo쵋 Eé³j­}kw©iZŒ6Ñj6ïew6‹¨ÜÝ‹hïô‹cQ†æ- ‹Ušx?RÿdoÙšËÀþ“ãÇÓÄ:ï‰,õ“¡XÍnÆÖúÃÄ73ÂöV×vqèúåÕ¶­w¢Ý[iÍ ÚÜM¥Ú)K{kŠâ§SCÚPukK bqt§[ ±#F¹ªU%5 _WŽ)R •Ô¡ }b§5GUàt¨f˜eN4¹p~Ç0““ä¯,CQ§„¥Z(Ê2ÆòB®"oÚZÁÅÆui¨+®|#û/Á(t€~ ñ—Þ2ý¬?iÛˆÿç´ò,,8j8°ñ½eᨼ#¥yVò‹ûø/íÜÜÙjòI$«y¶Äê¶Óhº¬öÑEq©hö±é÷I¦Ë¬'Ǿ.^|Søߢé¿oƒVÒ|+ý­¤x2;›ù®Æ™¡ªÝj2Ć'– ÞLBÍ ¸IqÀ·ØÎ-õkOÒ‡zÿ‚?gŸú…ïƒ|Egiñ=ôÝKÅ6š…´ÍpͧK¤Þëv³¢M.Ÿá¶6š\ež¥¨é×w×Z2ëvsÚëwpɦýÕÁâóœê®&¶!føoì¼& S¥*ó©_ …ÃÐÄR’œ—±Ž^ð²ÂS8Â0EQ¥iTð²ÊYÆçXìrËðØš˜,—ðËãƒ?a¯ßðQ?x ßèÿ¾,x/Áÿ³ý¾µ¦\Ç«h60øê{§Ô4 &å´ùu7JøkÄ­GP‹W½NÔô¯ Àug–C¯á%×Õ¶Ôî.¬Õ–ÆØ.ëHÖi­4‰.­®ÕþÛ»éœi·k§²¼ów^i÷6z…¬úsÜiÇéZ÷Ç cÄz|^ñ5Å“YørxÞ [¸ Ÿ[¿ø‘ñÄv­â SÄ:áÓ¡ÕõÉôÂÖúUœ·’x{E62jÚré¾+ñWŠ'ÖìéW·^"ðÝìÚWö¾›­Xi–V6òjÚQjZ\kß [{[Aomv/Zàlµ³žÂ-NÛQº¹Óoæ¿}¾_b~µœÏ‡0ÐÅP— åô²õzÔñ´3l^…þÚÅJ¼åõ|>¦2¼èá!KÛ>L6‡ï+â1¸“ &]<ó–ã±èãòÜl*ʽL?±Ácò*Ôó*ô(bf”¨V›ª¨óbdÚSZØœG=Zt#SŒøAð7Ä_~,iž½»K(“Z·ÓÛRÔ.ÍÕ¤vÎMq­l…Ì÷3Ígc¦Z¾¡:iÒ]½­•ÉY¤x®àžOè7à®—ð÷àýþ¢øÊÏY— íTö×6zn—â=gÅzÐK Fàèš–¬/i5+»Ë´Õ#Óµb·u„í¨hVV¡ÿ0þx#N¿ŽãÆz]Ô÷š´°Ok{‘kÆgu¡_ l4{=> ^ËR»D÷‹o¹Ñ¥Ó5$‚ÚÆïõ-+Q·õ]‰_µ®»¥~ÌŸ³Þ•w>•§¤º_Œ§°Ôb»Ðô iÍýõåþ§«E¢éÞ·]>â;ë¾},:L–7o«>™‚®O-¯…ÄgÙ¹(ЫÇÙÅl+Ãa¸;[_Øʾ>x•Yâ+áêb©apR£ y†%§‡©ˆ©O.­g,Á<†…(QPÌsœd\hàia$±9®a:¸ªx|,prÃÉâhaiV¡:õ}‡Õ¢§*ѧõ‡ŠgÆ+msöºøùâŸüðÊGð×ÂV6>ðmýËjzœKªIs캠ˆÍowÝõÔ—:­³¥å¥°HßR±‘,ïÖÇ÷öKÿ‚A\þÒ>ø_ᯉ6ºÖ« èÚV§£x­¦mWE³¶ÓõIäÕ/ÄivIp²Ë 7V¨/EÅŽ–“^$wýÎý‚ÿàÿ³Ã…zo€í<¦>©¦i4×3XÙ^Ewâ›h£šëTñóÌÖ÷qÁâjz‹iZl©ö˜¥Ž]"ÖM3ì2ŸÙøKKð†šú6‰¦[é’Ö²Óôñ¹È¶¼ù†+[™%º6’8Žâiãž{i$O2Õ¶ûø‘‘ñÏe¹îI†ÅÒ˲ü ð¯†|_ €´¹øªÉ¬xÃǥܵŸŸ¡Ùø÷ÆÚ–±â#@¾—LÒåo x~ÿAðÙ¸´ˆÅ¡¿Ú5ºûÿI¶ß4WY?èö÷v2ZÌÆXÇ=¥ì@5”û&š'e•§ò甧ü¶ò¤dÚ†ÎT+û#Õ<‹ÈNbxßË·–±^¤ÖÍoÛÖ5‚8.áÿJF"Õ&šÎ±ÄöK˜lY­¢… ¹†mBÙ¦&Y剡ŽÞñškhn-&‚à¹T:ü~tÓI:Åìýr*iN¬©*q—$Z§J5¤é¨ªj¢n1p‚qÃ¥í¡/i[šµ;Càªãq8iKhÝ©Qj¥ªEJÒ†iìðñt½¥Þ*£‹ŒkaiÆ´*ÂGù›|<ødßSLþÊO&ƒà½^ÒÏJoéºäº†µOie&›§é1i:Ž™¥N-.ÖæG±{;ýwE°Òõº{TŽõ~½ð¿ìñÃ\øÝaà\øCDÔ"Õ4 ëÚôv7Ï£Â?â6 ‰|;©iZ–¨YxSÕí+_|$Oé×_ü-ñ0²x_Ú<—>:‹KŸIƒÄz„º•¦K©^[Ø!¶‹P{«Kg¸»¹‚Ú;›Ë©¦ë¿esT“ö¯ýµô£u²ÖÓö•ø—§ZK ðjv¶ÿ¾.ßÝÙÛëPC±¼×–6w&(¯Õ[xÙí¯ó¿éŸÀøo£Ç†¹Oä9ŽkŸg¸ÌZucŸã£ŒË(`ÕÓ«‡Žê”ëb刯˜Q­zµ¨G­A,C)ÓÿC<ñ×9ñ3â ¿2Èxk+ÁÑȱ™…ì®®UŠ¯œKG±¸ŒJÌ12£O AÒ*4c7ˆJ¬éStêPýª¶¿ð·…tO‡Ÿ³—„.ô{ÍJðׇ¼=ioD¾Ñ4 ­Šêž/×4}7LÓìnmV5SGóí®ÞÊÖåoÖ mñó¿íYûx_ðÄÝSÄ:?†5½{á·Â‹š½‘»µú§‰/<$ðËâè#‚Yî Ô´ýNm2}&ÇK±KŸû K³i¦85QôO„ÀÐ.ôåÑÂØ eŽI|•Ë/Û4ùLÒ³‡ifizóHZI%ýã³?Í^‰ûKßÜÁûü_ñD_g ñ¾¥±«5œ——±YÝZAm<8‰bKxØ,;á·\M4¯þxuâ £Å?Û8Ç.¯ãÒÎ3nâ¾Ãä8ÊØL>}ža²Œv)ÕqÅãó."Í)RÌsø>] Äðlºv“-‡>Ð&¸§Ïk5¹—IÒtûIÖH"³ùì†æY¦“øÿ‚ÔéVZ7í©ûE[Ø,èº_>*x.Æ[›ÛÛû¸|+a•Ž‚oµ ‹«ÙtëÉå’Ê®$ˆÿg·1Û*Ä?£~‰X>!ÁøÍÄm‰Çañ|7×͸W •Õ¯^yž[ Âüe­MÇ C„Ã`p|CGE`]B¬ñÔðØZT!J¦#_¸¦ðQ¹ð8ÓæÔu]J¶o hRý’C=ìws]\Ez-®-SQ¾šêóR¾Ó.ï Óc¾·´Sýµ.þ(ý–õ¨|'ãÍV3ö–•â‹Ëkdz³–xî-WTxX¼°9’<ÙZ‰`—}¼éŠx¤Œ²7ºüÓí5Ë-oÄZÂ>©¯]ëSGs¬_Ü\]j3iky.æ•æ3îg&ãžf•î žyó+ý/ÅÖ«šb¸šªTXlÚ9Na:4e*£‹© ¿ž¼)©N>ÒÕèS…¥NØŠ´½š©â¸:øj8,–…juêK–ʵ7MBJ†; Ê¥F:±ngF5£F­<=HÅEÖ¢äø5û1Çãßé^!ø‘q ¾;i÷­ëa¦·mk¦¬iZqÐõh¬âð¾>™keáí:ÂÒk]b :ÕÕ¤ºŠ?ÞµO<-ð‹àö¯öÛ¨-u4n¬£ŽçNÔlb¹»C…›5=?S‹T‚K[‡K;mN7V½×”ö¯Êk¶ð®³áBÑ%ÎûélX_¨/ØÛMÔïͨKï´*Áö¸¢”F (òѨJøöúÕµ=CCðJÞ_]J·Wz®¡r¢g‰nnììl¥µ’áa1¬Ëo,,PÈG"Æ(Š}~S•Òâ,wp¼ñ8š8<ʺxÊ”¹(ÔT0u(Õ¯:0ýõ®c/MU«R”š”!i{:¥//3œr\‹1Åáð¸xÃ+©:Ôa'í£[ŽÄû5,UÒêžÏ™FS…jNµ,=Jr£É ?’šÂëç‹£ÔµÖ±©ìãss<— /õK‹95”4qÛ̈.&šÀZF=¬‰gkæÛ1 ßløa¾1~Ò;ü+øOðûRñLj/4ÿx“ZŸDµ™ ð÷‚¼=£\ßj•õýŸØ,t¸ôn­ïRK«›ø·Dö—÷šU¨úkögýž¾øËâgÀëx|ø‹e௅Þð宫'ˆôMB?LD[Lólì´§24Œº|PK k4d‚y]®.[Þ×òO‰ßIü'ñ–pÖ'4ÏsL^mŒÈðøúôðy1Â᧌ÃVÍþ©V®+„¡íªNX5<*ĺQ¡:Ô£]â0ÿEþáð¼5›ÖÍ1Š¦ ,-,Öž [Š£[FRÃà+W¤©aéU§µñ4qÕ›OØ}[‘N§ùï꿲7‡ü]¢xn†~*Ño>+i¶ž·ñ‚5hZ2j6%ñ¶“àÄ­âOø›CÐttÿ„‹Wð÷†u[>ÇD·Ó5_j’êóÿcÝkwzZìŸû@Ü|{³ý™üeð§Ä^ ñχ.Ö_è>;‹Zðç†|7áï>þÊ?k1 ]>[6Îk]CQÑïtP÷mݦm©ÜÏokÕïø'?„¼+âícÄQx¯ÃZ‰…ŸŽ>^Y˯éÅÕÆ¡¢êÚ¾ öwš…½Åݪßê:^Ÿs{ ¼ñÃvmbŽâ9!3û‡ðV;=sâ§Çßßi: ^%Öü]âK][UÒ|=¡èjúEý柧Åsƒ§é¶Ò,0XÅ#fÜ_M¨jw&mKUÕ.ï>ÏŒ¸À>ñŸà3 ñžCœà)ÕÇçÑ£KÅ…á~ªðY†"8Ic=µIbqTªÆ1Ž*Чòöø ʼFñK†2ìn|3“ç8œÃØeÜ5q§K•ä¹¢Q¯õìzk Z¦”j,4¥Mb*Æ4ñx×_ ù#ãïÙ‹Ä_ü7âÍÇâ4þ¥.±{¦è‘ÚY]'‡EÕ­üÖW÷°Ë¦Î]†Ë]7Öö2´‡Ì‚çRº‚ÞkÍÑÙ_Ù»öS›áoÇ[?Ùßö-áÿƒþ°ø®xú jZƪ|Jø—ã¿Ÿ §Öô¾ÑuY59íN¹«Üµ•½£&§,×WWzImsQÖoí|Ÿö”ðÖƒ¬ø[öeþÒÒí.?´¾(é~Ô?wäý·A—Ä^¼“Mºæ/>¹×ui·Iº`ײâ@¢0Ÿª¦úïBÿ‚¤~Óöz\ïoâ_‚'J‹©tgñGÀ¯‚ðë“èw‚âãD¹½‚ÖÖ•-ͤlRÛEqp’ÿ(q‰¼iÄœ;ˆžaž×Ÿö®a,ö¶QT°®tªäÔð“tpµðøz˜œ4 4±˜l°ÄâkæTªC‡§Oûö„¸?‡3ü<Fã‹¥ÃùŽY,Ö¥S_‡Åã0õqRÄâ)Ö­…†2¦bq*S”áJHVùÓ?¢ß€>Ò|ö.‹áýBŽÞÊX&Ót³{=Ö›46–ÐÛE«jusªÎ,âŠxu^uÄ¿²[]SP‚åm-GÓ&(b“÷Fq<’È­+ÍäÏiÄ®ŽóNfK9Ú[‡µ]ƒÍu,WfÇÌ6âH¸¯ƒ–¶úfá½>Æප²HbD· ‹il¹¹¼›Ì¼½•¼É$’{ÉçžY¤’âIyFú2ÏM°}OD’KHey<ÝÍ2 ˆÎîB±ù»ü¥gPÌ‘lV9ÜæÏö_ÑïG„ø#–á0¸j0§Äøêج6ž8UŒþÉÊ=·°oi9Ò«Ë*ÕjN•VÄÖ¨Õu9üâ–6¶mÃVUeV8IQ£R¶"¤åûªõ¥N¥E”]ࣛ‹.*©Ó¯8XuÍÂý¦èygl k4²2(¾Ók{˜ak¨nDk0¬‰-ÃÞxåQÅŽ«#ƒ¼Q\y÷0K wҵǒ‚ ›Iü¦GYeDå&¹ä+?®[ØZ {ŒB¡D·ån#trO°ù¼“C<›NA`sµ}+NuµÓZE4÷W2 žçuÐ+o%ÚB‘¥ËKäm,hÒK,¬¦Ydvý“ûI׫)Jý²qä”çË*nN*œÜg¢ýç.Ji^ÜRªSüÊqŽ*¶ MRœªIÑU-MΪ“öž^Y)ÂMªj ª“NmJIÿÿÙE«jusªÎ,âŠxu^uÄ¿²[]SP‚åm-GÓ&(b“÷Fq<’È­+ÍäÏiÄ®ŽóNfK9Ú[‡µ]ƒÍu,WfÇÌ6âH¸¯ƒ–¶úfá½>Æප²HbD· ‹il¹¹¼›Ì¼½•¼É$’{ÉçžY¤’âIyFú2ÏM°}OD’KHey<ÝÍ2 ˆÎîB±ù»ü¥gPÌ‘lV9ÜæÏö_ÑïG„ø#–á0¸j0§Äøêج6ž8UŒþÉÊ=·°oi9Ò«Ë*ÕjN•VÄÖ¨Õu9üâ–6¶mÃVUeV8IQ£R¶"¤åûªõ¥N¥E”]ࣛ‹.*©Ó¯8XuÍÂý¦èygl k4²2(¾Ók{˜ak¨nDk0¬‰-ÃÞxåQÅŽ«#ƒ¼Q\y÷0K wҵǒ‚ ›Iü¦GYeDå&¹ä+?®[ØZ {ŒB¡D·ån#trO°ù¼“C<›NA`sµ}+NuµÓZE4÷W2 žçuÐ+o%ÚB‘¥ËKäm,hÒK,¬¦Ydvý“ûI׫)Jý²qä”çË*nN*œÜg¢ýç.Ji^ÜRªSüÊtiff-v3.4beta018/html/images/cat.gif000644 004341 000024 00000030275 05774120357 017043 0ustar00samuser000000 000000 GIF89aq’õ…¨‡’‡)eBe>hgMRgPg…{da@M=CM%HgJDh7Œ¬·Ž¡  +.>{A=y+²Â·¥§¨K’HI|GqŸGk‚Jst{mno>:M<;=RRQGLK011%142M@0H0 (}šnVgoZ^\åçëºÏÖ+,*:&CIDCjlCReJ‡l652 %&&666L9L‡Žœh=a>‚egd "",q’EþÀ‘Ð&,ÈQ‰è»ív¾£m…³Ù|+Qè‹KàmR¸òxºà°í'œ‰­G®¦«ÕVÄ&º%J3K"3B"#…†6%>57v8+$$8$‹3’!T!!84}5>?ƒ#24K%"«¦?r#6"+!%?6¥3«‰#„%$33B‡¼] ŽµÁ’42Q">4nVnkÝV$±ƒÃÇ"2%Õž2²…º"NYl$#?ºn¦W‘8>$4M|ĈÁC<ÜAÁ$nÉA `dž!HŒ;æã¤Xå€fbüá2F: ò’i‹N¦YBâÇþ V¬¸ÆŽ>ØáÂ0z ðÑá (È¢‹¯`Y@¢¬U‡Ð.¢!4FWJÀ¸""ËM -\ô@Ñ#<Œ¢À†‹.V” ã†,ZkÉ ¨]iаt…Ã1j„î°… X¹²X⬠= r`±ÍF  ;à!±ÆO‰06h \KÖÀÀÀC†çyLÈÑ 6ÞØ7pÐСE‹ #Phà°—Ãá8@à){.§Òüøbrp@§™Àd@ÀpÝÅtNÖs“À\;$ €;,A\PA. ®þrDJ³’+—¹ÈO— •b À¯‚añ 0P« *(ï¡¥'Í6?ì Œ ¸Á¸ lRC,„u#€èÐ UCéÔBÂ_9Ô*ÁÖÚ¥à‹Ñð*htÔQeš™M‹zá1.ˆJP qç>§€` à>hÁ 2X€0á)@P`^;P@I¬Nè¢6@ÅËqNr0F¡ (ñÀÂÀÿ1‚ÐP<±Z² j@ X±‚¤œ€ô€ ÀBp´ +€n„`{è@þòw‡oIJPLÄô~•b@bw‚ì¹àBÑ hàIBX@Ô¸:D øNÀp™ÞIKZ˜Œ@ Â÷¬ã>XÀë pJ>AЀp   `ÂA ƒ<¢™Ú@ 4õ à!ø°8sOÄ@r`F÷°å„@Ї|à1ðæB)|“ä ¥Æ  2ÕØOžõ“|`H£¶”A™1@çÀùùd©2¨7 MŠ°Ó_ íÄ¿u«ô©¢e'p< U`*S$´`0S¬þ§ì`”œdT§ºKB@˜)%C‚Ž3‘—âÿÚ5 €$Ô§h’b ƒ@{jÔi /vÑ¿0`:èé0A@­è … @P•`š °¢ ¬ØÊQ@lêÀn™ì¥8€\·ƒïäŠù@ ^õ€ØS!D‚Ï  …ªñÀ^ú„› @{p)\”¥7ÐÀŽz€(¹"b0“"ÄÄ Y,³¬AVt.,Y©Å v4ã"ð‰ºÐÎåÐ+¤f^"D— Á ],F È p‚xÐxwÔþu±bÄA™Ìûõ‚%”8G Hpd 漦o³ÀŽ„lWTÍð„QVàÆ}à3 A:BŒqð¢/‘…!> *Ä„ .„~A$€°lçø€4P ™Ñ ÃEð1QP”Í×%ÄFð’‘0ОõÁ)dpŽŽ°T4ˆµPÀÛê"²ÍÊWΈ— €Æ¿É@ Øré kˆK™HU&@È`ÛÑ8MS›RïJ.,‹S„ @8Òm.†æª„-œ‚Ï-Q ›üÐ74(l褚¯Üi_ÙŠœnñƒpÆ`øÅìûp@8…°A—>º.þÄ(p_ òGN@ h P œBG-xúìPX'DþªO‹–"¥Z/ˆÆ Hƃç<Ç pèÊxXNuäË¢ÑoÃÆ3. ÎiFͤ˜„5pé îs¶œ§ xQd䃑…Er$wFä/GúÀawP¦¦4yôƧˆ¦ÄÝ)(¢½(B‡°ñ"N{Á-J@ ~ î¹ëBï ¼A M@bîK 8¨RÊ* 4HÄ>G{QО}à‡›²†¾8¥/k gòY™Â9 mö!ö½ˆ–  N2¢K¹h[@* þT*g|Ê€ú%þèË+šilØôu „8E¹^r™\Ëf<0`.›ªDmX‘˜6 >ìç *T…*Œ¡é–«Ä•L  ™Ï~FÁaR„ëüË< )˜†cŽ‘æ0G&M€ä=éaÁ<ízûø¥$#‹Z<™Ó‡A¹ÀY ë\ãøA " ³í‡*ÈZˆ^Ѓ Á =<½¿¸eaકª”õ ´îœŽÈ…yŽYMP ð R^,€Ãzp¾€-ØAF6¤`A!YHDÂùD¨öÿšAqÇd1nö²0úòu4²sv0þzP¤/Ð,Õ"1"< 9&02Vs`5RG$8ü 5Р3ÄxŒ’”æá{à pìq†£#!€>œ°Up:.ÀX ’æ®æ4Ò4|M±›U‘;pYPÑ%Õø8‘Ý“) —LßNž :€Ný€ºäÉÔ à°Tp{à ÐBjÄXÊXY-ôf )Lö44 pà ñäD 7 óqþ ˜QbÙPe0ÁIS3©òÊ%GrÑm $^ñMuÔ °>éR14Yj¤p`¢T*Q3&cO_fDLÄm§p¡/0úÂW0@Šj´7 ±9e 'Á)„rKT2.N©Ð °Y°—ù¾$’”¤F¤#’p8 ŠñhÒ$—Áœ$pFò›šx Q u%9z¤ƒ#a>Y³&¦x0 à\‹ .¾à2Åq!4ã\ñm„™DaéÃ8@ š°n” ß#w  ưbgaliaA à F!·1 1F-ª'BIþqÃabˆ ^Þ0Wžˆ2ýС“ÁpÔf 6‡0&2@ 9)i¯R3Áb`FÀ K k>!Tµ`‡¡BRkŒ´ DÐ œ¶@V°B7 ¶!Ÿ X·8¹‰AÑW8°?Oº!=4` N¢Á€5€â` ÅPp `b Ô˜!¡Þ”Œðh¨Ä@š™ÆyÆ‘*eâ{aJx#P:©J¡c!µ eBàmÒ€ F@Ewè³瀨¦àç@m$’ {iŒ°õ` " ;`@¢ð$V ,`xQ3éb…T©Bþ±`Á0÷ ý  ¿0ŸÃQ(ÑGhwÀÎi}…;€=ši 9/ Px êñÙZ7ÈyÄp ÁÅÃ` ÀUdtqG$<:b:IRuàîyÑHPÀ>P’S”b±þ8J„†=@*«ªZ=fD‡ª¬µ -’.Ýqи7p5c®V XpgkFg÷h7ðw`=ÎøeéÃ#[³¡zŽôˆ61ÎAiÐM²¬Â“f0Â*+ lÐ?P†äa€1W À#%1 6`®¨ ĵE2‡°ˆôšþBaðÁ)À&ÅÖr²z1 t²nÀ3ÐòaO4¹Y7€:Ü ß*e-¡ˆØÁAÆ7¤-~³ ­R\5£>gÀÕâ/o'6[tG4ÚñQÓ³¡tÑ7|DÍÇDU7 ùu6!Ð2…a÷ §à''€kæ12§6À’Šõˆ(¤ÅÐRh"âѸÂ;!ˆ¢)ê¡-ðNa‡utXPpW~SDKà @qO,ÀƒaÞæm©²¶}8£9`(@-aç‘5°°Á‡Qp„bOð.¢,Á;1nŒ"ZÐââA¡0*²³*_ËÀ4h<nÌxÛÃPüÔWOcÀ`Ðt„@­r3È4¾ {|ÅFoNTáøGÃ>·3¾"(秆â|A¹èÃ(õB²/p @$ƒ, b7;y›hCþ,žùtià{r¬Ò6`°Ú÷>!â0(r[|'¬/`/\ŒÀda 4/Ð'ýB0Š?ä3£önaØG<”<€ð4裞8/'àª\¶¯’m«c‚5ÀùǧjоîáDœ2Ãí¨Ðcèõð7ÓÚ€Ât#²× ÞQÒ‡#eÀ1jÊr~ÐëÃwÍÐ1ƤRÊP¨— /±@xRæ²$è4NXÜ2ÀNF–Ã&ïa4ã(Ék'ì` ›¶äc"$ð <¸&Òô†yðÑ[|PSö+6~œ¤]P7 ’dgñ©4FþiáQ‰‡{ kƒ"b% èÑŽˆ²÷+0õ Ò°6:7nA³nÖŠéq(xá0c1[áÐXA'ØBà0t2rš±±†åŒå‚ §ú2hq¨ß£)Ië•"J£'Šb/çQÓ¯!(’}‚bQ|By„WÖVpðdƒH~¡nI[l,ÿ@@²šFŸ[ö{è%xæð‡0Mææ3Í,öR(¤-Û( 8Ê%(ÅŒ€[õVúh~&À~!RdeÞ¨~z}äÁ:eƒ3³ñMÂçÀajNÜ .ó7•pRp}q!’€+)Î÷þÒb"eÍ4‚5bø8µË`Œ€ÑÐÝ&Ð9 À„Ådc6å&‚ù\•UÊiE°bt#3F°°œ´1HSv@£¸Q f§‚hÔâ q 1|l& 5€ñ+–Cƨ3l’Ðcµ­­á Û‚a6W±)»û©ZqR·á wp;"ZDýe ;J@„‚‡§ ¥ú$d‘1“#ñC9â×R(`‹À¾ `‚±ßû}39F!bg4Ó$;b]°ma§ËÒ‚V'b±Ô•DÑRÂô Aâ¹aøTPš.)ôãZØAaþèè¶G3¶H›V껆– ¨?°?#öÇüCq©€$C”Ï!¼‡)€­Á"€È<̳‚Ôi‘)šH-:¦@‚F$B!ts3œ]YÀ±AäŽ:eŠµ‚0ûMì@%hNW.H,€Æ£¬|˜j4ÑQ) 0ï…_X·! P#‰%`B FøFÛ“:T&²qwsHsîÔ™±ñ>.œ‰‹Á–÷IqDÂëŒ")B‹Åf&°Œ»¨¿Æ) ÀÖ2´‹ÅXB&PV$ñÊX;ÚãÚ®íP±³Y¢ †Ëb0ÚÌCþ©¶n£|ž% ›*m;ÀŠÔÅÏó‘óX”‹…XAÅftu.…(I$”S IüÄÖv‚Õ.Aá¦é#þB(ydQË‚Väx£;DHBg·?¨ÐH&‡?ès¯±fö€Eíg>%Ë·w€zYá S°UŒåÑ€A=þò/;°ê{RL—ÕM±ôf Ä ´Q+ð…F«s”TÛ}Œ¹Z‘ü²MüJ&aíµV°”¢ä§ :KViB6DÏA’f !qþË”BQñŒ• Ф¼âÜ«¤CI¨¹”âgl!þ“?@[@@£ùh¬•Ç“ˆ´p›D¢åñùJ¸ÝV¡P`ÈnçE„…’/t»}jÏÀ·‹…jŸ mõé Z±ÎîeÇÅå#ã$à°'Gêlã.fgàãç†Æc'¦&çÃG “fÁge¥Ó£§&æçue@Á†bÀk§d¥Ïæcå&d me‡æf#Äcç­càF@c¥cüe¼0ƒP1‡Aj:DæççL„ª$šØ£“ùÆç³X—HÔ·‚•p„Ña‚ >x2%,·òL‘!V'{yjÓâO% º`) 58º:QâL þgÐÐ)¢Ðx>uÆšB–òJ€€P!‚¨QÃPˆPkÖ;>È q)äÇ)8…àÁ#ãÕŽ2Lùø!CéG§0²ÀpQa‡€§@lX±Dˆ1tî¤2C'% ±á‚@(PÁf0ï‚£× „^®J½\AA18Ö¸(¤-²!:K|¤Vl=ò6츜Y€ ,ø𢆠Ö1˜0öÚ2þàâs08ÀÃûâ¾ó†¹l½ ß(¤bMPŠ¼%L­ 7ç”!‹}8°ƒr ¸ ÈÏ<ˆá‡¼Lj8Bä0Ð@ƒþ{`„=ôð p²AlÀ©Þ²‡1V¨Å|Ð!„cPüÀ'jð „lðÁyb âÃ"GH1ÅM¤BÞš„–ÜHÃNü¤† fä @pÑ €’’C)EðÐD˜aprÓ¼be't°(ûHa›ÁK¸’H°a†DE`óÌE\´Ãl8QGg8“M+§Àá«p áª€¥ðÄÊKm0Í(ƒ²a1C‘"Å”FÙ±ƒZx1"A*hÐa…qúôP7ZQ„mô2;t`é4ô±Ã‘^ád‡D©á \ JþÒf‹lÝ !/Jõä––r9ÃJ ¡ÙÝ|uÒl?ˆGEò !EPÓÄj–ÊCå=³Äý@<á¥Odq’RÉjCôp7a}ó“Xr©W?R†—F.]†¢Î “ĆäióGlXCC84wè.]8J‡Ã!†Rc€ä]µ”BÂU›Í´ÒêRGÏÁ~Õì!b aíVІÀ>Øá£`üùToù@‡ùÈ>Ô|èpÒ3õ0S£e õh8r B "a#CÏð@¤;ÒÌJ+´b(GàWÊC%â–âþ5ÎÀa€¨=ò$U<ƒïT`‡XöDNgˆÖè6Mœ”„¬ÝœâNûn‹tl`ÛŒçãJÒ RU«ÕzQœLdtÍ!=ôÃÙ&’Í2g¸F c—úPEQ{¤[* µo5mø@AjÐQÐñËB‚K@ÌDü‘ Ìôh@f(ѤØT›*qˆl Û™èã, 8 Ä<Ã@„= Sž«T¤€4€dtð $ñ"zGh ¢IÑ'œéƒÐ…©…i'œcË 54 ZkMÔ“ÖñD jLèTÌ{Èæ¤èP%:^´з¡þ¡>U² ؉ ´ -ÐcPÐo=ß™ì3€€ d»”’ÆÔ=¡Q¡?Ç3Ú¥Â&©ÆaêRòLjСH*k'R›Ô X :@€CÚ&û¦PÀ‹Z°p‰ Ø XÀܲ ×7¢å¥H =*å€h íH“r‹ )X-Š•(J‡"›•”¢QC=²`Ià6 ,°ÄÓvÀ@ < B Р`wä%/ ° ä“-à@PÈÄ¡°¥H!x¨‡›>ÙDJÖ†àÈç–¢­~?`Šú,*òðÉ¢¯£4Dþ1N ÑGIJ=àR|ÉË$ —»Ü%2Ѓ «o?I”›¦ƒ;ÔbY!+“2JКò<8 ^0 „y%XgZŠ4:Xüã¬ùÀqr¶—R ¸Œd #b4€øe.qªðr§æ0‰Ø†‡Á€ TX¥_Pôµù¨ohÁ'0Àƒ<–<À@vT‡…qˆZþ:£?ü‚ ˜D@ù&L9 <’øˆ6€ôàè'NY }Ö€Ÿ¿Ä j“¯b¬Pn[Æ*AЂ#åI#X Zœ@Ÿ6–`zŽtàŸTÆ°#!ÃFþ&š 2ÈòM#@Ʋ+h9¨›€š²·¶UŠxzË"Æ-¥(Õ®ìcõÍbµ’“Jp ¸4GŸ•¸„ˆz÷{à„Cÿ ÔÿJ2< £µ²•é ^Š²6­….Y`ƒ„ðR= €ŒQ`ܶ#¡R šQ J’¢{¬œ%BÜҮʙƒ—lˆ ”äÍ:CŽÂQ„À"Ÿ>å€L3àN/ûóÉó€K^p]F¶ G=`Œ¡[Ö61l[à!RL¨:˜¤ÈÌäµµñæÈné  ð  ˜ÀÃX䓵2Ýò“=á/s@€þ`m@%­pØ‘Òø´kTyÀdà/¼UîKo‰‚ y€)Õ*7–3À‚X“œa˜ÃÍ@˜‚ÎÀ°gÝç4@ª¶4`@E]KM¯À¾vÍ’uï¨G[zãÉukBp‚¸€ë€Ñæ¼Á9s`!0Š7,í† D*S‰È¢DjÍhèc|ÊÞ©P[/;|—FA>õÈ`ÌlØþÈuq¨Ÿ5!6ØÀ ˆ8!¯©F^D7´@‘aùsŠ°Î:oó‡Í9ž3€/Ѐ«óIS¨9!`—³¤Shšµð@j1¤#iš-”]`Ä#äÚ $'ˆ¸l^Z‹ @€Y@0aѵvÀ-/5íê¨ýëF;xìc ¡;~¹–ç¡yèN eÉÊ/šv•)›¶h@Ya‹„š…°×2(b2›Ù<‚ Ò­–5rˆ}fpxpüSNŠ‚¡‰†¬( <à?oÙ.¾aßûŒ{pŽ½»Ùàœ“EI*…#J㤠þKè£>bÁjàEvà/@`ÌÀF¨èf!ŽÐ¥LÆo’~ Р‡+€ü‰< N¶ìÐ$Ë ζôŽþ©º\-âCÄ™ékJ@9xàÔºPZ@'ðϾÚ/âfàé¨ ÂÎá±l «+œŠ¦N`ì–¸ç" » €Ì/jdj! èZÀ!ÛÆ>>&tê {jÃ¦Ë øŒ`6pkwIál)Kv¨ €âü‰‘À®Œ€(‹àÜ/Á>2Ä"ËÁPÀ¾ @ÀÅ Öõ"jÀ„†€G4dÈÐâlÞâqÜ–̼n•MÓ„ày«fžÌ—.àorétD8`8.à ֢і$!Ÿþ¯¨÷øͱþÞ‘: X€F< B&bBÀ€LFQV N ÃîvĦ v® ˆ²v$)à‹.NG诨C0bX‹‡ŽäzêË°îɲ¤–²„BŠÞQ]0uàS„€F®`"àåk¤CM€Ä긨RdÀj Œ>DàJxÀÚdÁ =mBZ‹$ÇCH0D` ¼Qz€‡²­fìèþ njËŒ3"è꣆@Ž¾ 8à&¢/LÖ„\Ì…lz ˜±±NŒ²Ò ±ì­²2„q óŽa¾MÕ,“òø<Á€Z@—–Í8Q ºÌþ§PÀêÎÀP˜þ¨dRJÖ„‰%Ã| ¦©ÔO9Ì-"NjiäPÓv‰µ¤Š~¤Q.&JËÌ€úç Æ  ò(írÏ–€ÎP9 ¦ xä#@І@ –ƒZ‚‚  IR†Œ6v¢ÎPdðÊ   Î*1d<íÉzGjãÎÏÁ§Ì1F `€xJÄ$ XÀæØ4깜2#–aBB¡/Ch„†‚(e‘èaÖXëðºªjñBdÊ Ž€ü)ñÏ0$+Ürà ËëŸjËÀaØ ¡àˆÃ½ Ø”‡(²ºLvâþî§øÔYv’ÔQÒ¼r'¼ XeðŸdëZ±"ìJ$Í&Ö!’#ÁœJ  bJ®4ôÐ Ñ S¶lÆÍGYõ9’ˆ€sˆ1gUÒu†"¥Mf!‘l±Lr@ðÆAð*$wäÙØ1f¡ë&@“9úx®/UëOýbªP€L 2 Z€§vÀÛ¶`É2 ç#ð y¢¥{Ðe]gHLD`Ží9jQËÐClПpî¸ÎàüI¦0 ÓZÑ–¸ÎÕ¶5€. [‡håêܯ’ÖGÙÔ#û­Áž#`AJȨ †qþ8„dgd¦jÀÁ ´þ¦JJWUj_1„¦œ  *ÄÛÂô–È1Ú  €x€ˆöðöˆÖ,€T @;†zŠ§Þ‘c9vx€—PO)V`-Á“ÏÐMcÎÍÔ±B¨ªÕrCôÎ ‰ñdè& %Æ TaËLàa]÷oùö`o/à(ÖµPà;zêv àž£ç~ɤÀšøLZ@„:D:xñußsíª¶âÏö„`þÉ/pë!‘ n€¦¦U]÷ÐþÖn7ô–|)@@èÐö®ç–Œº$axF©†rÆð‹´tm+þ_ƒƒÄ"¹W)„ ¤`mBÆ÷ac €h{ |àpeŒë–* Ì÷n# o«¡Nàa“m`Î`)¥{:p™”D'Φ¯ò¥†UµC*{b\)σ¨H1R„ZDàð6 wOÍ b{J€èéJ•·Ì ÁtwØN < ®â* +Ì@NB«Y¤Å™$É-–§à"ªåÐà\ÙúƒÌ :aM+BÜ†ä¤ nئJayNZ7:ø €{ êÏý ƒÿ­z*Œ)ª€l†ŽfMfÀ&ÉÂ>z"YvèB‚—8þ'—ŒÀ\ÐÚ~vfù¦HMFàl ÀL33<ê6O Š}+H—OÍ €pôµþ-‘3¹ £v¢În-{ ®+¶ „á.c fÚ.2¼\ ÂÁž#’hÏÖ9ÌݼjËâ V’³0‚¾Z×d<»- (à,€¿¯,@–ÀD;F;Ç#ÀÀ¹ ,@­7#j‚£‚#0‚]JÃ)ÀèbŠCQКƒÑœÃëì^6dƒ_ÒK€0`‰-›Í-[àÍ%Àºgœ«Ûº³S㾘 · "`6¦`)Zm¬†>^¡0Î{CB`h{’«9™ç °!Yœé"¤ƒ(vÔkkÆVx—¬¡úÆþÀ7hÊÞÍK"*n bNbUòùbHÅEqA ƒA" VµÏêG h7ÚæVh>±ó-Ú€nçureNÃ)÷Âäp| ­hpT(´¬Ü0®Ý„àp @Öø|€¬€|l~ÔàÄèø¬,ÔÔxxœ.ùü|$ЀDUì@ÀDA(€àx(Å„ü,Ž…ÝdÖ„´í„œ |ÔÀil¼¼ `œœ`n÷¹øÔì”Ñ lh€ ¸ÞÄ} „€½m ÔÜx$!ù úìÔĬ A•Ž c,`DÀŽ/ì åaSŒ®p$!ÁèŽËDÛq „†)7v@çË.²åÁ&3‡©}þ/4È(ñ#†ƒè4áh³"Ó+p¬ˆ#èN¤_|„ ñáž@;F…P€/ÆŒh´ &Õ#°2|€-넽ΈÛaGFâ‚°s¢¥ŸÚ´åh…ïG«g”˜Q°Œ%<)±aƒÒàp °#C¬ðÐB‚ ìè±£XhW ‘ÑZ a°ŽÈˆ<ŠÆf;€p1dÃ((  ÞQà¡¿'xùáàˆƒéÏð‘Ý°ƒÎû¶¡sq +tDX°A„;Xpz–KÀFKãaþ„ eÄ` ’„@2láF M¸C0P€Ü{ÉÔ þà àÐÙ>,&kä=àábÓ  € Cp€@-D€Zµ\@A D¡P@‚ ¹ÆmfQɼ Ã(:ù [€ p .4XË{(dš à&”à€ Õ9àƒ MšiÃu>”¹O@ €.pÐA)ðj¤#éý™Ž³TPA2Ä U“µrݱ&¤´ñLJÁ(0g.T §¸0gLðC 0Ðy>V¦ ÅÐAž£¡8—žqxiJ¸´ ×6évæÄoÑjŽ B3Ó<3 …9fÐÛB8œ`€$°(–Ý`icMÆ´@e²v‰:(Ðôª³™ÚR[–@Öʹу¢¡p‚1ØúHq¸'@0(` L ¤ ‚ }K0A´ìpCñ,à $A¾l ƒ‹É@‚Rø C†8¸â ¯Ðò^ Br(ý•;¢°£{(läT/|àÁ¦\;  € Cp€@-D€Zµ\@A D¡P@‚ ¹ÆmfQɼ Ã(:ù [€ p .4XË{(dš à&”à€ Õ9àƒ MšiÃu>”¹O@ €.pÐA)ðj¤#éý™Ž³TPA2Ä U“µrݱ&¤´ñLJÁ(0g.T §¸0gLðC 0Ðy>V¦ ÅÐAž£¡8—žqxiJ¸´ tiff-v3.4beta018/html/images/cover.jpg000644 004341 000024 00000047335 05774153511 017430 0ustar00samuser000000 000000 ÿØÿàJFIFÿÛCÿÛCÿÀ““"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ÿ?ú(¢€ )G$SVD “™0\œ…ˆ$dŒ#'Ó4w}•ß¢i~my&Õú+þsù,[ü7Þ)$Ï– !`ÕŽóïÆz óZún£{qä[ZÜ]NêY`¶O2fUŠI„HYÊÇ2<„ ±¢åöäW·üýž¾ üp¶ñßü+Ë85KÀþ·ñ5î„K.««XBÚÂx4X 2^^[¥Ø»û(užXáa<¨ýuý?f«|[ð¿í «K¢ÚGáe×,õ¯&Œ× 6½«xYm48t½.hmVKù/.5H®´û»8m®%²0ÛI-ìóZZ÷æ~;áÿñõt«àøN¶S†Ä`ã,f&¾wVx|¶hÂ3¯UWÄÂTœ©Sš¢—5gÓ~MlÍâ1¸Ì‹‡©G?âŒ>_‰ÆQáœ5h,f'‡…:Š”œç T¨Ö£5*õ)ÅÂR’mS©ÉøGi£ê—±\½¥Äéi º¸1!a¸™ai®1“ +;¤>t›#32øÈʦŒ–×NJª»íÜøEÈÁ.:ç;Iàž5ým~̲GÂüMøßñCCðþ‰~%xBQøYâßìØ,ô«]SP½·ñµ¢¤é'ü"ž"[Ÿ”Ž‚}îûÈ?h´³Ó¯n~}Ñÿà–~ø}ñ__Ðu]I¼Eû>þÑ/á‹âŠÎÿÄtÍOû:ItÝlC%å­·Œ¼âÍKD…õ=í¼KáÝþH4Ø4Ÿ_éÖ’xgâ÷ø›ÇxîÂfø|›ƒÊc™ÇšÖ§C ‹¯,Lv;§WÙþû R‡±«š÷½·3¥NRXæYÒá?qžø‹„¯áÿQáÜ¿‰(`óºô]Iàñ:¸Œn õZµéãjàñ1„f°u+ÚŸ5h§Nšþh —£ œåíÀ\ƒ´ðÃz§ ¸ìÆìPòIõ5ûoð§þ ñGÄ?¿h€_üÏ|Að·‡5Åø9{{,vñߊ ±“Äž¹[»<Äzœº[1”¦«j“ÚxŽ}*ëAÔ’ßòËCøñCÄzïÄ ižןÄ 4Ïêþ9ЧÓn,õ¯ÚøVçìÞ!MSJºXïl¯t©su§Ï_*Ùß·i,îR/Øç’æŠt"ðrŒ1_X–q§(a±ðѽJ”qrK ˆºŒ¹U*Ó—4%U/tœðöc‰Æa2üï˜ÕÀÑÂb±3ÃUö”a†ÇÎpÂVX…z5!VtêFN%짜­4¼RŠÒkˆ¤gr¹e(£i ¬Øćrä°B¹2a®éUj¶J‡,@C¸S¹²HÀÜUŠà•V;µ·*rºNñM­R{¥dÕõOTîž©žûŒ’Rå•š‹^ëºMZéÛtÒqwNÌ©EPHQEQEQEQEUøP¶ÐHÉ,O=•xÆ}OõªmÙ“€@ëŽà¯'Æ”¡?8¯[s-†“wJÞòk^ŽÎW·]#(ÿÛ×écú ÿ‚oé~ ðgÁ/xãMÑíÇ?üQñÀ>%Ô‹Þ n4M5®µ½ù1HaÙêš|Vêmá‚ItûÛÖ¸išÎÈÛýßðµüñ[S–öÂxŸTX4éµIíÅÜfk­RŽ;˜5$”Mmq¤ê|fTØó ‡ Ín!?ÿaŒÚþÇ~׶ڭç„üsâ=SF–ã¢Ô¤Ö%°ºh˜HŽ˜°¿’ùJJ÷QFÌŸX𵎳ðÞ|oá-@ÙëLj¼E©!‰­¢–Û„¾¹ÒµkpZÉ”hÛZ%µÅÂ5ÄJ·D„W÷'‡<ñ?Õ£©†ËxŠ¦ .– –:4ëೌÓ(ÄÏ1§ ÔéFœhЭNP­5UJ£”9SGóneÂ&â|,ñ³xS-ÌóêùÿˆÜQÀ˜|Ã.¥ŒÅg<,¥FQÂcrêt©Ök†ÁÔ©‡¨éJ’ufÜ;?¥¼}eâ|o°Ô|q/ˆ£ƒJ–É>Ûmq£ê+®ÜM£Oeo¦Ý¬:uýÄÈ×&ëÃw#f§æÜÍL&ž9¾‹ðÇ›ûŠ—ßüg'…ï¼­ê6‘ø;SÓ$IO†>/iú]¤ƒûCT’ÞÖkiµ½CU´Ð/mµ+ M;HÓït[Izv¡{%÷œø;â߇.üAaxt8¯|pöþ!…íí.tˆ®4Ÿ Øx²}*MBInä‚÷Ì–îî¬<3k.¥¨Ckwu©%¬qÏ%Ì_4ëš·‚¼%ñ{âÌÞ𯉼8ž.Õ´ƒ©½¿öeÖÏácPƒXñV“e,gM³Ôìu›ŸµK4·wpKk=ů‡à¶ºÖ·þñ«èOGÄèqop–M›eþ$â²Ì pœ–`0ø,qœcs¸eœ2¬EF yZÃAÖ¯ˆZn§4y%5/ºð_é•xG ôqúOø[Ãì˃|)Ì2úKq<«Qã.À¼%åxÌV6Œ±xʵ(æ òÙb©:¸ÙÓ­JR”`á?Ø/i+ñ_IJ÷Å‹m^-;ÄÔõï†~63ÞA£3Å a©é¾Ô,L™ä·Ôuk[Iõ ÍBK›Q êž!žÝZÓJºší mfÓT·µ]Õ4‚|_áY_Ébg†hîêõå8Ö«/7Ëøkè÷˜pæGô†âÎÇøOÅü!R·…ßHß °XŒ®´°Y¦–;/ãl«Ùc+å¹–Y˜ÖÊ¥ŠžaO „Ž' ‹Š«uêòÿ;ßÿà…šU‡íûLŸ®Œ>ÇoâÏüðæ³y¨_ë:*üLðf±=‡Šµy^ÊÖâ+ß…¶×·z/†µ­CKžÏPñÏ…¯u{LðÒZø~ÃXþy4?ØÏöŠñ·¾,|>øðŸÅ^6Ö~j>!Ó¼x¾Òn¦Óô)¼1u¨[OÅäÑÁÞêCK¾ŸFÑ̯êÖÐ\Ée¦N-nî-?Ñ¿VðÖ¥áo xát[-&Õ¾øóáý…Æ&¹Ðîôé4»{~+_H“×Ú^¹…ï5ßÜÜYé÷:eÞœ·ß^6'Á¾;ø=ª?Áx^ßJðçí âOi¿~ i–z4~ðfµañó^²ñw‹ü{§hÖ2i^/ÖWRÀþ7Ó.µË+Ë÷ÖôÍ3Ákz~‰wâKÍ?ú“3á,ãˆ8Ç>åø?¸z”q”q52ì~Ä9~sC-«ú†y—á±0¥–áÞ2†#/ž"¼¨ÏR•ªP­4Ôÿ¦<$à>1ño!Íxÿ‡é,Ó†çœO)ËåÃõ)ãð¿Ø˜¬»šegR4jÖX|oC ˆÃb}jñ­õNXTÃVœÿÌ •²ß+pNx[Í|\ðÇnü)â×Ò'Û|Yákkû? ZÁ=¼1Þ구ÑÇÊÉki{,Oa‰ÅaðT*bqu=–’^Ö¥œ¹¤ ¥hÝ»JK£ô4¥Ju¦¡œ÷½­¹IÝvI¿–º\ø`iLJ€Òop¥Ë‚q,…Á0ûxpßwý1ðkö4ý¡h=>âïী/¾#Ëe ³ßh¾Ô4;¯[GíÒÂ3&­»< åŸ*km:e¹Ü}íFÒåbþ¿cŸø&Ï>xWƺü_´ÃïxÀ~3½ðŠt?üð§ˆt§¿¿Ã Õ¼IðÇÆ:gŽ¼fº—…­<;¬x{Äñx»H½þÌÖtí^×HÕü%~u‹V³ý ð/‰¿eÿ€^ðÞŸñáúüø¹o¦h:{|Bø#}àí@Ä~*¾ÒãмGeñ?áÍï†<7d`šòêñ4=~ÃEÔ¿áðÞ»w©ü<ñöŸ GÄ? âçç|Àpâ Àḋ‰·±ùfi‘קŠ• -Ë2Ü6sÎqO–#ƒÂౘZ… ¼l–.œ¨RªáQ/3Åü'ÁœAÄÙWa³\_“ðÞYšåÙŽS_ ˜ÖÆc³¨c£€Ë±t¨Ç—+ÆBxJ•1ÄƤe‚~ÒŸ,éÍŸˆ_²Áoˆ ?gmGá_ÆO…Ÿ~üOÒõ}kÄiሞñ'ÃÏY[j:¤‘økR:Šôh¶[kðM …êYÜoK+¶£F‚y:ÈZÆX5Ë}IÒÂæ1âm/ìöövòÛØé¿ÙÚf·£êPï{+ñgö­ïûXOl·+z‰}=¥Ú\c÷Þoø'W‹~1·Ç/Ú3Å?µuïÄj>ðܺw†4í¿Œü.ÒµôQy}©øµ!Úì·Ú&µð΋ igS¸Ô/ôhlHôËoÆ­Cᾧðïâï…4_Š~°ñ,^)Ó|eq§ê«©j«à=VÓÄpiÑ\[è¾!ðž«¥M¨ëºdùZæ—~ãO𦳭¦¿i5ûi‘]~wàŸÓ£‡³Þ2ÁfÙ{W5§Áœ ŽÿˆµÃ™>‚ú†k‚Â×Äaå‘áø¯„­‰öQT]YaV½F§F½?vQ_QàF?5àOx¿Æ:\uMð®kãfEÇù “3–>…*¾]‡Îøvµ ψ£ŽÂUÆʬ+Ñ©*pÍEÆ´§9x¿Ã»Ý7Á~'µñÆ—¥é—÷wºU†‘ª€%y‘y{f?´.dY]cÕL6Ö·º…¤Ñ\8gw¹/Õ_|5 ÿÂ#¯ZØ_ÞXj%Õô+Y´!}}ª=¼~"ŽÛÈ×4 .òçí:]Ͷ³x±Ë§é—6¶“궖"­¬³C‚x¿ÃŸ l|[âë >ï[ðlZ$v×:m̳[ø³H‘4Æ{[]/YÓ-­c‘'µšÈø“T–ö8TéNd‘ÌZ/Ž|s 6'ív_†‹Û4étûå¹×à³²-0’`mí¼@’Cžâ um>O°ËÉs{m+"'úM×Ì>ü)Àž'øCÆ8ü¶~7äÃãñxLϘeU*cpIS¡ÏÍCŒj–6Œiò×£Rª—¾£8ÿZxôuàxãã_„\1Ãø¼ö‡c8[øO†ÂaŸe™¾Q—æü5ŠTq4§—a±X*Uq2ÀU†Ÿ³¯QÔ•Ûmkü2øG¨ü?×¼ii xjçGÿ„N×Ioióø†]CÅfÎþÍ~Ówiá­'SÒ5{H¯5kk™¯.t•Õÿ²­áÖ´­2Þ3]¾m;÷ÿö8Õ«$Z\º­þ¥r¾_;Á>4мYá­wÄ:µÛÛÛj¾ñí­ÊÙOªÜj1ê:f·§“§éz¥„qþ<üqñD:¿xºÂÎÿSøºŽ›t5& »_Mðê[ ÏkV²ºª\x§Mitøô9­l­5Ûh5§žÂ+›ù^+¿¡ÿdÏ^ñ‚,5O üJµ‚ÊÃVŒø»@»K3áïx^û–ÚWˆ,Šê†W·ñ—…|k¨j:Kš}Í–µ¡A«K&¾Ö×Çü7ã ç?Jß ñøî&Ë8k ãž >Ê)p§‰9®[ŸÑâ Ox…¯‡Ìøw RÅJ¦:Žy‡Âa«pÖC'­Õ«…Ž5èâ+×þ.â\Ng•ä™¯ çõ8£þ Ïáø‹„xû€pXNÍðÜ'…ã¬Ë.–‹ò÷™{++Õ›T°½¹Ha¿{ ÛC.Œomn­õqwVß|Døwâï]ê¾:ƒF·Ò5/ x¸Is¤Ç$6w¶7[j:'ˆ-"»aq§}‰õÒuk&ÞÒäÅ¡ø–Õní5k½FÏïO†þ5Ð>&x:-wÃXk—PÛé÷~¿‡V–K|-ÓtÝ*ÏûN}3ÄQéþ'²] VƒRð«_Áe¨³êÚÝÝÅÄ^[‹ŒøBÿǺuŸ†íî´ÿjx^÷ÃÐ^i·šu…êqM©é:-ßöÍ%µœ <7TVí®´¥µÔl¬®­ÿ-ýŸ¿I:^ñ¾mŒâì›ãx›6§xûƒÄç*5)qnT¡OŠ?Õiâq2£ÃøêU%„̽¼ªÎ9ƒÄb”a=ZoðŒuô4úDðßÑ·‰xç)áß2ìu,×üھC,~KÄ^fÕêS£‘ñGà),»8Åf9n"¦"†/–מ[ŸáãUG*”?)$ðgƒµHtÿ‹·^Ôµˆ¿²±´øðÔÞÝ\Ýéþ2🅵+ý_Å~ñT ë5ýð›ÄWúÅ™G“PÔΕcàÿ2-&ëR7ÇWí_û9|}ººø‡û[kŸ/¾üø™ñOź÷‡u+!ü%£Mãokz—„t•žñõ›{M ¾Ó¢ÙÅ©ZCp?²æIMäsú¿ÂŸ‰ßµQqkck«èz߆®¬dÖo%»Òlg¸ÕíŠëTE"òH‹]Qµ€ÎÈ,ê2=½ŸÆ¿¶‡ì¯þÞbøgàOiŸl|oñNñ×Ä{K-"ÿâF‚ºÆ…aªAŒ5½2y-uŸ¥ñ»Yg²ð5ÅÛkºåþ£­ëÚ=þ«¨I¿Øï¤QÁ^&ð‚ñ3ÃœFIÆpÂ`p˜Ì«<ÊsúØú˜^ÃB¶'5É°>–.vÄf5ªã°ôha#)ãÛ¦åNä×ú¿ô›àNâŒïâ7†yþI_…xŠ8e,›$嫘c8„›ž'2ÂË÷ù|±u\i§ˆ’W—,(Sº’þ Ì$)?7Ž3ïœøÔŽ=+ô/öÂý‡¿á‘ïmìõ?Úà_Å»½GÅÚχÃ_ µ/?Ž´ôHZKKÆñG‚<7§øv&ym­^ÁõýGPþГìÖÉs¶¡qmùêAÉÆN ÷¯àìN¾££‰Áã0U ©óañø,V]‚©B–"+‚ÆFèÕP­ÞMYò£øb¤*R«V…j5¨WÃT–F¬mìqTÛUh§»ö~íïv›Ý‰E.꤮bŠ( Oø}uà=/Æ÷įø‹Äž†ç~¯¤xkÄžÖ5HuŒA¬ßxsÅöñ‰ü·¹ ¥O<ÖÑÜ[ÛËeq,WÖÿÒ×ì}¦Á.ü} [xàOŒ|)ñJÊ5];WñŽ‡ñⷆƢÄû4¾‹ø sðËľ0|7ømãO xcO“á¿€>'ý«áO‹¾x_\ð×Ä8ÿ¶¡Ö|!©øgGÐWá猵 { xR’}[Á:Ž¹áÿ½Î™ue¦éçLù3þ Ià¯ÚëÀ¿²Gƒ|;¦øÁó|-Ñc’ëÆ~+øy³ÂÏ{à­5 Üöž&øs©¦¡¤Z[ Ëi©øWÇsêÛš¤ºç„?±áŒ&UK žû1exnâ LjÕ·%ÅûL=ia¸‰ÆV† _뫃©O‡ty«É|Kÿ³ÿ‚­ÁðÆÞðÆ¿Ü„þßD±ñ„°ßêzÇ„ü1 –ÒM\Òá[›ÿh1[¬#O–ÂÛQÖtç+ ªé÷ÆÒ?¯¾=þÍ¿~9þÖ'ã†ô3Âß|)6§{ðçÂwzͼ¿5ŸèÖðkú­–œ.“LÑã–Î]:Îðx’m2]VûÃK>Ÿ,ÖKÖõ?åáoŒu¿†_¬×À…mRÓúÃý‡¿à¥ß ?i 2×áoÅ‹í#Àÿï"–ÓÃéqu5žƒãJСµþÃÔïV;}Z¸gKe¨Ýˆg¹„ÿgÝM$ËcmþWqÑ#€8Äø¯ W‘qFiáŽi—e\IVÿÕêùŒe+Ç0Ë02­*usl-°¯0¥‰¢šN•)ÆnËÿHß¼dú>ðv?þŒÞáónñŠò¾'ñSˆ­Åç8jT1j¥\ d•ùp¸ãéÿ·æ†r¯õú‘­Q¦§oÊÏ‹—úOÃ?Ú¼ø ãW€¼Ss¤x’þK/xL_ÏáèÃRÒìì4«ýãVÓn¡ ·0éw g{§êúž¨ntýJ½²è|qðãö^µXæð·Å¯ˆ¾¢ÔÖ(|à›o"ÝéIi%•ƒëžóVVêQ5´ëá‹Â¡æîX’ÒK«Odÿ‚¢iþ.ý£?ࣟ ¼;ð§Âº¿Ä?|ý™¾ØüL¿ðõŒ—l?üaâËrs6ãȱÒüuáÝW—’ÀGhCÅ|UñŸÄš_Ã[O\øËÂóx…/|q¬i^"ð³ë×Æ‚š+AâY´»Óm-ö«Ú@ 9ïl¦Óüùà[ëGI¢x>ãèÓâ×xeÂ^Ç‹ÄäØæ¾qã#õì¢xa§ŒÄÔÁs/íÆœ>³Zô°ò”•8Ækšm?ïÎú\ñ^QãÏe9>y–e)›xM”çÜoÁÕð¸ Ë™d¹-*Tñ¹…<JøÏíZ6'?eN§·\ñ¦¦¤pÒ|GñOŸGÔ¼/ñsáßÅc¥Kæ“áïëבê³FÏm¨\Z<ºî¥£x‚Æ7‘>Å{-—ˆ,µŽ%·´¼³dó¥¼ ñ_Å>Ö4øWSø™­·ty4=JºðD>3_øBK}?Fño‡¡uÔ¢Ö’ÛZº–âÒÛÄ%Р¶›Q‚ûQÖmlY»›Ï„_ðN¯xKø‹àÚ7QÑ­o¡µµŸÂ^+¸²Óüge®]yS¾—©XÚéúŒð)kËHõ5 +»‹C25½„“Ïaã’è_²¦™çOáß>6·Ö£¾Ñ5] çKþÕ{›MwB×ôßéím.Ÿáµ›Kû­([ê ¥Ýi×–ÐÎÚ¥Ö¥sa•þ¨O…ü>ñ«„ñgÀu°ü?šeSÅË'Ì0Ø•ÃÊyö0£[ˆÄeÙöö… uêF«j1…l?·Ã)Jä£þ†ñ^SáoÒkÃœï‹ü:þÆö™~S™PâaW&«›B¾ ÓÄà'G4ŽUˆFæ±XgZ £¡(Â5¤”Wê§ìgûUh>ƒD𯎣u=ž·áB=}V;Éa1Gáý+Ä«mge}ykû âkûÙÆêÚ-YtxÏ㎑¤ØùqÚïmuí#ýU¾’e•Ø_ƒH?¡O‰Þ1xÓâyÂu©ðîe^ù—WΰØ\¿#«ÄxÇ×Ãð¶c—Z8¬<±^Ö²ö5p~ÎGSÊ¥ígþ8ý)0f~ø;•ñ߉xϸvXžyîœO7Åp·T«ˆÁeù†+ì°˜)á1xl,ò¥ŒÃV«R½féʧ¿'ý è>4ðçÁ(nu_ˆ^>ðæ‘ ¬Is¬Zdz'ˆn.æ·¸…¤²±Ñ§‹Q¼œJ­5µÑÒ¥½hbép]Û1’¾7ñ/ƒü/ñ·R×¾&Ãà1ðúHîl­tÉü[¡ø~ÿHñ¾‰{ÇTž÷÷:&±7‰´ýZÜ[Ú_i^lÚ®äÅ–¯4êÖ+øcÆÚç†üKk¦üvø¾ñ9Œêë¨x?óüXׯ'ŠëK·}BçÀZ>«¯kz'„mo¯­o5Ms]ñ±¦JòOo<¶z¢Ø¥×ÝÚ]¯Ä›¯ Ùø“áî§ê^ñF‹8¾¹øtÚ™qþ/4Yµ[ŸêWçÐ&Ó%¶¾ˆÜß.¡{k¨¢:=ÜRËq‡Ø}p¸¼Ï/£ãî+Äž œ2Z^-çY½)øCÃÔ0êÌ2쳆ð³Í2Ó¨äñüή.¼°ò—±•ÊH~ñÃþ%åœ-á%~ ð+Çx±Æ8¬‹ W5©â¾Æf9VEüV]C Õø‚‡â1MSöË šáêb"¡ËF4q œ—óûqÁ)?g ˆ‘üZý þ&x_àßÂë½.Þâ; k‹¡üAµŠ×IºKo ø;N·Ó¼]á˽ êÁu†ÝðŸ]ñ6¯‹f|P·sG©Åü¨þÕ ýœü ã[öwñ/ÄßhQÝê)9øiᕽ²³†äC¥Ëý« Id/ï/c†îæd—Ú4péÓéM°ÝIs ×ÏÅm.ãGñv©©·ìŸáŠ¿&ñL²X|Rø³û\øWâçŠüC¥hó%ý¦®Ÿþ"Gþ™s ˜Óímôý+GÙ¢ØiŸØV×övÖ1[Eù™ûD|-ð÷Š¼sâ[Ç_°_ÁM2öÇ÷šÅÌŸôwD³´‹ìcíÚŽ½Á/èZ_XIÖ·ý«¨é–¥»i`Õ¥6v‰þÎeÙu/¤dž*eüCÇUÉ*b³|wUαXlÏÙΤÞ?5•xü<±Uã'Tž!N* £á”#ø· qÆyñÃp¿ˆÓž>ÆÖ_X¡‹Êjeµøv¬êÒQÃã­W&±2ÅQ§*’«8Qteí*Æí/ædu ÍÆìàg==›ii€ÀôaUëØþ0ŸÞxßV¼1sá ظ³·Òf»ÖõIíÕ"šà?ˆ.¯u[xn¤Wž+[ë©f‚,n`Q|ˆÆ¡±¿ ž¸õ]ÀóŽcŽœô9¯Áë®Z•²pœ©ÊÕ%Q¹A¸JOF¢rk›–p‹Švµ•ÏÚà®­x]T•/v¤$®¤Ò•ã&¹f­8Îü²‹ºm2)OCIY ¸’:»Hx`ÙÜ*q‘Ïg¯_ÓŸnøñ.m0%†¼òÜEºÐYj÷Nnä° {kgŽT™ÞÉ!Š(Ö0V8’0 2ž<'ÔóÖ¥Fù['œƒŸLwõü½ë¦†&­?ehûJU0õ:JxjpIY´Óvog­´Ó¯‰ž G ^R•*sw£&á(J¡ÿ/)ÔŒ¥Er;;¦¤”—èæ™ãV.çÂÚ†¯¢]^[yBïC¹¸€Ë+ÂÖîR}5¢¾Õ}ÖBneŠâf]F;sw ú—íaûLxWÃï…ì¾7øÖO x·Ã3|?Ô´ÛÍZMcì^»¾MKTÒ<=y­Ãª^xtÍtoªm:}KN¹¾Ó/g›O¿¼·›ó{Áþ>ŸFŒiº‹Éq¥¶æDTGšÚBK+Û™0«1-"g–bqÎOÒ^Öô}{P›JÒî¦hN“mª¼_d’E†ý¤žÖú D–Ñ!ím¬/ñÙf%ÆAmè¿©ðçbå4«`3<~ƒ¤°xü%J'fÿÎlOg^x·™xÓÃÒÁÒP–[Æ9Oå4jf¿Ø5©ÎxðÆ5Juh©ûwJžœçNa ór¯Í­!î´}R»[R/‹¥ºÉ$oÓ\^AqzðÊcŽÊYo lw7Ò{;;BX§}:éL¿«°Ç†?cÚ Bðž‹sŸ |{-iemáŠzÇ•á/YA ·Ç„õmFþÃÁs]X9æðŸŠl,µ{ǹ·>¼ñUÛÅmôñ·öFø_ûF| ¿ø3-÷‚­uöøu?…¼ªkšm…‹xcZӬ廤ë«áûؼ=cý®bÔ5­/N…㺴k•‡ì×’=ÃÞ🈬'ðíàðyöYžä[Éê`1¸ZßPÄJ†>†:ÑÆSöU%Fxw)Î’u%ÍGýúý'ñRàü¯6༟—â2LÆ¿öß瘬“?Ág¸ÚØìU-z˜Ü7´­+ú1£‡ÙøÜ=Zõ¨âp÷¥Jrþ¦þ"üIý—cý"÷à—ÄOxzËÆ7úׇ.ŸáßÂé‡â¬:¦© wZ¥¦Åcuk¤è7WwšVq­è×:þ“ Ö’Ëw§h‰~³éÚߢiw¿·—ÆŸ YýŒxwöSø[¯iº·Š&“Ö÷zïÆTøá‹K?>}Éc«Ïàɯ¥Öt ÙøwKÿ„ËTv¹sivÒ,’6_³ïíooû2ü{× ÜøÛKñDÖ¾ñ&Ÿ¤ê–)ÒuÍ+HÕ£M׆‘}¤}²{Mâ; ¥±³ô;ù´Ë/ôƒø»0ã¼£„±œOÂç¸ì¾†cÄY&<9ÕL%Fµ*uñ˜ÊÔWº¥ˆÃËZh¡e’þsñד㾖ù¿ŒuàöO_‡øk…ø£‰iTÍif™ß á8Û-áÜ/–á8r†6qUñxÚ“„°øª“UaÁIa¹0êÇÀ¯Û7ÁŸuo|&Ñe_ˆöún”÷~'ñ+¨x3Iñ%åµÂiWºÍ·7ýžüiaªµ¯‰¼G§i^†çÅðÜ ®n­¯o¯¬üY¥xËOþÔ]/P¼³×ôé-ÓR‡J¾‘Véa–/οøA¯þ êSü^Ô>*êÿ <1­Øi×~Ðô SÄúŸ‡t(c³Óu}eÒÛ_ÖüC«Òê×w:‹^:^ÝêVv:„v¶¶vw]½ÇÄO|Ó®¾+øâÄ¿ÚwÅæ€Þ²ÑµK]máð&•«\[ß\ê÷ ×öe‚]ƺJE nð˜ÞRÓÛKr$ÐücàÿqW,£'áì¹æYŒ0´óžÍ–m›pÿµªÔqØLÉc°•8nt±ueVuqü¸wNÔ©Ö®”Ï©ñ7Ñ£Æo 1<[Àþq¯„,Vâß/¤ÞG_1á_ ¸'ˆ1Ž|]šÎXéæPÊéfkê8üÖT(ÎqÃa0õ¡]aåÈ~Ó_àñÏÂÛý~xU¸Ð¦×ãÕãø€`¿ºñv• Mso­øãÂZï‡í4Ÿhz«=ÝÖµ¤øO–ÃóêZ|ö÷šTÞ¸ŠkŸÇKÿ€Zg†ôRð_<}ðÒâMBïûÒãTŸYðúëOjeÔåÕt)t½nÝtÈžyµmM4=wZ£³Ñ5X¾uýéý¿m/ üfñÿŠ>|UÐ>4x{âÕΙo­Ø¯| ¢Ãa¥øgM¸Óô½NïL¼ð”Q‹? 隶«¤Ù\%Ί÷vš£Þ^µ¾–²YØ|#ûv|;‹övø¿ix4ø øYñVÔ®4›ï³<ú“â]6)¤Ö|=p†!k»õ™ôID-pö“ÞA¼w6Wó/ù/â·þ*}óüÛ>ðË=ϸo!Æçxî!â^槉áŒ6Eâå[.Ãä4(Mª¹^b'‡„纒²§ q¥¢â?þ‘Ùo|/>Áp‡‰ùöcáµy7‰¼;Œ–—xš¸K —Uâ¬Þ<=aha–m‚ÃÓQ­—àp41™‚§έJ”ã'ø½ûVhW^øI¬j>6øWá/Z¥ü—×—^#Ð4;MSY—FÑŽ¡¬ÜëÚ—Œœü!áÈ¢³»¹×ä7^Ô$°ÅÍûiÈ‘Góx]ÎÉÙÑæ¤Xe1#1eL33 ‹ò|Ìǃ–5ý|ø›Áë­nü1¨OjðI¥}šV›R‰fžk[†±\Ï%¼–ñØߘ´»¸oÒëQ¼‰ŒVvëgfŸÎ×ígã;oˆ×‰â߃Ð|6Š;ÛËk=B;K{†ñ/‘Ú-óø“N’m+Ä cµÏqgª›Ë›«»ZõnGäpw‰5â& ¾iþ±å2ãÕÄK6Èðô¾¨éT†"¥8:QªãNjT!Jr9II»Ú2m«xAâúíšqY{Vauõ*g†=ÊÊJŸ1¯Lð‡Î¯xÓHd¶‰ᵺ>z¨I£EÄr”càüì›@|8ô0ù¥i਻wJë¦Óu+,txä†3õ—sŸ „Q]•Xlc€¸’ ÙžVeDÁÉÛj:½§…/™[ûLÛéH|¿:XZu[«Y¥inŠöHåù÷|ì¸Â¨Çw¦Ý\%õí“[­Ô³¾…òYÞ×Ï{U@ï,nÑêV² ‹¡”ûˆ5óþ,a±¸<¯‡jчÖi`pUáìjEU„EJIÚ¢•í&¹·~GÍp¦:¶ XÊ>ÆžƒÌ£‹Ä?e :¸ FëSž2U¨´Ô9©BïmM_ [hš~§=Þ»§K®À¢žÖÞwÒ¢¿”\MwkcqxÂþE²ŠæåÌñÅÍy6ÜXÌÑÝÃê^$ø»âÿÛÛè£Y›Lд¿šÏÃ:ŸaÑm…°¼—V°ÙÅu,#È_Q{ùÌM;-ÂK$’¿Œêš|’ǧß_Ûɧ[Ûê‹ Ý´sÝB·bÉs%Ñi& à20–'2*ª–l+gÚ6hʧkyQÏ Ÿ.k:…ž»aâí[Áº•ôwš;èqZékkwdFÙmµ¸j0Ãæ²mSRxCguŒ±¯ç<ã.+­Ä°´2Þ¥œåÓÁfåΖm˜Wq…,¾Xˆá}Ÿ= eZ1—?$áí.”¹WóOx/âµ kÇpFG—ðVŠÁÕÇætêˉÆÔËñPÆR–"&©Ö“¬¹ß<ܦž“š©ÿð^?ضo‡8°ý«¾hi–ZŒ4Ý6Þòæ?øßû6Þ=1˜ZG<1i>-Ò, ±Ñ¤2m·¼ÑãÓn§»½ºûuÇáVŸð âÅï­sãݲHŸ ´MgFðT‘=ìpj7rkVšÍËëz~—+ÈF•£_Øä꺬3A¨iš½Âé³DÖÓkɧ~Ý|9ø§û_üføO/†¿ioŠº÷ÀFþÄð¿‹< à­SUñ·\Yjw¾-¾ðÇŽ4ý*ÞXéóÿkÀ.¶ÎÐÏcl±ÉyÝüÓt=R_|½ðÖ›­økWÓnî´-£Õâ¶ÕtéËKEÒtí"!›D¿¿º´‚×RÓ®¢´Σ¦\Ky²Ûÿ¡_³ê¶iÆ\;ˆðçÄn1Ésž0àÜ,£ Äy-j˜ŠY…JwÁ`§›×¬£8âp˜¼=*—+´hâ”Ô›QšþÐðš®uâ>;Šã*8I×Êñp©žã( Ž6yÎW‹Ê0™ÛT£Nj˜ ö†–;ª²ÂV„ ÔŠü’ø5ÿý¤~é^Ÿ®êñOÃ^:W†àÐ,ø ãû7Õ>xºêõ[6öKq©k>×oô{†ŠxzQ5£ŸL–í ÜF´öV?دˆ^(pL³ÞÆa§Ê°¹ƒx¼.LN (¥û cÄ8ÆœkEAÊ2wQ>c)úBÊ~qÑ· àsþâ,Â8>&Éa„Ëèà2šO±¸œÙ}NXŒ77Qâ©â¥_ÚÂRœaíáBQþ‹þ~Ûß¼}ñ6Ç㎇¯hÞ1ÔBƒÂúVàÑ¡Áªx_G¾Ô–mZßWñG‹&]nâû\¿¶¶º†Á< á5šÓO]$ê/eq&µ¨zOíã=Gö„øâvÖ|%e{à]O¶ñ†…¯h¾;øqãH4ë­"Êáãñ<:47 Hܳ%·‹$¾ñEšKQÚ›‡üO^ø/Å&àï‰Ú6¯`|)â-cļŸÃú—ˆ¡Öü3®h(tïÒ4Û}:÷XÒ¥}_MºÑõgHÔ­>ÒgÕ´íZll>ÈýŠ~øããm§ˆgŸâ¦¡ámFCe­Úx[UÖÓž Ò.'‚ÒvêDŽ-ÓBÔnDžt¿Û^ ½’ kí)c¹Ò¯¯ýÎ1ñ*Í2œ»ÄþRÇÓÅeØjYÖ0Î]*sáúʪ¥†Êpò’¨±<Õ«N:Óœ¥)sûHÊþvú@ø_à×…y†=Æe8b¸× ”U˪q.|¶†6®c“eXY`²¬m9ÛKŒ•z¸ŒeZµ”áCÙR¥ø†ÝOÔÿ:JSÔýM%zGé/ú¸QEå˜ÎH¯¬ü£Ec£ÙéèÄ%Å¢Ku"ãz\^ÚÈ1¼s»ªÜ4A•`ÿÚØ#äÄ;]O¡ö„î¾Ù¥[ÜZÜJÂ+8Ö9&RP¬¢iX²é¢’5í ’HV¯²à· xúõìZ]HmuÍí[Éü:Fíé¡÷¼ –ás_íìtÝJùEl=&ÚúÅéɯ>of—›Ý]‘ŠÑt§´KÌ fÕo"¹“1™"ÔáŠöõ|¦. 7j"&ƒÍónæ …Ã¢ô–Ò[E*ÉíÄvóH5i?k*ìD6rÉ)I6,ë¾%[  Ÿ»r¸R\Çöˆå¶3&éÖ ¥·vhn£[›¸ÜÊ®&³Nñ†EãX]¦È‘"H­ZIUâ†t´6Ím ¶GD·Š[…µ’Hgè|öÆÓM¾iI‘ä'Ø✒¯eõp’«*~Òõ)Õä’æKÍ{¶æ¹¶i_ç§Áäl1Y¦6ž# Ž–oRÅe”0q”)ÿiO7“œ£ºTyå7ÒRMÅž¯ZÓôa¨¹²º1}¾ç³–,Ñý²å£-çÉåH'ŠÝÝ%D¸ñÊžf?råsc´Ó®Ò=:œk6îíoé Ü4ÑN¾XÚø’| Å ÄË@³:MŒzn• Ø:i¦Dìe’ÆÂ+‹¨âòí#ŠI$uŠ(†ÆQ#ç“ð»­üGñ ýÇŒ~,\èú.o-‰Ò_M`úü:‹Åiw¤i?m%¼ÔãšÜßZÙ¬’‹[«æ™Y•æK繑þÇ2­ÝÖ–ñÚ¤‹-ÂZN>Ëeý£vàMh-“Pd’áæ_:ÎÔIu"E…Žn“J]+KÔõé-’Q{­-¶ød¼q%‰¥’)|•‘#’asnÑ)HçòįöxlÐÏ åü1á^3S…2<ŸŽÆUupÙf,ÂàòÊ•\¹êÇSŽ7Z¥W*Šœ©ó¤Ô`¥?Îø‹û7„8²§põZT)JO›dëšYFk†÷Ul»F Ônu§Š<‰µ.m?L~~Ò?~XøëIÖâÑc]"K7/-Ì1›%Ó_!šK>ÒúÆhôíoG°’+©l§v¸Óâµ™ÚSµ/~|ø_6‡áü=ðlÚ_…’ÊÓZ ð–•©]jzd×ñjÚ|ÿaº{û×…î/¬&†úãϼŽ) GRð|/ãoÞjº^mâ~ 3N>*¶Ò,쯮äû3Þ¯‡I{öw²½k=ó–w"˜aeŽÚèEat«ó"Y yÔÂ#*# ªD¿.Ädf$ÎI h‹B,cŠ·i¢º<Çk™‹o‘0&//z• db:6³k@“\ZÀ"€2[‰¢‹¸!FTKvµ¹RέTu¤Ý|Ɔxí¯. È’{yV5†i¯![(Ý‚ÙO1/.qöxü¤ùœ7ÏdÄszøŸk„§ƒ­‡šÁU¤«*’Jœ¹Ý^og¹­n[mö™úÇçÔ(fYv jµ|.i„U0™„h,}­8ºµjÏ Fj…çJ3‡¿ÌýëÝ2 d—ySp#x¢“Š'[°ßÏØ÷¬|´ºxä-¾Eór«­^éÞ±Ó¼K«Ýص¥çÛ¥´³[W²[#›!gi ¶=¼÷ µìÒoqwKˆîXyo¹â{_[Zj·eJMö›ItÕk¤Ô®n!´ž yç¶,“ >ÎcB»È ×ÊÞ&ñmÿŠ®äº½vH¾í¥‚<†ÒÆ°*Ù¶ÝÆ Ó¶C\ˉä&AÎ\Kžã0•ã‚ÀN*„¢ùªÅ¦Õ¹U”RÑ»¿µê™|GÇ¿Ú/1Ê°¿Y£õ:¾Ây´”÷öŽšJ;Ú<˛ݺÓS¢ñÄj7æòÒúûM¶ûDWvЭÓÉ"M¹x¢–â(U¤H¢9´‹|Æšf—ªÐ>0ÉofÖÞ ÑãÕ&–ãÍ´3›{å2Ï$׋•â ;mÅ—ð«ßKá)tûèìâ×í@Ô<*Ù¬µ-!-­,˜ÿi~ñO‰ü;sqis.‰âSHºŸK¾ƒRÒä¸Óµ+»YÃP³‘ío¬ÚHXÛÝBÒÛÜÆ{id⑾Ç6̲ \)—eXl,óÌGÕëR£Äù¥L?öÕ\>VâÌ 1ËoĶë]]«E$‹4Îv4ŠÂ2Ñnxõ/ŒwsÁs…ŠÚ²¬V×Gl— s22ÝÜÊ|¸Ô³¶@£É@^BÀ¯‡î<ôç¯Ê1ø `qŠMÇ‘“Ï^zý}qÛ=+,4å„Äb±XyJ|dÝLDù›ö“z7Ë&ã:AEußSX¹Â)Â¥XC  'eïË'ÞÛ­šú߈µ-~ðÞê—ÜÜ„–rP§Èœª³Üä¹ÉcÏ5†\s´c'ÛüšŽŠn¤å)JR”¥'väÜŸ}.Ú[ì´ì.k¬œ›m¶å-Û“÷›v×QI'¯jJ(©nú°piâB8=Fsüê:)4ž_ø‚ºwM§f´mhÕšÑõL¼·¥4]ác,ؘ‚2>^3‘‘Ðígš®ÒîÜH$¶ÎKgqž1É8Âÿt6r!¢Ë¢[/E²¿Vµz^öï4äÜšÑJMÊVÙG™¶ùb¾ÞÑ»åJ㙳Æ1M¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢Š(¢ŠÿÙ\>VâÌ 1ËoĶë]]«E$‹4Îv4ŠÂ2Ñnxõ/ŒwsÁs…ŠÚ²¬V×Gl— s22ÝÜÊ|¸Ô³¶@£É@^BÀ¯‡î<ôç¯Ê1ø `qŠMÇ‘“Ï^zý}qÛ=+,4å„Äb±XyJ|dÝLDù›ö“z7Ë&ã:AEußSX¹Â)Â¥XC  'eïË'ÞÛ­šú߈µ-~ðÞê—ÜÜ„–rP§Èœª³Üä¹ÉcÏ5†\s´c'ÛüšŽŠn¤å)tiff-v3.4beta018/html/images/cramps.gif000644 004341 000024 00000031521 05774152725 017560 0ustar00samuser000000 000000 GIF89aŸËóQQQDDD nnn```þþþñññ222!!!œœœ‚‚‚ÖÖÖ¸¸¸,ŸËCþ0¹ÆX»„”Í A€àø‘ay¦ëç,¼Š©*¢‡xïç:a±Ð‰Ã¡bXô{9`GãUTà8ÃÁ@^˜ qz!X&“ì[LŒÓdCAÑ@ø ƒ ]ƒ‰} ƒvˆ~ …~‚‰‰bœœ‹¤iv v¤c­œ¥rD GCmD Gxi^c^o Ãbe^   Ä CšÀÃŽ—¥b ÃÚl”Ÿv•´¦¢­¡Ãv§­³¯Ípö*à_ à:ÂI®!àa2`Ú!ƒ –"þÜŒÑ'f’€Ñ†I3ÅJcÉ€´„£E f¨ÓBétð_+a]b1˜Žæ€´Ä hË>šõÆ0èg “7 Š®)æE’ 89SFFT4±Ñâ5¸(0Ì5*]E”Z6•¤Eà ²aD,8–¢âélº "<§4kLjª-ZCë `-\ ^õš0¼m`@Ò·ÄZ“ꔯ“(iÁe +@Õã¹ 4sÚ{؃WeþdJ)ÉH ­DÓÊ>,݃`Y½†Wä`U%3F: ŒFŸ`‰@ˆ4O¢- á{‹tR’yMÆŽ>v,6‰P0ÉäJ=r­ç•“EôÊþ„D „2 ½Xå‹D¹\WÌgláâx 4€Î8’€èhð@:X’@Š:Hç¢tÈ(af8ÙÊ"øès >åIRÛ=‡œ(‚JO;‰HhÙ†e ÑLJsSÞm“5Ѥ¡áx$€Å˜g^ŠÀA~Bž<3œÉ.^2àbV¬¨¨‡¥¥!Ú!£˜²—M@å ›åf@8^þ€AOÀ…&Ï$2À%<8íã0©‰¥eØ‘À`…Òå9^-ÀÀhõ¼™Q”•UF^…ÒIVpʼ¬ðÚ®«‘©t\Š§˜’‘N´EJaÇåµ€¦Þ:qÄo2é1D :.”íºÂŒKÊš:0È —li*à*XÎ& ‘„ ÀãõfX^°y§_>ùàÔ›Wm4!¨¦G4|ld€­­”&p=ò>Ö1dôý8ýãjÚ @`1 OÈ\* ìàD³ô¾ßH jÔÄÑxçȽä!Èx«¨T°´M •À(Ýâààdkd?+íºe²)ZþñÜœŒ{$AÊY5•âØÙêmºÞà°²¨Øáeo7ƒíÄÈâÛ,q6" ÄœÏL€Ž¨´‡àÀúÙ§óv tÀéÔWOŸ,N¾“XCOàóš¡–" `E7žë€Žhã1€¥·97zÃ’¤ÄÉÄÕ÷tæ8„âa€WH@„¼w "XÀ ç@à›‰,*“¨‡Ë,0„°´HÈaÿüGBÓ=‚)äÛÖºþŽ2¡ÁÁ7¦â9„„òã+ ‚3¶õ¡cÂáNµÈ5!¡€øNT­:ÑtØCþ8‚§ ìi?9ÆþZUžü˜DáðFr"" [@Çwì±9{½/ èÖçˆ7,É`è0™«Ø·µ3m-$:HÌZÊCž€ŒB²Ö ¼M„vR€¾p!³3"€MmJ£ÉFHÇNFŒ«J”Qìp2h@EY«À3¦¥*î@"¸X—%à1T{#¼ƒC>6Ñ“FƒÒ!`d‘û؆¥„e4G#—Ò`³˜Dà@Š˜)ÂuUÆd&Û›¤Ç¶ PÉ@Ønô3M­ÊÖþ”hŠÑLàLA#/X8íÌŠ rr™Š˜5{â<Õ!’¾Âà€îˆÐMÈèòÞd«Ê!.¤ÔXæ É6¾oN¢bŸ)ÂRXJ4¶óÝÖ"‰‚C’•ñã°àL“ j»–+ðõ4 `¢ÏèR¾ZRÂàä Ëcˆg&? ±\($Jô9žÏXJéÀ“‹ŠÉKX“b'³zZÕ[Ïxš<è£c(ò|uPšpVˆB«èBöà 3ðésCh©)y§ ŒëMEÚ Ÿé*‚n3)"ŒFF¥!K‡ÔÀ!Þ^ ®‹Š2Òþ•°a“P4Š‹|ì4û: ßøšè @‘K^šbŸ|D¡Ú-âj !YF26´5ð!?yX˾ˆÀIÍ+\xÕÃüüaaå#0!ˆ„VBÑ)L!„‰špƒM MÊ[Á0bQÒ×Q5¯]ðÂJ½åP,©î-‡CÛœH'T†gxÁdQ^tc‰¸ü@)BbN¤ò„—…X QbQ0Þ@wPÁK+åº}A³ `XKoñÃ$#;Ó•Yk²s¥eà-sÀNpó€¼D#{|ƒ )]ñÙØä#¯CBïFj²c’±a˜NÂÒþµÂ”¢»‘è‚à‹(!cÖ¡ñU:ø¶%tê+Ó8ô€ÛÌo¹ÆHR.5“äÁƒól`Q„•ÂNèZü4 RGM#AJ5±<(aÎÒÑP¤ÃÔ0xåB›5àƒ¡s‰8=òêá褻Ln¡©VI T".Æìð —Épz—W‰¬‰}ã(lÖ¦+qªu ãYÊTѦ²U@T}˜«øZ\ì«6#‘[‰…œY”ÍŽ³H r ›„\g Ì|ÛÉP¡ #bNz 3xËX{@a²߈yªVx‰UäYËüng±LE J!B>&óM.ãSŒ¦L鍊ý; 9‡ ~  ±š}¦£0…ÙÓÓF„¤œ”& ½ÓÃqá= `R$Â/àÕUœžaår} (f±­ÃRÌdb`ŸD ¶þyc"ƒ_¿3MÆu“HÔ-5NÁàà´ª@?±`)“€;v84Q‘QîW1Ç4…ñª Þñ Á'7C!@9Ò1.Y q òSD¾ÐRÆäZ@6³õLiÒ0"TÓ0ì1ÃÀIÈ$â 8Îr$2 hh@v8èQöÐ5!<ñ•¡ mB>NRLQ÷€OG¹3xGH=˃pÌ„G rk–"?=È —€yˆVùb'ÞPDlâ  /@s†½á<°¡pmè?ìrÿQFÀŒ"@°ZÚ xþ.B65&ÆÓ&…TPlPM8p$8 ÆCK‰%d6ñ2jda+Œ’/áàZ<¡ç}ôrñA$ÒÑ;€sC;TD‡VìC‹À´q=öÒ*$"z‰Ç7`ZSñTÓ:Ã$I|¥ZØK„w–µ.Ts6qDkÕqÔ˜ GGyO§Ô3Â÷CAŸ#E—B=¡ @tâ$ ÷„l0ôrHESðK÷8Gq5sè… ¥¶jXƒß×i.óÄPHä 7 –" PMINw÷&‡<I-¶s)JrP…€6 6AœPþ-j’^X$/{rHa’5ˆÀ«Ú@Çd™tŠÓÓ*orñ&ÙbÑ{À°“–± ¼+Ò`d*b ‹GËc±bvúPSË‚ ú‘!Ô%ÇtFðSFYDôçG€Ð%)rcRnnPH/—!’5Mˆ– ³B"ÔÙ¢"g"NàP—ã¡89Ð'7$®’Ó%Y¡ µ³1àr-%Iè0MÀ*½PëÒÌô4þg'l 9–™*"(?0YMëãvE‰á¨"j²«ÐR¹ù0Þ±Œm5&^ò&l ?Üá>]¢ E@v2.ÊCLµrDGÄ&=0)²&ãU–‡þ´uóµLgB[v‚6Ë£"a!9 ¸p"ÓxwHÄ&‚¢Ç02¼DLpDãa'p6ârÚ¸pŠ¢á,$r94uX†b)桬¡oÝ“r¹C¢°c–?£Æ vñ"ˆr ÅB £Ñ6Q?”# F ,ó’q08^L0ÀXrõµ,œÁžf‚ d&ðp2Êð9âs?pS3Ðé 9Y q BqI®"} ð ñãÃP|s{³f> ZxE·F$¤"Š ¬r'áeG0o&%Lð?êrÒ^¨1;¶‹óÐHx øx`Ñ!ÏÂ(ó’4„B˜ð5þórnO¡Øf£~òH”/Ç¡§€L°PjÂÐud!5*–Wã=ÙQ:…0 b§›ÒK¢ ‚™dÝÀ ×b@’Jø•i´€ ëv@“M:óMQ]‘/ôg-oq^‡%eö E°p%!Ò‡§¥†—0 k}ô§…€pè0^®«ºÑNúWÓ’ÀaMÑüBºIn†’W3(Íz¤|Úd:ÁÅ[葺ðeÂu :P aP®aP‹“ÈQ@x1‚{v8­0©&:±GmP-äÊ®¿áŠ³p¯H,µ‘l‰äx6§¯òÀÁFþo®A_k¦©¿«æÁ\@ª ·p¶ÇTº@¿ÁfX­{hú¡;CQ,k€¬ðc5+0ôpëUlÒ“R=—éâef÷u¨ÒFbá ìp¥{l‘k)[ <kø¦aÛ£nÂÁ¥ömüPEAH-±ó—'§¤ØÁ^Æý0LBf·á±4ÆÆ9Í ÉvE a5xÁa#±¬§3Ç°±¡8á6bû#rõb‹â·‰°@·  iiVäe×jú²\CXº¬û¬+zÒ'ùÓQ¯¡mÖg>é¥1`“0t(,Ff}æõÈñ'fþè=µ  “z2ßÈTNòÒ…Ïåe¥+·j0&µ@ïá!l±\h»9r´€ÇÐ5KÀ¦_Ó, ”±:|q# §)g¶°[Ÿ1oš‰w@!èA©££[G%d· 0×P¢U¸gÓ’ÕÚ.Z¥JÇPµa§¹›ÓÇQte¥núЫ„À§œ€8)1i#Š ÁéàC½ÝsÑæl9<,ù ²(»‘^T,¡s…ƒTj0σ¤°pvq ‘šŒ† [¶¤šQ_&üÅVñekl{±×FGÔ…QÅ÷ ƒSs(‚mþ!V È—œP8×Cï}yf/aZ¼Z¹ ô,_À§Ò=È‹3Aº†'‚“Ó%3‰&ÏÔ¼é@9É4ùihS³#ñ ö(£pÁ‰­5[Q Ã0èE§4!GÌt9£ª‚Ê!ÀÆf0v·.\&[àë¢J'¸ògãO…£J¸zQøŠxª&^¶‹­´€g±pª¢“y–»BW4â$?cƒ>½ƒ’d8@˜‹õWÿá`}`ÎçP"D¦¢GK¨dÈeãA`÷ûÏ#†RÖ0¿±£ ìŠ÷Ìí{dg"š`XÚNhÂ-–Ìö8„þ¹…¤9ÞÃu9Ú¨ŒÙiE´ äWSMe¤”GE`;!D?ÒgŠú  qG–䀔tŠ:‹‰Ð[W`ê"N[ Tj¥Ho6‘-Àv(¨i²m›c'z)Åòú@LœrE6³æŠÒʸÐ-중 $—×ÑÐ11>ë79À¢S63“’DL—Sµ3Q^ñ’n…8{(m^àµhLö¦ÏƒCqLç ù!_8¤1`‘lª@ Þ3E4&±æÕ*Ò±]ÔæjO› # bSdþ1¸9aCkEP{’aÂF/…g §Ó_ނך1À²±6n!‚[S.'N«PDš¨êrÅr3ØäÚÛâ%Y&)ò6óÒ5ÓÖ3#*!I}›ÀRÈ7Ã麥E¾ãXááX™É6¡L’"©%*8ÅjR$¶6’9–²z6m@’»)F¸}à¬ù¡×žX'S³@\Ãà¬hflcYCúmê¢ÜC'hjðP7sFHëá<¨ºåb™NÒ]Á6-r S% ñ×Q:‘Þ"JÖ”o.ó>Ó£Ðf󩓈SþàèTÃ¥qâþ„@ íwËîµ#C‚n€#KvP^C­=l£@qw<á&¬•@šG‘úCâl*åŒAéБªe!BЉ"0L ±›xC"{½$B…t"¹Yqw–³˜mÒirr=Ú0åÁa$6¶ždSdX•\¤9Ítú’›Wä=Ž·5 ùë,BCkGKA…C¿P05#¹û <#ãÙnÄD Ç®ÃË})Š3™<–•:zrU èY3‡i Ç>‡ÔN8ÄÌâ :ÄS^¦½ïLò燶ìñBε1-›Q@êØòœ&lrë© cb[(e€ ³ÏÑ& ?þãçA£_¬ß‘>œHKó’ÜçÇ2˜asƒ©æ=Ašª^`h8‘T„*=1×rI~À*ÃBKxIÛS…ô!*ÁŒl+-µGß艉-ª€7BqRWÑŽúR[O1i ݃ /zÔE¾-9#ÒrH 0^!?Õ4r¡€o¦ÍÐ9¤ÖL³$}{O1ô_BÝq`™´±Q]W8 ±C)sèìv4Åø#S&0çcs<›_4!X ] |]P:âv>ÿQ:ð=òãÚ6q "6(I*+k‚ÛÕ{5ãá ì”ûÅiÂápQåTš"þ1+XtôáA§ÀBìcÍwFH&!ÂýxóÚ3bTO$  †À`Ç–‚¥9…çqçA\@ï f!~Áx!ŒGdR¹d6Oè±0,8A°0P‚ÁE ‹ƒÁ.à ™ù&<¦ˆŒp|(3‡)#!„€¨FÇGH%¡ ÄŠÓ…¢†I …‚†‡€,††Ÿ žŸD‡„‡"#™Èeæ弤„…5³œ……Ó›´ ‡á…Á 13ÖI¢[Œ³!mP"!Z¸‚f}Ç„þ)ƒ  !ൎø’¦ÚnsBP…âÀ· w˜™ö"Á—öfµpPbÒ¬’!8(¥¦š}1—4PêmñdÄÂrž€ú1ˆ€„™ (ÀÍ,M=h|y € ö 3ö Ÿ‰ hÁ@ð¦€6# Äðã”Y™Í”!ÉÆ㌋¦ úD O‚µvÄðçÙ³^Öü Ð4) `@(€“Õ'pg$¨À³Œc5 `‚‚hÈx°´±|qeÿÑvã 72X}Ë3¨ì1Ú Fkš—Ú.ø2´-ažbÌz“Î1܉ìÀCÓÔþ€Z(’/­p³ÁÈ›²e3ÐtÔUY}´l‚?1ˆW°h€Ò°¢šXja$»\ŠS!ŸE8KɇOŒA`€R+ ¼m2 Ôp¡p„B€;õdR€X Á…`Æi¬á)„/2%€jT@ç˜c8à /„Á-†Adq@Àl˜«(¡ ¨17cJj€˜cB¡@h€ƒ¶†!Vb£² à€7@Àá ü,Á±~¨qÄ›z —al+óÄ2:(Œ„xÎÀ…Iøa§ ( ŠºÔ'…ljG/ª€pÀ!BŒ¦Þ¨Â (ÃeœWnþʲt X€F jù¡ÒŽÒfÑAÌÃ@•B‚<†•-ë`€AK—QËE[(³Šüã7YÀÊXpi›44 ‚§8k¬F!Æ#ï¿FS…VL`ÝÑ2L°ŠËHÐz›«YH`ñ!G5\âñÊáI·º¤ª*R«‹!,°aäX „œ¬æ#Pl(ë–U0)êÞxa3;Š9/_š6Ë—™ƒâª¯ŠE[,¸ ‚ƒ’ªF j€ýXŽtÈAi£EH˜¸0ÄZË §6á)ó†!È|#›åÈüÊ+²QÈFéiꪢŠ(Û^#Ê3äŽnþ«H#U—Ò8u‡5vÎÁo½×Ð!ðÀ÷~¶ÿ*‘#¢—N)ã?n:àfc馔2n(Åóι¹æO ÖŽ²p¸Odî¸/X@ÂÕ8Î¥¹«iû Ác?®ñ40¸†Ü/z–#5I•+¸ð›#ª™\Îç_ŠÉï>¨¾Œæ«±¾í§™[@4Ô“Ò½GÃûŵ¯Kboü«ÛwE5¾‹Ï±iÜ;jãg‹·þhïT<Ê•äD‡ƒUC"™¨Fkªá¨ÐFÔ¨›ÚNW NÃVùƒìp÷”ª…ËDÈFž‚$ì`Ð`e–‡Lì!…¹8B5Šðþ…HÈ)þöÆ@È]Ž?8Å6"g ÃØÀysˆÒ‰3»i¨È|¬Ë@âW…x¬fL@ÏE1 MˆBLx#˜ ƒ"ŒÝi`¾Â8„12!¯KMóÌð»;Rî>\ŠCb¼0©mK”0ÁÛ!Òm<ÈDøp´¥T¡ àŠ€ž4#¨…ÐdZús·ü…‘,‚íðФáÁHð@Œ Š3Ô‚rutÜwÊdŠ-È¢˜·¥ÂmcÈ“ÔÐ=(ú }n€hÒL1x-/É‘XòÀŠ#.›:ÌQ¡Tz”¦x8žñ¹g8°9èœCæ`¸@îM T :áþ„Š H£‰§ëÐw ¾Öí¬ †)Xø¤¢Ñl3óB@M#ˆ²†‹Æ+\Q.ÌíyÊÿ2¹QX€ß9ÅRŠ‡ƒÐ3(ECSx$»x¨mq³Â+gW7ù©æmVP‘àj"+<\N09È+ôI8>C{[™ÐRÀ4©Hz _K¢F6¶´ƒTãMYè#SÖð¸ïœƒžàÀæºa¸4œè)':¤"å& ·Åõ B œ´7P*3p+~ÒÐ>ðš DÀá8†rt¨©…[ªŒÂ*±€Ê¬ç¦Ü€G”ˆÈô÷&/œ/nWœÆ›JX‰ÓúÔ%š Z­xþxHÀ :àq ½u`¨²ZŠ(:HvjÏ ;‹ØÓJ#l¡y«íì炈F”ôõAº‡LžA“Ÿ1(!úº7Ðó%ç˜T,Ø'/q¾é•³šPM ¼…AoN Có¶Ð“‰€xFoœ¶·%I$¿‡»£7P¦ìMpšÁ8ªpµÔU€#³û^ªøƜĽ. ´(¨ipG‰ÿèh0ë)x”÷z´E«)Øb•ú{ÑÀÁqibG–ÐÓ-îlgóç-8ñ©R\8¨dñ¬z%…kÒ4û)n<;làl 8_P†‚ipOSÈ R%Êé¿/a þÉ®ó(O8áZ7û<] pºÈ?õ ~ŠÓ\·¿ÁÎ) €Hü#JI—hUpåÄf`᧠IžxÊÌ’ÆÍSÞÁtD÷‰ÌÓ&á­PˆÆ †#ÛßMÇDŠº°½t;ÞRŒ‚³‚ë´ƒ]æLj•2ýÇ ­™îåV£#è.à1ƒ‡¡‡=¡€ a1ªyºTÔq¥+Ø-¨™ªÛ¹ÉvgÐ̘  ÿYXq8…/Úál:ðÒ_eO@àO\íM€(5R b#JÅ°ìâa6Êm¥)m uCµü,~¾ ¨âÐÂ<ê·JþXɵ¥r]ÓêôVÓ!Éy…gEw—TE¥,ø>‹À!qtøT®‚•P•µ)-uݵÃqTƒA¸)³#bÄ\Aþv×pâäÈ×ÊV¢ÆhõñI_ò;íuθ[—ЀÞÑ)Ñ W‘ý¼¥ý¼#ªûàÛb×ñ4J¨ýàj±uC“6ÐÏR· r¦T¢–‹Î'Íaî9C${£°sn°ìy3t˜õÖ¬mIPÄ81ºìÎG“‚ÖÅ„sÔ(a¸ðýYvm☷—”£=ÿÕ‰Û±Y3dTÇŠßNaƒ=®—Ñ£þNÂë´Ëè_GLàXPþ$È3Õ .Ž zãÎG¶»\ñÞ¿ÁE®ëåFñWM[åi=ÑW ?7X.@×àìßoÀËû›&ˆ© ­$ËY;:Ñ*!þK¥@ƒÑsºQ½QÿÈ›l8·Ù±¹Ê‚°kžÛJžƒ¼¥r·ÇÁ‚Ô@‘,M ‰îÁžÿK%Iؾ  ÚP½°ƒÿX&»…à‰3ȲVÚÕÚ›Ù˽«[®Ãj¡8-ÛQ Ô˜/3-Ãc³­Ð/b’ªàœ°¢fú‚LìzÜÈA'CŸ½¡ƒ)»»· Yq7º2œ;ÏÚ›s4åh73%B"W°¬xš<É™-þn( ˜[ŠÌj4£J£mûŸQ›Ô:+X‹x¸Â)Ó³Ú²9ƒéÚ1Åsˆuº Èš9Ùx½ÕÃÃ¥b'Û#ŽH3çA0ÐiIx†!\¤NDŸÑò „²¼I¯=£@’7Ć Ä¥*¼ó:ÈÆ%9ìÉñÚ4¤|«E3€Ä’/LpÙR=Ù)(Å!F*¨×ÁE¾uä/Uà2 )/ô%¢C^ò1ÏÙ†² +n@ÿ±¡5(“ª 7剔¢†G˜‚ÖQ¹¡ PÉ Š7ÔI+Áp¬ á(Â8–¤0Š¤¸ˆ¦ðþ±º:ÛI¼lÛ4+˜#&i,M9JB ÙâDª%ø"S@…qh5ô6šª<¸‰Ûš¥œ‚X‰;ȇÐX‹\ˆ÷H˜2ð P8 …sE;ZÁM„‡ªÉÂçùœ^’¹m#h[ …+©äh„ȩ ˆÂ¨ ¨t›ØÓ0óy† "(†Q‚b‹‹¹Ü hò8;1YªŠ3&éœ3»ÊšK5#)QPÁ梜%›Ÿ«€kZ›m™Ç¸ªÄz›)ëŸó•¬Œär£¤x…¸eQ™uIÊ ‚qzñ¦ƒµ9¯Aº³óqµ?°’ $o!ˆcˆ¨ ‚b`"Ž=¨À“ ˜ˆ‚8­‚s®ÇYË岆:,°Ë)…EBˆTh¤(™0¸é À)¯)šB ¥„ü¸…„Y‡È aà¨{ÿZWÊ\¨jàèÆ`…Êp…Ñ¡Hí†QÀ"¶êqS0Dí*˜ÑÈ Ó³Í·ù.V3jz–îiŸÁ–N¾08ŒK8/Ø*HŠÐ™Yñ™:(Y(—eé™:j®‘ê#î,J¡QJ²œÎätL\Ó°ÄAê J˜þ$e‚Wr†öȉ‡=ø„[ùYP!p€Uè3bˆ(Ñ€:m0:†Lè Õ£H“*'ˆ~”9s„é[ÂÌ€ BEyµÙŠ¦>ø¹V2Y >@8x¥Šy¥¨¥q’*€#ÜðÊå`mà1[i¦äœ{KãÉ^É4Pp¸¡9 ZP‘ ycxdʼnX4Ø€…*ˆC,2€O0 Ÿé˜D`Ú@…S…29¤QÍ€C™Â û¢ˆ“€I™§ÑP´Ã9£`­€³\P‘YŒŠ‚ ‚ÐJþÍø•“xƒ$º•ñ$ö0Œ¤Ks*Ðñ*L`J0ÚJâ“þøˆÌ/˜X‚뢤!ŽaP%² !BÕÓŒRJp Ú’ÂzŠþ òHöx¾Ü‹Ü 2¡ 26ÈÙà½uÔöЭZjŒs`¹Ì3Ê£¤¤ƒÀZIÐÚG †c"7É)Ê’±ƒW4·×¨/¸Pô¬p+³¦Hœ`­ªxƒmØ*úZšvz/ÐA…lÀ‰›³Ú‡Weýh‡p“%ã°{ƒ#ëV¿0Q»©r PH¶ „ݬŽ I¥01Í9 ƒÊpéêªQþx]G ܸŠ7ÄXJ*عüáÀmØ °ëÊEQPPØŒ[iÌ- ÌT‡ì¹#WS—Ö²ZH°Þ¸À‚¹r’“°½ #ˆ…2ðF_<úG 8Õœx-I…6è-(8m‹•š­å*°T„š±”b8œ_`‰¤óö¤XJ`T0Y‡h›ÂÀ„ê°(‰XÈ„Ù–>øÎ:¹„À´Å9œžKH ŽTÑÕh`X`² Ú3CvúƒTØ‚X8G±9i$ð&ùÀL¿Ìc’§˜“²3¢P”â6 íTÀ.õþ R<Ø{5 n™7Tµ¾=zÉUC7þ2 š(‡-3ð I¦s”Ø®á¹;vµh!´Z¦ÙC°TN£ìLYˆ`PvJ¼°‡ûÔ‚°H68¦T0©2«¥¥’ƒÃ©Nn„þeµXeI×\DxÂCLÀ/øƒ @¨dƒøq’žbØ‹ PD0HJïóÎM»4jÀ‰à`†º#‘Kx–’®vÀ? `;ˆG‰—ã:½¡ØQZ\X Š”x(Jªßs5$r˜Üˆ’Ú›m9çHˆƒI‚¥Ñ¿«\˜šð¡ÒYòWAPá,èÈbþ‚1© ïQXê†t-ƒó™EX ‡^±8ƒ²À€AøÅPÒÓ˜äRT‹€«-„ÑØUƒ~€ƒèŠÊ›eíuáRç„Þ«¦<­éF‹À¡Y¸…K{©¾‘E§Xª¡¨…Eñ™ÞÜ#p8‘ ¹ÏŠŽD0°B‰ÁQ!2)z¬(öêGh iû ØIY;&„æ³(<š°k9“c!‰I”p’|@üЀÄ“r”ÎÀìG˜P?RNk4°²Š4ót­XÎÙõƒcp¤á )pà‚M> TIWf’00íH8rujËié­þ…ù‚îØêÖC?x©Iy sJ„äݤÆpè_XMÛÉ#ePîep”¾0´wQœ~2î„!IòÍØ”¥6í¯…Škx „ŒÁ „-Bw8,! »€¤$ìuï(0 œ€«ƒ½v†•A?à¦è¦Ê¨Ûòp˜,ˆ×´pPEx% ‘,i ö˜“¹”ðf0 …3è 9^ã,E1‚•°Ò0–“øV°cá¨aËB1mí%jîjo„¥ Eµ¦'÷s7Á4‡+,œƒ¹zù‚¼ègÈh Iie±s BôFÜ+=Ój®sþÄ )ȤÕ+œ”¤Ä뙩OŠÅ ˆÈÆÇÑ#5ñ:`û|^5‡‚­ôÓªBv˜æ=Û® p“dßR¸Rëˆ4$b–Jþ#°‚?Gª‘¹¬„PXâ/) íÞeIS±KßQKW+ሑZ¢EP¥žuHx5’uÂÅŬF‚ûŠvjÐ@paà…?È° (ohr®z,¯èio†.Ž(sŽh£·Å90BØÏ8¸bœð‰|9±ÇáÚY82“ðqE®‘¨xo†¦=‚ÆPjD O’øäƒÃqpê›(P¯¨¯èþŠxG¹W]j,s‡ø÷·&ô¢Áh‘ç;S™G1‚+±€Â›.1XPq'zÓviÔ¤ˆp—÷ä.î]Ÿ N*¥,t…Þ#ï`©Š!èT*…ù)£Žÿ¶pµ7 {¨á´ò¥ xœH!êKá^E¦Ãiy }±%AMâŽK†¨ ·ÒX’‰»´„(ˆ”‚p‰“mŠÒ,4£ ³Tš¤è™©Ó†^©oÁ VXN!i&ú`æDHÃù¿?$`™#*ÀC[ƒðõn©Qkví¼P(w¦HßÖ*¨­¹l¤—)—ÖMý)1kèlþ éª9ÎX„-…ÉÙ€˜¤X™1¶÷!PÐ:P‚«ÇJäo†Xh ³Ÿ 7I Yy¢ŽšŒ4Éñ’(T5›´–#ÙÓDMT!‰Q 4p .’LµÐdŒtÂ¥Üò .1í3Q:{e…Šxº¨pRFéÐóZOM`‘#}‘‚[`1Þ]”å«! “ v‘M”•#(È•NH`ù`¸mq DÀKÍpK3ddÀy¬¶ [åþ“€0¨¢Äk™…Ð#9q†4µŒpX!Á)#p’ 2r¤ F  `<ât‰…`A z!±]ó$’ˆu 3U{½àI(1a–N(»Ô€¥ ð”öÌS‚Œ&ÐÅR¦ŠqÑ=((™$„Œ[¼Ög6SJÌè‡FƒE æ‰À7òÅS¥‹ý* k|Ø‚*ijƒ \°â­¨h]™à#’¼&CMEñêBK·lUÚPlØÓ"EÅЂ.¸(Í |ù²h¯§…4”-·Œd@»…q®”€=ÔÞ7‹ˆB• 1ÒT–&`Ĥx!ÌQ >þÈH•—[nŠT£W˜×„ "h¡O£{¼&m=ºPeWFU¤ #>•"Kc³V´t@…Íòç†u½»Ê”Seʵ.1‹f]ô@•yÌc€KA!P*¸aÎ@*!ÃÜìsÏj>¤þE«½dk^ñÇf\Œ@Imxpq†ø¸Æò­—¹Õ¤ÓfŸEh'0QŒC ¯ñBéDÉ=˜‹3ž@Žå^˲¤‹…ì@ âr8Œ}QKÀqÑR ÊrG i®bÏ„/à3°º0ñ”¨ÞrA yj/šÄD±[ñË—¨T¯ú@µ{„(Jê¼þR &™‚(|ÉÎU˜À—nˆ£'bBë¸ö'Ä´¬'¬ð 1@ !1 r‹È€N€¬”¬%“ÂZÄÁŠ£`“ÂÈŒ(<H ¢ ø ì&”ñE©rˆÍdg3° ÏÈR@ˆcHçÁÄ:P€ôf+§+…–¢ç›:ì ©0Šá(t%ðîˆAÎP¤¬(gH…*"25b M<ÂW„˜G±E$Ö“fc\.“-È<*‘Ž„É|q‡€™‘„ ppG—àˆÇQC:œ|$‚ !ñ[Dñþ @ w8ãC=ªcLë?îU< †‹ìD âÐ’B&TÇl˜™Ü„aÀ=sZN..™™šš›  œ£?*y‡†hdmIvp8OR( .À. à ¾ÆÈÉÇÄÁšÊ£¢š¦Ö_1ÜÜmWX3I·8©Bè2êJ·» >¿õ¿Ê65û5=ô¿ôzôxa`ñ5°|íkø.¦<®p7èÞò¨@ûÖ;3˜Š#@¢wØžPˆG@ /,D ™0†;ˆÁ¯‡ô0†IŒÁ vˆ qÂ;q }0B$ž 'È"|0BþV â‹0‡áÃ-‰iÀ; ~5Ù‹‰0ræ‰\¤:éÆ7þÄÀ D$b¹˜µ JH…$õçØ£ØS£ðŒzøfh3‰Ǭ¶.`€Pþ…MQ¬8ÎqCfÀÂ-Òa‹“¤E-£¼E;Êò€b52kä/j‚“é„'>ùÉB€¢ÂøR!ˆbæH\„›c;ä(Ç´˜$%AIZÊr‹•X:¿F#9ºää›·Ê€DöÂÃøå)b{ŠT¢ÂÅ,æ1ÿV@HnHêž™éFXÈ2P³, áÀ5q¸ÀÆEäÈ¢äì@¾úK`tEQ´™ æa@¯ü€uóÅd²‚¯ä3fIÉ Lþ3•¢D¥©ºfÆ`y ™È†\ã¢ËºîÓxŽ¦]`‘üÀ6hZÔ×€˜À!ph xщšþ ôÌÐuLj2àCÞA“JY –€vÀ=’„‘]Z´ùÔ‡>˜èÔ#m ^‡ÙÌ*° DůHΊ3ßÌ%À†™™ ò¢RJ˜F4¦¥4Ûé@æÑÔ7½é?‹¡ÀNdT¨½h>CâèSŸ±–Hù:>°¨Ðö:‹Òfð%t*T4ÓdÅDY…\(¨Ë‹è’Œ€°¢U«òu/ XF80`ÄÕ«À.¦HP ²Ž…þ,f-ËQ™yÀ´.uN‰€S@ʶ>Å-ú¢ U㱌Lë¢øס‘샊 æ®ñÔ°š¦‚Ü:*YkÔÀ”…Û{àÖ]¯´â»aÎ}®qŒ]/²7 ,×\"ÙÈÈ…›‚¬ì@eÛ‚$PB¥«*1…Ü؈3èüM Pu/Õ0œ Ö*@ Œä4QqÈöáß*W­Êè²ÚÊ4ÐÀ4ef‹« "ôÑìý‚7;~ [GBQì AAko‚èÌùoF;ÚÁPÛü jR+YÉò…9¬] £P|ö®L!ù%°€Ú:€äUuÅPsÜÒœfþä ÓûôÑ@½·9 NκõœÌ›šÝ­}{ëÝþ’v°É.›:@àáb}7Ò Ïz¥NëBê:cî{…+\ú$h;á=OzÐŽ¶ô|]:‹‘ïnÄÐ<0?ü­}ú3žïBˆ<¹ÁÍœŸ—G?v“/ùs`¼Ïw¿Þé :ߺÓý½ñõ‚Ówßü§ ›iâ‹PˆÃOH‡„?‚‡…@ø$døBIì‰Pè‚ 1þÃ'€ƒ _X! UXD‘‡£…‘8¦èÃp´ä8¼#ÈÍ ñF0œ_”8Â!.‰ÒÜå¯p Wîr;þ| j¸¡‹Xó‰Ó+O5>Uþ”`g%h\E(Í cªà"Hz(Ñ€óra‡3'GnD.Ò‹eïF2AÂ{¼²î"]c(>á ªŽËCÆçøóîÐoH mþ‡*ˆ‘s-±™ º šêÇmû»VºxO‚!WüâOÒuèq ´PD­„ hλÆîK|#›ÅôMÉÖŠ˜à—ÑŒ4ÒlÜ ˆ7}êSy’"  jq½P€±CÆD ˜‰¶ K€l7VƒB "þžHdÑ„IjmhdŽ˜„h¡ŽsôѣĿ"ÐyHÞÌ°¤n¢Vw1N>áKL á=Qþô0 ðwßСq¥4 dAz&!àzŸ{2QP×'R>àMyrK=Á¾ôeLHƒE± q~ñT!‘Þ`|ÂDàO¦´káÅsGgµ—w¾¡)h+ÿ!Nã´æôeçƒ\¦N ±·‡—]Áq„J¢áO+EÔÄàcÅP{ÝGžN¸Ôˆ! é¤NAAƒíER‹¤X‘XY¢ÇfÈOkg‚ pw¬aSèçBE|Â+5Qb#L1Q‡áWÃò2ÿ 7ŽT_¨XÝ°Ý0}” ÛM*¡Jq„i¾þ1‚2q.6áb+c˜£YM%¸A #1êÁ1·¡6Ÿƒc¾ ÁðF‹Å&eˆ(V`,¥Ò¤Yµe'•P¾ñ8}Ç&Ðg Pó0T(¦ÕnŒ?pœ4˜°H5RÖÑX;È¢±ÝV¡a@…e'a>à&CE+ð±.Ž‘¾¨6QÓâ 0TÅ$ÄqdãQ%pðø ?P,õ¤%Ôè]EßñÅ ’æ" 5n"#2Z¡eq5uÒM†æD?ªÅ++ƒ Y÷H#…%.éXÙÑU`E")rYþ3¹ ¢_þA€1Ò„µÄ÷X(ºx>r#ye#B@>e P;ÀêÁ~WR^Z¢X™á‘Å#`&^IV"‚_Ù-i‰S<â“1`­Ïá Köj{v9%C’¤ƒ–/%°*`hT¥À3ïR£?ƒ ‘–%–µ B™Æ7š°dªæ¯4‡ãi´&n…#ã9% ó9>v4 tiwë;g‹FôÚ¬Ëv8 6mÐv7ÀÃ7xS:®fo¯BÒBhVië†;Ô#Aç¸"„±ÚZ7´j³ãkÏc;®¶dá&mâÖ;ªVm d1dþ¶l²[<Ð<ª6på–Foã ”>Èo7»øãA¸m¦[ ùF@Õ;ó·äFplK év@ýoï–>Ð˽ꋾ—67ûÆoè›?Îþ—Kn¬û 4¾ú¼îÖ¼ñÖAÔf½÷VAú«þnÁË@Ôfo€“±’— 0@ù+?Ü¿ý‹@Ä@ñ«lóö=-0;Ðfm«kì&?½jq›:ã ç&ÔvµÐp  ‡ T`C*÷p0Ô \ vJÔqQ‡c÷q“° /,3tDTä1g@sHô C€v5ÜÇ †sJtD6·t"çv^ü,' >ŒCÄ@ìBWäà D%çqðÆD„ ÆQGÆEGt4Å&´CF'Åmwsg'¤sRôt[ C}@taÐCˆÈ¸° i—v€,rŒÆ1œEj`vm0C?¼1GÇVlx=…LÉ%×Ã.”Bu`v„Ã{þ„,isX£(À3]û%Šçx‹üÆ^TÇAœÉžŒp#W˜¼q™ @ðWñÌl3 ¤ ?PË»<ćàEs,v¹VO…»„€¿¤þ‡ hƒ8ÃpDÜrGázzD„èÐÕªäøàcÀ„&È#MˆK¹à3X3˜€1å-RÌð§˜Þ_ØôJˆxˆ´R°Gi¨ßßd+s¨K„á‚2øe¼Tƒ—ôUíub$F;˜OØÁŠhýâ¦Ä܉"âV]‚y‡hN¨/HqDá#àA‘…Ša§´ç Ÿí’ÂØ‘Š10)q-îOÓT20˜P}Œ$Rwrå·²‚º$§\¦x…W¿4$záUÑ ‘æñ€Íìp)ÁþÔâ qM4®ÑÒ¡-B™X…<ðO1ñÒ¤(*îþäNa2¡·†&eP¢Q†B¸R+pæŒáUŽ'üý„PÈ|!§DAè†Zž…Œá2%׿ðÙȤ%îç užÚ¨Ú•NM§A‹ŽÍÑ'èY=y(°ZbND›/„Î'È.$¬îQgÎ/~÷…Ø‘ÞÝ0ÍŽë§1Pm9€ YX’´pWb#Q±¥/(„ •wÉ~ZéÜ0M%A†ŠÈlÁ6C‚ø€Õ·x'±áQ·á8›DÉ©¤øaôøHÈ(5室X!Ïšqí}•®RüçÖÏøíTXÙÇ­0À‹Ÿº&â ðÏm9þs5&s9›³YÚ$¾Ðì—%_í(B˜ˆº~5É4m«-€ü®"C¥jLPãsAñèÃA±¾w˜óô0w‚M2q§¸Uy´æ)¥ˆ0¥ˆu“m~PØ­bOó@å{VËŽ2a(€²ó¨FãFvÏΰ $ä ˆšéX)“a0u“ÒàáH–î61T+P6øa%ó`â0T—3Ãqu/i¦°"þw{”Á’õ´š„$aõOºN%1¨PvbXþÀ2Âj*' rÇQ'çß ”}Õ?P$÷‘üïþ‹ð@0)]>DáB¨Ÿ uF=1°b±+ï×›ÕfY†­Vëù|=4¬“`¶ßáuÀT*< %#CbfÍFGcaA¢§â/2òEââb§!Éå‡ËéIÊC”4æÃÁ‹åkµ ,uõ«Cn­§G.w.·f'ƒ¯b#ÒàÀ¦ÁçðàwccqÁ¢ƒ‚gƒDØšBâ`“Í[€4Tj<ÊÉ…FkukkÝˌƂ×Wñ@__ mg§†=76Þ(£¶ˆY#4ÖN(pˆâÏ nØô0ÀâÃŒ)¤Ä™«Bʇv±ØµÃjtÁ‰£k_ @(0ûSçP.þexà°€™0:n~`2aÏÆ?nõ¨!ÀÆ';–B7²È’&U­p@ƒƒ69iÞ´Ì·“gB ÔÄa‰ˆ' ôe   f¤ ÒTqJTF'38z|òUä:#×1Öòxcâ;›'5 ôÁ!x‹à¡=€&Ь‘ÝHÚ¢Q¡ñÉ ØTÌûð€[kÕŠuë*B¸ðaÜò>ž§úA™ _Ò6,À+ Rn5¶Q˜ íÁ§²e‹#Oµ0©"DÐX¼87ü-ÚÁ·â  &º}kpA.†;`0`‚6ûc8P ($˜p ,8D»þ vG6Î#¶ŒFI/?öXo ‘DêÍ“b¡Fýž³, F€„›cÚpŠÀ|TûÃ.~"ÆD´Ûa‚‘<(Êó€°(fSVTq±È´Ê8áÔQ§z,ƒ Â"†Ú8p‚(Ha„*ãQ@p©€*0àÈ"ȈÉ'£¤P¡½öFˆQ÷Ldq¤ÅbŒ¥^¬áEöÜËTAFð ºjb†ž&PJ…hD)-Š `O„[å JÝÝM·ÓI'F•:ˆ®/—Ø4€˜`pÖǼ.ƒ €"‡ H˜(Ë# \Ú4z’þÐ"]ö €¬\ÙÛÍÊ‘vƒÑËø¢Ì¥4^xYNU&Ijrˆ`¯ÕS©0 ´VZi}âÐÎ=w„Îu÷VØ•4Æöˆ-Ö„±ò™ß} ðå4 "i°`‡©FÏ~`"V‡þV\s5¸Xb"XwÝ\Ýc·Ø¢‹µ÷Ò¾âPzߘEP;*Ø:ë48!U™g1ÜYÉu8ʈ%ŽÀbŸs]Wc 5ºèVpûÓpI<¥õ-™Ywe#˜wZÜæ&·½a\e~X¹ëÞ±ßÞxÚÐ段½ÉLq¸Í g8Äé lkËwÇj†õ³*1k¼á…¦õ¼#.o‹SúÞRÖk% rc;ÜÚôþ8•§{_…£5Ú6÷¿k½á3Kœå—>z·‡Û‚p ]Ü-o`ù² â6/ÙÄÀÓ¸˜O®ñ‡½âñ®wÌQ ìØÚݼ¼¼á ö|3ÛÃlÎ߈cr»‡·ëâͻʻ¾Ý¨ûå8çxF3:¼ÿñ¿güßj¹N<“W{Ïþåy³ñjPW;:9.eg<ⶸ²öp$ÏIÙꊻ-&.Ž%©Nr¢âå厗`w7Æ÷½&[{Ê;#óu¯Fv±‹oŠ<K÷ý.E›W.‡V³ /_Ÿl¼Ÿ™ÊõÍk‰ÏzVž6Ùgöoñ\\æ)#ï¸ àpš¥«f/xÊR¢Ä»ÝíBÊfÞë¢?œdû.”›.H§ŠÑ¼hD›9Á¢þUñ”Ìi#ãX‡Æi‰CÐ1G¹Òˆ–²”wœW¼–X¡Ê3‡9|î*ÚÓØM4«9Ýk ÛúÓÇ3.f d¤:Њ&s€»Üf…fÓÞð¦ÓYk`[ºÎÙVv”Ýk0G0¼BÞ3™íLnrÙÏ$ž`fÁ]h^nØÐáµõ¡ùjísï:Ñu>we#˜wZÜæ&·½a\e~X¹ëÞ±ßÞxÚÐ段½ÉLq¸Í g8Äé lkËwÇj†õ³*1k¼á…¦õ¼#.o‹SúÞRÖk% rc;ÜÚôþ8•§{_…£5Ú6÷¿k½á3Kœå—>z·‡Û‚p ]Ü-o`ù² â6/ÙÄÀÓ¸˜O®ñ‡½âñ®wÌQ ìØÚݼ¼¼á ö|3ÛÃlÎ߈cr»‡·ëâͻʻ¾Ý¨ûå8çxF3:tiff-v3.4beta018/html/images/info.gif000644 004341 000024 00000000203 05774364066 017222 0ustar00samuser000000 000000 GIF89a ñbbb```ÿÿÿæ!ù, T„©Ëí£œ‹oM¹ã xâ@& gªŽ)ÄkË&ݪL®/g,è)j¶›(ä gÃ¥ñ(2¡ésWE,^&âýLx èà:«×ì¶ûí(;öoñ\\æ)#ï¸ àpš¥«f/xÊR¢Ä»ÝíBÊfÞë¢?œdû.”›.H§ŠÑ¼hD›9Á¢þUñ”Ìi#ãX‡Æi‰CÐ1G¹Òˆ–²”wœW¼–X¡Ê3‡9|î*ÚÓØM4«9Ýk ÛúÓÇ3.f d¤:Њ&s€»Üf…fÓÞð¦ÓYk`[ºÎÙVv”Ýk0G0¼BÞ3rÙÏ$ž`fÁ]h^µ¢0@«TjísïFzˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆìÕXˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úž â6Ó¸˜O®ñ‡½âñ®wÌQ ìØÚÿÆŒÿƨ/ÿ®¨›p@<àͻʻ¾Ý¨ûå8çxF3:tiff-v3.4beta018/html/images/jello.jpg000644 004341 000024 00000032660 05774044220 017406 0ustar00samuser000000 000000 ÿØÿàJFIFÿþFCREATOR: XV Version 3.09 Rev: 8/13/94 Quality = 75, Smoothing = 0 ÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀÀ"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ðÿ²p óÓßÿ­þyÁö>q¿ŸB?ÏOóÐÖšFFÖÛœtÚçüzû{P#Úqßîç¯òô§@+×RfV3~ÇÏúϯËþϵ̶0ù' üúδ¼¾™QµA/eïÓßñÍ[.0¥ºØ{~yÏ®H÷™ÿ_×õù»Ÿdã>gÈ;O?çüóÅ/ØùÆþÝÿ<ò??®4ÄD2ŒŽxÆ~¼lvéÞ‘cÊ…PªÀƒ þ§×Ÿz9˜XÍûÇô㯯áÈçßñ£ì|ÿ¬úü¿çüûV‘FÈl(é·Žƒ·nœØdÑåcåÛÓƒžŠ^ØóÍÌFh³-Œ>Ièÿ>£ó¤û'ó8ÆAÚyÿ?çž+P#p¤ž¼tÉü;©ÏP)epxqÈ= Ø{ oZ9˜ìfýœoçýßóÏ#óúàûÇô㯯áÈçßñ­!À@¡G@1È?©÷ç¶h(Ù …6ñÐvíÓ‚{ š9˜XÍû?ë>¿/ùÿ>Ô 2ØÃ䞀óê?:Òò±òíéÁÏE¯lÇùæ—cœO^;g'ðì~§=@£™ŠÆ_Ù8Ï™Æ2ÓÏùÿ<ñKö>q¿Ÿ÷Ï<Ïë!iê=zzNƒôŽ :Ž@éýO¿=³G3Œß±œpÿN:úþŽ}ÿ>ÇÏúϯËþϵilîÂŽ…xíÆç×°&+.ÐvðNA ^qŽ}½hæb±š,Ëc’z?Ϩüé>ÉÆ|Î1vžÏùçŠÔØÇ'“׎ÙÉü;©ÏP)l< §¨õéè=: p;ÑÌÂÆoØùÆþÝÿ<ò??®±œpÿN:úþŽ}ÿÒ tÓúŸ~{f‚ØQÓonÝ8'°É£™ŽÆoØùÿYõùÏùö Y–Æ$ôŸQùÖ—•—oNz(={`?Ï4¡ó…$õã ÎOáØýNzG3þ¿¯ëóV2þÉÆ|Î1vžÏùçŠ_±óüÿ»þyä~\iÊàð6ãz°öÞ´Ž :Ž@éýO¿=³G3Œß±œpÿN:úþŽ}ÿ>ÇÏúϯËþϵil†ÂŽ›xè;véÁ=†MV>]½89è õí€xÿ<ÑÌÄf‹2ØÃ䞀óê?:O²qŸ3Œd§Ÿóþyâµ61ÉÀ$õã¶rÇêsÔ Aiê=zzNƒôs0±›ö>q¿Ÿ÷Ï<Ïëƒìg?ÓŽ¾¿‡#ŸÆ´„G…Ç tþ§ßžÙ £gvt+Çn0Ç>½4s1Ø°±oUÇSÏ9?°ü£TÅU†29‡^00:“Ú§ 0+•ÛóLž¸ííÜõéš\6ì–艽ÏSÜç==„ànGPÝqÇëùôŒÓU æ'?óôÏJŸi*2Ø@Ïÿ[$þTm$m'‘Œç§P?,zþtíÐ)R/œ`Áé‚x>üwÏ4¬9Û» ¿ÂHãÓ ¸þx°c%¶‚Iþ"Íž}ò{~YÀ(ÙòägŒ÷íõÇõ=qIXdXl¨WnHÆAÉ<yüÏ1ïH@†aО¼ÓŒñž}*}ŠÀá~PË`¾¾ÜvïJT¡a“¸çéùÄúb",/Ê7nÈ8üþœ,Rm^0ýrw_NüsÓ׋1£pqòŽ™äþ¿æ…@$@NŸ¥?_ëúþ˜ì\gï`g;ÿžÀsÖ…@q–'מÜôäÿõO±²Ib\ÃíéÓ4…r6‘òàås‘Žùç¦8Î¥ Âœ0Ï8qœÏÐt´»:‚Æp@õãž½?<ý*r¥ƒNYŽçÎ>ŸÓ°'µƒÈ^N9éÐõã¯ÔÐXS’¸ e‹ã¶sï€xçýqIåñÉ'hôOúœþ:f§ÙŒn 9äROCè;g4èá’i5y¶ª¯v=9'°Ï×ÖŸ›¸E-÷Ž3ÀÏÌÏÿ¬Z@ íÓÆÐ0>ƒô©Ç`jÜÖòÁ!ŽhÞ6æÞ„‘ÁéÆ8÷=j<9ä dãžÝ»öZJÍ Vjèƒbçí8ÉãŽ#K°Ü $ä 3ŒgñíÜÎxœ)R'=‰=OÇ ç¸íH…냃Ӓ9Ç|‘É>çÚŸõý~€@+»€HÏ?‡Oò½)ŒÃkgÀóØŸL“Ó§µ8_Ÿ ì´6HË9Ç=>¢‘T°Sòž2YÚ3Ó¯_§|þô¸ä:°èO^ä8Ïý(òÂü£vìƒïÏéÇòÅM´ü¡BäôÏÞ>œzž¹=¸â€  ü»z`7^¸éþIÉéšAµxÃõÉÜ9ý};ñÏO^bã8?{8éßüöžµ9B0|Ü éÿêúuÎ)“ón<òöéŽÛG ã4…Pe‰õÁ'·=9?ýcH…8ažpã8Ÿ è=jr¹Hùpr¹ÈÇ|óÓg?Ò”©`Ä“–c¹óϧôìÉíKp Ø©Ô3‚¯õéùçéG–ä®bøíœûà9Ç\TøƒÈ^N9éÐõã¯ÔÒlÆ7Œr©'¡ô³š`K´À=8Œ“øqßüip>ñ;AèGË…p;~ÿÎ\2®Ã`Ž8äžzsÓéýiqó1Œ8ýxÉ=? Ðv’¸Ãð½ÊžqëÇSôÏ¥ÁÊ‘ä0<nœc8ö¯¤eÜÇs‚¹À$}ãÜoóÁÎOWáCw=HúãÛÿÕ@ì]Ÿtíç<öé´c®{ã×­.и`ç8ÇsÙ@ôÁÉö>œJÈÀÜ0y=€ÿ?.Òj˜Êç<ý™öéFÿ×õý~%È6|€{(Ê€ õ'ÓŽŸýqJT ±\c¦à2òœñŒðxëRàpW“· 3Âêyÿ&€£pUbØ$–^3î}=Öž FPò¶õcžçÎp¯.ŠÞIK$VìÌ̈¥±Ó¨Éýuö^´ƒËiÉ–@7'äÝëÓž½û˜ë¯QB‹H©ç  3’xþ¿^ xµóˆGJJç‹_9„t¦¯æô_×Ür6~Õ/îÖD€€Né$u=ÆyïÀíôÆñøjÖök5Ψ«&>dŠ"ããæ$ž2vŒcŠì´[M£Î`žÄŸOOÄþ”ksü‘Æ9cÐcúzÿõëŽYž!Úéz/ó¹Ÿö…eÏ&“òÿƒso X©<ÝŽzp9ëÏ'Žõi<;¦(_ôv$`nguÎ;õãžýU©ÀqŽ8ÿësÛúƒÙÈHq›-ŽŸ{üÿŸnc1G7÷žSÆbe¼ßÞfÃáý5:Ú)*U9nÞ‡ëùã¯kcLÓÁ$Ù[›,|µì{žýûÖŠÄYP…º1úÿžÿZSÀÉ ŽÄŽùþu“ÄÔ–²“ûÅõ‰½e'÷” ³¶¶pÖöÑFàmÞˆƒŒñ©¼ãÆF=O=€ý> Ý~¿Sß×ù~H-ÉÉ-ógž§ÛŸÇÿ­ƒYÊ¥õlÆU®îÙÍxž1a¹d[òsƒÓ9íœç§?N9“ œn# œ“Ðçžžž™ë×è÷Zj\ÚIïAÇ>¹üÿÎkœµÒaÜ C¾RFX¶yô£¦½kÓÁãaÊ›Ðõ08ÛSå[£šŠÎ[† K+¾NrÏÆOlŸÃ?Z¿‰3H¾yóÍŽ 8(ÆsÇóÏl#‹M³1¡HËv íÛ·OÏ(ožb«¹Ù›¦sŒ<ä>µÕ<}g¢;kcj¯u=NRÓ¡·³ˆÃaX‡\ôÉN:x÷É#$±ËrFyÀädã©ëÓŽ;uwѰχkÉ “Î#‘Ó8?úÜÑxä` ŽöÏëÛ½z}YT¤Ôž©˜ ’6¤õL„ ŠG{h''ÓøÀçÛŽNOº9#»8ïÉÎ2ç©x óaTcå?N¯.”ch<Ž[¹ê–=ë¼í" •w0wryèzûþ¡A9c„ÈÉǦp}øèõÍJ± äô.Iã¯Sþ… ä»rCBŒäuêOä8úѸz(%¸¿`œç#€zþ¾ ]ÄmUl}Ð àdú~§¿LT„nŒ€v~Q»¿|ŸïÒœã;C`ƒÈF8ì?¿þ³úþ¿¯˜C;³žIcëÛ“’ÜRíUùˆ8SÁÁ=øÀéמóÎEJKufÜORN3ÛvÉ?…J·,ðK`ç§\v4_×õø Q“ÀÎIõ£i œ`Álç§çÿê©1ïŃð¦ Û¿ˆs‘ž=;óþ~”œ…# <ãŽÿ•IŒý(ǧ^™¢ÀF)\"ñ’3øúõÉÿ=( ŒqÜžùëÿש œ~8£†6ñ÷[w#55¤K-ìÊ !‘Cp:òL}E3Õ‹?´-z`JŸÌTUÒ~Fu]©É®Ìî>è§~8è9Àè9ý~™«66­st‘ôUåÿ¯ÓòëPÄ€ —8ïÎ{ŸoÄtZ]’Û&æo™º÷ÿ=+â!gcãèR矑yU`ƒl@ ÷ÇùþµÌêSyó–Œ}?_ä>•µª],p´J@ÏaŽqù~¾üu®l’Ì[£1ëøã¹êNÝtªú#lTÓ\ˆaã=ùÇÔóùiU ¸\ä’'ßüþ¾Ôg€@8þOÃüööÅMf£íqþ»×$sëúóÓ¿5‘Æ‘³Û¼*¤l#;˜þÏZ¯,L­´L Œú¿Ï»æc!Ñ'?(çäÿõª2B§“Éý~µ‹}5·,–¤xà¼c·ùöÿ=—kòOËôÿ= 68>øÇÓ¯Oþ½J…Ì3’:ôÿ?çš›Æ õ»JFŒôŸçüôÅ9íá°–T ±É`œ“éõnÎ+TÌ‘©Žœÿ_Þ°µÒÅà`øóÝœô8üq]TŒ¬G (R•–­™—s4²`äã’sÿ×ýx­?Û+LÎÈ:¬Xdã=?>üsïXéó´eAç…úúþ_Ÿá§itÖˆB äã_ðô®ØïvwR~ÿ<‹>*³‰ {H!Ð+Ð9ööæÜ€6äääž~§Ó½v·—ÒÞNC’½ÎGÔóëŸz〠g$×­–;óü¿SÒÀÍJs·—ê0. ã'úsþ}sõ¡T‡8'vq‘ÉýÏ_Z~=yü(Ûž:çµzÍ\ôH¶†;OG­8ŒŸ™~£=?ϵ<ƒŠ1é@ ÁÎæÎsǯ¿?&Ð8 < éÔžØúb@8ã>”möö‹ ü½?06ªqžƒ‚O©?áúâ¤íì(ÛØp:PxS´žØ¥ÛŽ¸‘î}ÏøÓÐ(U$ G=O?â{zzÒŒ8Ç$ÿÖî.´ì!…qT’:Ocúѳ8ÎO8$çØzÓ¶¨A•ëŒôàpyü~}©HÎNr@Á;»œŽ¹õÿV? tlðÈŽ™Yæ¸#ž?K·¨Ãð@=qÆ:œJ6“ž¤ðO¿§áéÇzVMj &¬ÏSÓ´Ñþ²e ‡ÐŽ„sÆ8ü+^{¥3òîo›u#¦xõ?˽T:”kÄ`핈§àò3Ô£¹¬‹ËæŸØô¯¯çÓùö¯‹mArõ>]Ê4cÊ·"»¹k‰ó’Iêqî8Çÿ¯úÕUÁÆ::Ó¿õöç­8Œ¸zc#¿<õýrE!ÈÉ' ËdñÇõíéëŠË©Á&äîÆõç¾3ê}?çô©!\L£r#¹þ_çÜdñÈõàý}©Ð|“&À À9'ŽŸ˜ÿ)5¡-hÍ“¦àHã'>¿ËüúR˜L»BŽOz vçô¨° `cƒÁÇäÏ¥Y…‚±§~LÖ+³2‡½¤ˆš" `ç¯##?ýlÿ/ ¦·øpy<Žÿ«µ¶®ÒË{ÀçüúzuªóC `sÀ$qÏ^xÿõJ·NËCYᬮŠ‘!bN7z‘ÔÿŸò*[­7í°$L† UW$õãõÿëUˆ`à’Üvã¯ùÿëw««ˆþ`¸#‘œ|£ò<ôü«Z0´“gV+NG'u`–³yJ2Ê™ÃÛØœcñïPOX@à‚FOnÃƵ®¤óîåuìÈÜF}= gÕBdãŒÜ‘’0~sÏáÓŽö´=YEYØÀ¸ÊA6ÒTá°sóõõÏáÏãvÁ8Àÿõzž?È®‹QÌpHÀú)ÏNO>ßΰ@!@ù½þnO>¾¿®N:W¯–/ÝÉùÿ_™Õ—E¨IùŒ ~§Ó×ùž† sŽ1ÑAü¿_ÖŸÀïÐ>ƒŒ’F?ÏA†{gÇŽO¦;Æ{qúúV=<#$ñùdŸóþ ´‘œsù~_ΤÇÌFrAÉ#ŒœvÇlŸÊ“hfÛÀè¨ãéÜÿõºÞ3‚@ööôÿ=)vC€>¿ëùSøÀÏSÐc¦y$ëþë•,ÝÆ;ñ‘úíÍ2 e{R?J^1ž9$vãRr>PcÆôÀöëÔÐF@ÜIQÉëƒÏ_×Û¨¥`£*£8, ryÆ=»{wü©ÀœnÉç ×ÛÐþÄR |ØÚÇN€þ=‡åžœ»¯CŽrps׺ç×Ú˜ ÛØsÁÉÎ<œ~·úPA'qœœc'×ÿ¯Çs’x§9ÈÈêrF×óî:]£;°Ißá××$Ìäàç=NGŸ÷º~$z L```cÜqþñùzŽ´wéŽã=ý=8éÀãžœ¯pnž~Ÿ\zzg4QŽÀ`ãœc·~ý;õ£òïõ©?0žzÉäçõúþ]*ìv™P@#ž¿SëÏÿ¬ûÉDÎ0r3Ù ÎrFI'®?Ïóâ„ù\¤ ‚Ü?çëWå¶À< õÇOÇè*„«µŽyç$“ƒœúãŽÿ8£”sƒ[š J¨<†Ï÷Çó÷íŠåÃÔqÇAëì:ãüå߃Ԟƒ¦?>)xÎâwüÝÏ_Çúó\Ç § ›”dáq“øœ…I³q<ŸÓÓô¨,Ã%³Ž3»óšÒXËp«»£ŒäŸjê„\‘ìQ\ð» HÀ Àë’qùZ“!þñÁâ§aÁ_”zœdÔr¼Œ³dã>¹?çó­ZåFír£šJ&$J`78Áî1ø½9õ"£wd7NpGÇëïbÙ«%·Í<€€<ÆÃ=y>Øàýs‘Þ¡˜­Œ01’2q1ÛÜdþ98éèu'îœÖ° " üÛÆy•˜«Ó3ü'r;öþ¿­{ØòÐ^g£„-%æ0<2zñ×¹ëÇo ô˜Gñ ’yÜcØþ|÷§€§¸!‡>ãëùËŒŠ\näç8àõä÷ž3þ9gHÀ¸À$ p9éÇoSïŽç¯r£+Æ2¯¡úÓ¯ãéRžÍÎxÏ'8ÿ=}³FÜžFrsßüÿúÏÒ€þósßÔúóùÿ†hÛþÆ8ƒÓ±Î>™ÏÓ.À# gÆÞOR?ÉõÏ Pp;¯¨^>¿ŸéÇ7GAÔ†œûúf‹tê>Díò®IôÀ?ãúúÐF¾ON}zú÷ööåáv¨ 1€9<þxÿ‣Žn¼ÓÈp?.Zò‚Çåäç·8ÏoóŒúž´„¼pbO'ŽOÞÞžÄI°7=Àï×ןþ·\Ò/8`}AÈÏÿý}¸Í;Ü`Ðã¿AÛ§O×ù‘IÔpFÒO$õõ?ç<÷=ߎÀ»zœÿñT§%?‘ÿ8õü3Î3@ Á^}úcñ÷üs’ò‚ÍþÏ?¯¾^U¶©Ž2@8?ýnßÏÝ/TðöŸo‹› ®çb2òBŒ£Ð.Oùû æf™‡Ôi^+šoeþ~G©•åÕ1µt‹q[ÛúÜ_ ‘sm:Ìn—r8ÿÐOùï[‰c$ŒB•Î p>™íþphÓõ}"ùž=>Í-ʨÜ<´RÀú<ãß×ÞµcŒÉ&FÑëƒÏ'©#^Èø Ù–"¥vä­sÇÎò¬=uH(8­4oɵҤ-ÕŒóŽ»|~~ùÐsGó¸îbsŸËÐÔö¶ìÊ3ùõíœþu~_”–qìs’}¿™ÿJ'mÏ>8JkcâɱÔ;dg¹úßdÍb¬ç2‘œàcßùWOyq‚Npy'üûtÿkîáòÒ,`sƒß-Ú7ûÿÌÙ³ÓÐ*î.ãÝúÿþ¬VÓãœpŽ{ÿ#ôµUÓœ66œ‘Æwgž:ž}Ï´C©\/ÎÀÀrF{ŸÀçüs^ýTKÈÞ›ŠVŠ·ÞPšÕI€[)ÎsÇóÇùÅe]åe,O\tãÿ‡ÿ¬V½ëáyç°Çæ§ùÉ®zí°[¿LuôþŸç®8ŠòŠÜç¬ï¹Ÿ0-y!-¹°Š À8ô#ºƒøT°TÎç,»‚MÙÇŽþ”ùŸeÑÉÎüAüDŒdç“Àö#5FîçŽf9 ç=A‡~ü«¦Ÿ²Ro¡ÝM.EèsZ»CöéÞ¤f0&TóŽã©üNqùVºÄr²…È `Ä€R Îp9÷?Ž„ÚEµíÌò½Ä®þkÈà‚F9é€ÿª›ý…dwÊA–ÀÏoË¿·5Ù„ÌÝj’m~GÖ}JŠ¡ï$ºhP]e¶bÜFYŠ¹z~?Ðöìñ«!%ZfÉôéþ}ªÝ¤¶Wœ ylaéמ{ªÊ«´8î=3Û¯?‡>ßGN·‚·õ:ç‡9íôõý}èÛx$tÀ9ÏOÓ§^ÃêiáIU c¯`:ÿŸÃÞ‚¹å³×9#§<ÿŸÃµ ÂC6õçëÇùî>ÜRã8$ôÆ0qÆ3Å;i8ÀÇϧ§¯ù縠tv“Çù?˜õ4Xc1Œ‡.úÿ>¹Å(ÄØ ñüºñÞœŽ‡ S××רõ¤û=ÕË­!’iËÔ±§¿¯ë'OMÔ¨ì‘ÕƒÂTÅÖTiîúôK»:m+ÂÞØ$ú„Ξn&åä‚IÏ\“Zpx+E…òâyò1‰%À÷ÈÿqsÚxŠå\A©Ì€î "» ã® Dº&¬XìÛ¡‘ˆûzWç8¹×ÅÕ•Y×µú-’í¹ú&+xZ*••]äŽþäuã°ôè?Ïb*FjÄI)t)jzÃÁuµ­÷8l§¨Ç¿ÿ¨V|úÜ’Ì% Iä€1ÔœóíßÒ¢×HûZdË 2Hþñþµ‚läÔ""ÚHnÃnÎWôöý>µÕF1t’žˆ÷°WŒSÑudúî ¸Ù&âÈÁÝ:zýfG¦ßI’4ܘÈÛ Æ1õúÕ¯øGî6‘æB ž~lcò_óÒæŸc¨Xƒ—¢*XÆðppFG§çï]*¤)ÂÔåSìc:tiÚŒ¯êeQï·8Ï;œr}9?…6[+»dÝÏAL>!ùM£ ä0ó=}N9ÿõ×N‰¤þÓéý3Ÿ†­ŠKš*ý×ü9’#èH' 1ú`sôôâ2¡I-ߟb~§ø÷ȧ´‘I;ùjbLåTœàÏ'“Ö®Zé³\¢±Pã;˜¸ãŽ;õÓë_IF¢ª¯ëÔð+ЩF\•™R8$ÊÆ»œŸ›o<÷¿Ïüô9pÎ{ÏÐõÿÉ£è~¿çßüóOpCpAë–<“þÏ?\„`cw¹ÿ?çô.ÇùÍ5ÜGô_óþML¤¢œžÅ©%+·¢FŽ¤VóÊ,Rùä~¸·¦Ï?ÅèQ …"Zª7tz÷¯–F•·¿ ‚›´ûuÆkà3¥<ʾ“´#²·ãóüа/ìi'9ÚO}6òß¡ì3j¶Ó¦½¶ŽP@*Ò€GÔv¬ÝrþK½TÒÚÞf1ƒç 1ódôîã^f‘™fŽ(ws´*®I'ÛÖ½sIÓWJÒá³Få;w1êsŸAíŠùÜFž–W¼»tÐÓƒ¥€äù¥}žÚŸ„´‹ë-^inlçŠ# J÷,¸çüqÝaŠä‡8è{ç¯?_ êi:œàu4.áÏLžßçé[ÒÎw”?åóœ$ó*î»—+i+[·ÌÆÔ®|¶xÇ|:Ÿóþ};9'v2ÄñÿÖ«ê×RkrÚɶ&}ªÝÀãõü{ÕtÖ¯ãR…QÏ?1Ž=1þMwU…JÉK§cŽ¯f-sÂQwévŸåm=N—< ààpOùÿ?Éx sÀ=ñÜÿŸñ¬µéøó-·6G(Åx®§MÓ¥ÔtØ.ã)š (Ùù~b?Ò¸ëAÑWžˆò1|1ša5Jz^×M?Öÿ‡©S®9Îy'ù|ŸóÊmôzçŸ~ÏøéË£^&px;_ ã×äVlòÕšxåDÊÄ×8=zõÇzÎ3Sø]Ï2X Z¿î姓<ãúþOëIŸ@FrF§ôü鯘˜t݆el‚özzñþ<¦Ü žƒu<ûøÕ$ŽiÂP—,ÕŸ˜»BáŽAÆxÆyÍ(SÉP~€‘“éõÿ<у¸… ã9ÇßáùSò$çüCa,ÍFê»—o=±ƒ×ŸZȱÒç²¸ó «·¤Šz‘ÈéŽÈïÓøŽâ+Hl¼× »Hž3ØÿŸÊ°F±c•Ûsžp˜VëëÓ­z”ýª‡*W^‡ÚåÕ`’Š½ïÓÍ¢¼šü(YZ)–EnT€#øqž:UøHIc=[2\TòékwЦ›†šMÙIfvŒç‘ÇCþy7áø{«Æ>{@ç=|ÔëÖµsÂS_¼i>ÍŸIC/§$½¢åoù¿¯[ü×j—(Z…‰ÆøùüqÆqŽµÖY|4ºœG$—ÉG@pG`àƒŸZUðf²€±EP:,È?­vz<¾•¥¿åcŒÖ&Ý*ÿ±ÎÇ×·â¸qx÷%†’üÕˆÂÓ¥M{©¾×ÿ‡üÌ8¾iñ ÂúV?{s <úõÿ?I}àùmíš[{–¹tûѲ`‘íÏ'8ã¿éWŽô¥c˜/3ïñÿRŸi{T˜n|ùkïþ׎šáê*‘»î¬ÿ¯¼Ã—âñTÕ:°Ñm¢ÐãÎ>ñÏâ?Ï?ý~¼Ðä’HÎFOçŸËÚ´õWE»Ý=´]3’ä¨Úþ¹¸ëž:óëšÎÀ<ŒqþÎ? ý#/ÇÃKÚ$âú§ºÿÙÿÃ#˱)%Z6OgÜnÝÝ{ŒcÛ¦?Ïô üßÄ?¯äÓˆÈÁϯñÿõþ&9çÿÕ]ÇàÞ¸ÿ?çð ïtñN <‘ž}?ÏÊ·æÚ3»¦1ƒëøc¯ó§²° XÝäªÌÄà2IïÇéþ5ØXøVÇìq®£oæÜœ³~ñ¸öã?ŸáYZºm”‚òêà‰€Â"«ax ’{ñüýøèá$Ò÷ñ3dúÆÜʾ'‰18úòú¶”ùVíFZ¾ËM¿7øû9r…íœÒ—MVŸðF è›ûëÿ=üjàҴпò ¶öBÿ…Toéw ›i ym“ù§|UoøK­:ýžàÓîõüë壕fµUýœþw_™êÏ2Oâ«ÌÏ]Zé>M¶Ÿ6·L7´ÐÆÑF@ßž„t÷®XkZ£>£tIõ¹ýjÅäúö{™®¼„³P@öÉnƒŠ„iȇ>|Šäÿfö¯{“×¥MFTîüÏ¡Âæ™]*J2ª›êÚä4kZžÂN¡vOýûu«Z]æ«©jv¶ƒS½"G±pC±öüª¨ÓŒÊøÏxÀíõ­-Q¤j?kØ.[Ë(¡†Ò¤‘ÈÆ}üMk<«àÕ:ZÛM—çb±æW Rpšo¦¸ô¼¶zãŠÏ=³Ö¹OøKŸ8û^ÿ½8çþGü%ò?У ôiÿŸZð¿ÕŒÓþ}äÑÿ3便†þoÁÿ‘ÕåŽ8àZòßOþ$»1’ÛTúdê+§o·$Ù¡ÇñÞ•ËÞÃåÝÅÓ†WšF|È\ž‡·Ö½ ¿‡³ 5ªS¶ãþg§•ç=YN¤úväbªç¦*vÓƒŒãîö­Ain¨ªÑ«°ãÙõìÏ¿d·ý2G Ž_óú×·ý‘Š¾‰}ç®ø·/þ÷ÝÿÜðª&¿„%‘ÕqŒyÿ/ç]³ÃŒ7ÆŽ‘¹Aæ¼ïMºm&éî-`ˆ;!FfÜF22zúü«SþD¾\»§¯>ÿç5ãc8cV³©µ·SçsÛ ‰¯)ÆövÝv:™4ûIn·ˆç…Û“øUKÝk/Ùcaq±Šÿxã€r}~•ÍËâ=RVL‘ }ÕPz¼äÿú¿8×_Õ3Ÿµ’;áþŸçëJŸ æJÏž+æÿÈòg[/“÷©'ò_ðç3¬^I¬}.ÕT[("Îí ç9þèªip¨ Ü u®†OßHf•#y$9,c1=ú{ÿœSv©÷Pëå/½»f½å’âífã÷¿ò>› Ä™^ h¸¯$¿ÌÆFheI#óYNÓŸPkÕt a5­9gÌk:œM¶vŸ\ÇÌ⸠‰Ÿõ1dŒcÊSÓ¯ùô©!’[E+ ¯<•F+øŸóÛë\Ø®«‰¿$šÛwþF—a1PJ4åuÕÛüÙé¹ç’xàRué““Žµç?o¼y?LàÊçŽqõëIöëÌŒÝÏÆ0<Öýyëús\‚ëÏÕ÷3ÅþÔ‡ò³OÆ‘‹êvp®0|ôQÏ»ÿçëŽ$‡bS–ãrk£÷‹ÏÚçuóXßóíP¶öÆâN;±'Lÿž+ÖÂðõjPP©Q5ÞßðOg Å®.ISæ¶ÚÛôfOØî1ÿÒ‘èóÂ¥‚+Ø_ o3!Áa°þ™ïWÂGÊ1‘Î3ëÇùÿõsÑztî{ŸzT¥>zulÿÃÿÛâx®šN•l:qÞÿ¸Ì ‚1ÉãéGo~ߧõ?…?°éŽ£4¤?{ОŸ_ϧç^êºZŸ íwaQq‚ÿgüäýM`cðúã“ø:påïßÛùþt¸Ý€ àäŒç?矩§ÐC0yûç·jR ùB€[Ï?çš^£ª€Ü€=:gè9üýipàAœÜgž;õi ´žpN O§síGRx'ÐÉ?‡ù矂NXG¡çóSFG^ƒ¦1Š^ 7ä(#·¿?§OÓ¹¤Û£9ëóþ•?;‰Èìq€yíþ‚€£¦@ì}‡ùëõÆ:Ó›{ãv9秷×úýIç®?—ÒŒóö°?Àÿúø¥ÆHãØ=úÝ}=;÷fÜçhcž7c©ÈÏëþµ@ÀëÜpOç­; ‚~Sø?Ãó>ô»y9ç8#óÏ_צqHàŒœzg¡=ÿÃðëF +Á< ñžÝ~¿áŠ\uç'œôä÷Ïéúý)NI=3ÉêOsê?.>´À`cÈàðýh €NNHÉl’Nxúÿò¼xÇéÿÖéëGVÏV?7®Onþƒ?•3gž¹ÇL<OÈÆ2¡@'¶sÓüþtñÓ'qè:}9íG!IÏlñÜóøŸO΀·$(Î`qÏù?ÎŒr /A÷qÓÓ>ŸçÖŸœNÑ´õöý­ à ‚:v þz÷þTz€Ý§®9À真_åþ»I`>aøtëúõ§mˆÆ}õ积>Ýø0êqÇëùšg¡<äŸç@P\ßóýiàsœœãéø{þtœ `dÏ?AŽþ¸è¸%¹ Äž@9Éü)1èqÛÙÇN?N3Å?¨ž3Ó¿çÈçùâ“8ÊñØòõëëùœ})êx98˜Î>¿n悹ä‘ž9<秿NÔñÉ-ÇNz‡œŒPA‚x)úq‘Ø~­73ÆY¿™ÿ?JOº3€;Søc·õïO sœ€=síƒÔçðõ£³6H휟óŸ×éF€;nAà݇äÐÄrÙ\}àN®òǧëNÆxëõÇcÿÖü©y<äî$sÉ9#×¹ëÿÖ£úþ¿¯øФg žvúäçÓ¡Å Æ9ïÇôd’:ÓŠîaœóØŒžzõãÀÿ&Ž£'œŒòGSÏù>Ýø r@û dè?^ÃùRmþlŒñøãÜzÓˆ+ƒÏ8úûcéëÚ†=yÉ~¾½¿c¨tŒò$ã'/åÇ¥#ÏAÛŽú ~'¿w·Ë’ç<Œqøúÿ/ÑÚ r2xçñà}ßÿQÆ `ðÎyéúýáÏzä÷=Ï|}pzœþ§ãã<1ç¦9éž?ÈéÅ ÇŽ˜öèséÏÿ¯%˜'Ž3øqœýqÆ}Oë„Ú߸ã=xïœúŸÆœÚ8x†ôë“ùþø£© äž ÉôÁüÏ¿^0¸œg“Àÿk¯ùúz É/œ~¿‡=ºž9§cgœt’}Oôÿ<u'r3ÓðǧÓÜ€7<)Æ8íý\PGb9é…îqή¥<ŒðA#Óú`þ¯â˜< Îr,úÉü ÆGÁÿ“‚· ÏM£åëǹþ\攞ƒ$rFxÇà¥;t½³ÆO'nçúõôJR¹$`xÇzþ?‰éš^¤ëƒõçü(ëzäõÎÔóJÀ4Œ‚x¸þ~ÞãüôIÝŽzŽ¾Øïý)ØÁÉn™n{óúƒÆ}½¨Æ9ù±ÁãŽ~Ÿ^xÇ>´„aŽTõÉÀÉíßñ°â“i )Îx¼Ÿóž=E;åà`›×˯¯Ò€3¸ò23Ôþ×üúÓûÇ cŽ™ÿ'Ó¦i1œ 1¸çuúñŸ­9‡ Üg vǧéG~@éîyç“ïH€ Ú9ì{ÿ,å@±œž8wÏ×·OLt§rT£dð{œZ8ê9ô8ãÓ¶:tü:f˜ÿÙ<u'r3ÓðǧÓÜ€7<)Æ8íý\PGb9é…îqή¥<ŒðA#Óú`þ¯â˜< Îr,úÉü ÆGÁ>//"5$()˜ŠZ,o‹›‘?¥‘’Ô<–—–?&ÛnÐ?•ZoÌ<“¨'Û&'š×I<9$55ú!.--dÈààÃ-Z v(ܱ`€B> HðÂ_ˆ‹"BhðçÂ… HÜ#v¤E¨P­†Y"Gá±Çâ[$v‰LˆiS*Ëþ 0àmj”ÈÕˆF-@ F„%DB˜Z£_¿e9¸åcÆ*T`È€AÁ ƒx ÀÚfôðáƒ@á"hñ"Aˆ6Ü@‹tÒå´0JZš³¦(š#”’û´‘"‡˜Aä@¡Ti §%¢jYbƒ>®"HkÐÃŒaè @,†*vä^¨ÂCm± ~(›Áá‚>>¨õÀC‹H=žÎÙ9*£iBe­Ù£—2Y˜8ÂÆL¤2UÈaá@±b)R ˜?"Bi~.^Ȫ[ÐXÚdé  006@` 8 :  Œ…ÛC3ÐÒÕ.þ„P‚ÍL§ÌJÐrtaœ£ˆ%&X³I)*5žŒ ØpYe(XVYò¡@€h!Ô–Aµä6€6À€“ D)å”Q2˜ „Ž%ÀW_½f‹ Qe¸ÔÝaà°M64vGÊNj¾É *mĸ“2hˆQ\‚jÙØ`Ûˆ”Q t‹Wº mVXaƒ0(8!jJ¡l°dm „™aA¬9€ÀGv#™” žvÓA☉Ò9%ílR †Z`ÁÈZpèŸBBPCGIÚÕ©VJÛµd‹à„Bèm©@TËh:– þ©Ð3ø°@»|²’.ºH ±J¢f;Óý¤¢`)NÉ DˆÁ;ÜlÓ§ åý™Â1äóËD@ƒŽ#PB’Ç![ž«›Xøð À&înº €Ûq*øQàÝÊ ½öÐI.µ'–”ÂØOìæ’9mlãȾìTP P$_xå@]Ìð.rí¾6Ã^ i ¤4DÛBa*$sq¹ÁìPÌ(äÃ(TF#õî݆ß5¢ÂA"²:rÀ„-Â:pF³'Ÿ˜¨çg³ù„ í¹¶nmKʼÀ 4U@t¥m…éƒ ˜^k.¸º±›\þ Pd/1¶bcШM"Fk×wÖÔ{N9h0bI3¯³&Û`²§fléjî†u¡ié’Ks¯íP\©—’U*¦_Ù")-ì{°‹#Dw|z&¬bpýŽ­äFvú„{cº£Õ:ŠwwN%>»È@1lÃ(@ ¬·œÕÕ 9hF@²€HJ!å’ݺTp)ܤŽZµp€ BÐA6N톂e9±4$&¸€e¬¹´ ? @ ¬ƒ´€@B`ƒ›s!Ç9€åx°À“nÀåZ@è¡Jè%R,¸À!PäÀ;ð*LIþõ¶ˆÔIZK#` I;ÿ È(œø ÁRzr`†XŸ¥þX2' Ú€‚„R@Þj jrÈú2@À @‚4r`ˆ‰°]0—ËÀâ—¡'•À8`BpáI@ "ÚЄ*¤!'ADÁNÀP¨@>Xeä1^ e@@A \€쀌©Ñ`ɧ7^` öf€¼àÞlÄ"‘¬E&ð!ÿ:`h>øÂo쬰’&° ¢GàAR™A‰.° ƺ€ àxIéµ1öÈ3IP·ÔE H^$\˜M€ÓAœãîUÉâ…£E9iƒ3¡¸Á$n8&–蕨HWb ÆKÀQZc&0ŠFue´þ %ƒ›Q¸£ÿ½dÜÑŽyÇ œí`6x…iúÑ$ ÉÅVÂÇ®³t¥·À5:¢‘ ˜F$èf ÎS?ïÈjq6¤´%M!]NxÁŽó ƒueÄŒnˆzx¦0Ñ4\Ñ”EMåªÙ©h|¥Þ•B #`/ÿàK´d@‘½{ƒ£XyCÃD¢¨fŶ·|Síà7J+Ÿ TQć0fíZ³ørpq‹pƒ.S¹ £õR’À¦*[Ô"LÇi—Af€¶´ ¿‘Æp†›w¾;ËtùÅÉ„QǸÀ?•¾0ÎàéJvô’ þõYß r©r]J@²!Ë’¬8 ›f‰BáªÛB2Ä•| }9ëIR" ¦¯NHMI¯`d‰JàJ†abëuXÃêaUš‹¼ Ý˜p§hª%‘ AÝ‚’æ7¯ƒt^A¡š ìTð®ýÞ‚{®* È™?íLâxŒXѶé¤z²ˆ‹ëŽ9y†=)Ýa)0€r@|Ë Ÿ3õhb‘°Åu]6Ÿƒœ%*1àAŸÊÖ–NÙ›Ü-­q@ h 美JvRñÂÂ5fwžI&šÚCJYÊ*VŸÎÛ@úƒù\±u 3è2>¥BvÒ-¢€ hþSb*¤÷Ñ5¤?ŽÀJ¿sp/² ³òmé‘&<mèÅt`@KÈrKÉâ0Ù€T$nÁ¸†kÀoùvk¥J˜ò)µ¡Þ7lòqOœÁbn1)”¢.]ñ!0‘0©’Ç ÊQ90 MÈwÛ¡iŠÓrÒ?‡) \&‹U<5adE–Tjrx ,6 ß· poµXð%ÑÖR&§./ a>  =FRÃid|²þ˜À…Ùè@<tá"”x™K@»ã+ŠpôNSMT1–ú{9¶û#T.«c)Áõµ ‘5±Õ Qk àq/ €6Ðlæ·s‘¦&18.Ñ4b '1æ×´{cœñµõñönV÷oV*5s¦É}äÂ.÷v¹pŠt±k^RŠ· ºP¿ -7†Œ,Û 3Û¥ÃÉë˜Ã8Ч="|Ä÷žÁ(ÄÛ(5cú;«O”Í¡¡0@*âsZzë2E[ Á%Û&¥Ø=/08l~è ˆ¤Ôq<Òð4QtÁG¶æ!|ˆþ²ÇW5$$0¥‘VuøÛAvv¨)œ3cA!™B!Ä\•Çí²5ïyæǹÁ’"Š`°§iØtD{BŒc«œF'(=£¢O¹Pק5‘—” Á:[eS BÌz â-e'zë{BIé.GØ!!@Z8Nø&Ê£=C;m1Ù/Ñ€`ÇBÐÀ‰4|J×RÛ:kxQ¦³9˜Ç OB}OÒ)×7}r}Xv¥Âƒ¿ÖîƒÆÔAjbàBTë¡v²1‘Ü“v”¯Tx°7õ7|@òÅГ±û0Pôù.äby¤IÒþSR}Y=}-m)·±ôF `Ó¦7&ÇÓ@ BÑ>li^Vû&*²µù’jâ'z\|Žd|òA²úxÁÌÀUÕU*™÷$Ö·ÕWrÌ;È%Àv¶` ¡F“ œÖ÷2L)¸ó÷/íä~?¤xI,ÄçH @(Ã'|)À|M$ÿ°Rt2±}_ ×y†­Ò÷*ê3Ç‘¸Ðu‘P©žl0±WÖ5|£hY–ÙµÝVfE(äJ®ˆå,¸(Dò“éK ^ãc)ƒÍ-ö| ÅÜ-âua—Ô’!¬ß(Q|·ƒ6ñ~£++–”iNÈÙÁò…€BþUÇb,SAõPË"ð—ÃËÚXJØ Þ’€™×)Ý_V.bóïrzºÑ@Ö@pÌ«,Rw—¯×<\j"ø=aûâfoÔ'U…(~d5XÇË¢ÌÕ’¶(Þ.½ªuÓ.².UJUÙ%Ô²á à. Z8/ºs¶#3q/© Ý°Ðeù´Óà{60L^è©RóFÊ2|òÁ‚¦ak—3˜“ Rùýp6kaAd±ª¹Ðо°/Ð!" Ž¡ì-€Œf©iÆ Pæ x0…è9¤7䤩–¬.¤0ˆåHJ]5 Ûª¿¡Ž°b·à"þ±¤à* ´Qr¦Ä:§r!'Ók-J·²’CÒº$ $€ð6`áŠÃq-³žç1ƒëá@¸²{3‰*’ –ŒW˜ ÔÜTÒP/Ã<~ó¹Íú¥XK)@Ë¡yk¹†$ˆëríd-ð¡¯->'”*±Þ·¸$§$3®ˆ/`Ém8úîwùNì˜Ù¼$RÜÖñ’·w8Ró¨™à©¹Ä‚ùÀ ù—ô¶uí¢S€f&§D³~^mÞWT!p37§Õ¼h'!_…©f߆Ѵþåj%¾XŽH]ë`I\YîÑ(V7”p±Ï`Á:BüU´A}ÑÉqo2ð4…:¦R÷¦ÔŽd%‰-#Å#ƒsiƒ¡j×Ðzu$CÉXˆªVfi´h¾gM°Si 4ãΖrbgaÂß³ LÉ:â3>¨ã9À6-€ùر€âã;ïÔÉjëV³'Š>Ghp¬?ÃS©[ßw5Â…­@¸©Ñ­±u® ‘÷‚Iù.c7äSB¦Ävº¶Ïß7P+ô /’;LHò9Ó](ÁÍÐPœSï"´,¿ÒwÏÈ„âŸU åâÊC¢- ¬2ƒ$¶$/8 Êƒ„þøË@°2ª…j§š-<€Oˆf’âp¼ët¢ZWUÞï÷ý­À½Õy|V£Oh1˜Œ3Q½Ü07Îs:ÿ_âÆï¦ç„Â"§`Cä%ÀÃgg‡éã! EcC#á%AÀòÁcrGAu C``@EafÆã¡Å¥`…ƒc…¤âäG΄§Ìw¯Â·‹kÍù¬"Žîù‡Åš¥‡…¹°ÛÛ[ûÐ¥DÃ¥!Ô!ÀÀÁáÃÁÃcaÇUchhuu iò€RehåÃC‹$J\Xaâ e.P PÁ¢‰6WX¤Ñöì *j¬õàÀâB9 HÄa â ƒ¾ÕtãF‡þldxœ€h#Lj1 h@÷¨ÞU2`È׉‡u>ÐSà¯é*¦ @0Á‚CÄ_ZpT(k‘…´@X0‘ƒ˜-yÒ\éq"9;p0FŽÙ4Ü퇀Á6‡A€P¸b…d!‚^páËÔ…þ…,HKKÉêuò„ZÁ›“NH”*𣃠bHÐ ȱÍâ÷«Ä‹sجÈæ#k~¨ß~mˆÌ Fõ hÀ‹¬àb&~€¨‚ˆÑh…Ü€Æ@‡ˆ…)Öù@Ê€*âÑÀP(A,4À¨™tƒÑÄ p€¼¤N³Šd”²Å‹XøÁO6˜ìõ…fÈCâ0›‹Pa\ɽ8Ò¾÷ £#0Éö”A'1@1pIjà€BC F³0š\  P€SP ß3 zp¾?‹à2ÁÞf£“&1(õn„'l¤þ!! YÆ0®á ÷N ‡5e´Ikˆ’!Ì¢ÇDcƒ€0E„1€_\\_x`XN9ˆÀ.Ð í BWȵÓ"FÒ*™N>¥_ Øè’È0mð€P fà¨f\ƒ>¹ˆôB¤ÀÈ+$°b[*b›”À( @ .’ƒ,âÁ:düaÌ*AÉ·½ØÈD-R‘Þ¤Êî"_a8CI>â%ßXã:ôìÈ4€0 9o8Ð 8ƒ”€å€€`P1(VгTè²j>ù‡ÅÏ= ŒLt£3òþZzA¡6Gz²I»ØÉGÚtƒ’4è˜réIrŠRYéǘ›®“5 RA€ "p‹°_ Ý=¡Ê/9èª]¸ÆVµç äA ]Ðð†:#Rk€s…4¤—px+VIÒ³âòªšçX茗ž.hH. [7àAl%I0 P4Je‘ƒ-ßg–íi# ÑXO u0à¥K]l Z\"I$ò”‹ÞÀ‘¬Æ¡,«¾®!´¡HD+Ú0È,s ÷B"¥( C _Éé½:²¥/á Qª† ™½®ö·Rí‚loIVÃÖ±þ"ÉtÏРҭ`·$ù ]©Ö†Ø*c t/^è …e°˜íž%! ˵@3ò*A»(ä5ep„«¾áÉgI'Øï®áAp¨‚æè%œ&I±sØjËØûYŸ°PÇ=Ïo·DÃzBä ˆ'à‹ýù g Øß,f€Zh íA rp> ´«hƒ Û“Ù¸v}|Å×hyÞ°½ëck¾œa‡È…RÇÌ–‚‘åÕHÁ%€[g1 «*óðÁ 2u˜©… D¨@((p*X*‡yÖE»Ø…«\„Û˜³¦A·dF]¨¬¯Ô‚w…aýíyk™SÀc5þAtX×:@Œ!1ƒSŒ ¦8s,ó— OíŠ vl ÿõÊxŒK—¥1é1$:¯á­<Á»eJ…6•š @€ö$k%œ±Ü v–Žw¬y§$‘m§! ›Y‰&2¡‰èH‡P7¡ °¦]3X¯^ÒkÜÐ…';èjd°Æ¿x+døz Úí@%+P3™=ÍvÀ£ÔSÌ‘0ƒÈÀrçPÎ1ǬpS®Üå"JÕàZ6Ö– FCéFâ†ôæ¥aÐwUŽÞ:~µâ ´6ÆAu÷‰25àÌ9(Wô÷€¦ÔúS‡”bø 6fþµflÑ™@áw&VRƒDQ KýžçØ«ð ; ·X¶U¬z¯ @{׬Ž%ö 0 P%Ѽΰî=ïqLáØìÌð÷O‚ÍBÔ ŽÆ< ëd@6ê($žá¯°,LÂä*pžªJ®@³l€B°„f°„Öð¬öôŽ!êoÌ0O3\Î>€ äcš€4àé\Ì\ äCOmé´Eœæâ^à²/õÔK ãÀÂ@‚Øâ  Á*€fz H ÀÖÏîF`Ý(ÚìüK3Zç} LÃð²mÔP>^aé$AP! B'lͪþÂøüEAB èà NÂNN¯r1IÌ~äÆÇ&ÑšÖ¯lo^ÔMDXBD(‡Ì@­ùèÁSF#C Fã\ANƒˆ +èƒ48Æ*aš$J vMÈÞê× çN.$¬,«8â8€ä"cTÅ@(ØoÀjÒÍà.Ú\àd‘À)t€>˜B b ‚ñ'CœÂ)†À4\áé€Æ,æR£¯xB°K¸lîí^rî­"«¯ôêDpQćÒâ1’±ýPÀcåOÒ “…u,#¤bÍða4@C‚F+2h¦h4D€T`RC~Íþfàø,¢¡žVO è­–Xhä çLËÁà@ª¶ŠÌç,€Hz¡,hÅÙö²G؃þÈM9v†ðöç2`V†F*—  “*÷A ŠÔ,뢦(*)-ÉXnɾª­†ìÁ~ã­ é|l¾`¸Sà|ÊHðDDÚxÕØá÷–Î4ˆœ’1æ‘ a€H‰ð‡T€4üad!<3^€l{ôk I“.Àbõ¤ ¯kå‘#R¬"èM ¶†|Ì"Ôcåo,'ÜÊÐ`L [¦²a&að“a?i%h‚&CÈ1Õ³Ô|€þñà·ê­ê`µ„ Ì+û€ã¸¼€­„¥Xž„žÈ@|æÒÀ…Ö(Äî .:Œ÷àK­Gƒ‡&a0`?…“V€h8ï3hœr#õŸNqHÀ!úì$ƒ½„k r!.x‚WOØð‰z!žÂ‡Th&v´fF4Y3–OÔL­£)a„“LË”a†*¥Ò0ÁÑpÿF­R Ñ@ï¥ê£ÒòˆYN#$…&µ—²A…ÄG•H\“Çz®ö4ááÌ÷Xq4š¦ ËÔRÉta\Tp”‰ÀQÆÒ`¬Í4 þ¢­"l»ú´'FHßÐK²zþbä‹Kn. àh¯* Å$q `]DÙãO‚0•3"'•VæR/õL³'sÚ,CÕDÀ¥6¸¬' íµòm[+%oê#¶'CÍgÁ¥Py¬fd2ÆÌ G“À4ò#s*7?Æ?ÿ3_9Ò ŒÀ Í|à£1˯L8„CñËHÇŠ æ@îp ¶j¸Ô" U¿\òÒx(D4u˜CÔVqÛ"Ò*…†*õS‰ðUh²"+í!ðâáøl æ´ ‚+´"ˆt( üÀ*ªÞ@Oáà–άD AÊG Çg=‰b6is9ŽÛþ®¢^3Re•27R#óUV´Â01À³M*rÐ9ªï$‡±ØD~8L$pi5„-§b2ÃR¶F=*¨IÆÇJ^£f¾°\Ú³u``l•È”*T*²*…¯Å/Í6·,à¥Ê®´À,x@1Vh$(½\nÁèÂí8̱`Hc{L U%p_öÈ…Q§ÍbäaÍö F#R1Ä_ÿ“e@*E1ÛÜ”TÀÒ°ìब'®àɈ ûVN{pN#¼kÁäRJ'|>T ©ÄI¬d=ð®ÓÚªñ >Ò0ËVr‘×x™’q‰`4BÇä“Ô–nB þyª¡¶èJ¾lɱU@kÈË°4" 2Ö<'ÕSGTè®–wÕP7I£l™"+4ò)³´E`W'3?Õøü°ŠL.ŒØjN®¬¢ûŒÂ¤À¹&=¬äWgóï¶4Í/Ø]T”iê•>.Wš“Ô‚÷ŽH^Q1äpHÀN먎¨@®äkN±ïÓIö –¶I¸G$j#""W—Ñî‚Õœ]¯èlÎdÐð"…†"—À@c$D0&䳑àé¯þJ»0+§ vö!î……@׬Vî“S¯#Š$Ë.â1(â5œ6¤þ‰\H dÐi0:V™(ºNZ§g°r5äöGha°Dgê ×L4BšE®Š…P•ÞXhknætm«³ö#òK ! |" æxc¿ÅšÆÅ=cÖ’¥(rÀ0€\0ÆöHà"Ax—Èg÷—5#>cfi–>'a~™" 8v+ ¾JÈH/%·ïªDÂÁe Ãt¼9\e/S ý¨´=”#ŠH36@ÝÊÁdV@"Yd `TVažB€è³"UáZ°¥Û– ¤fR´°Õ É’ÍK‹ÒRÏ-… ,E6ˆdÜæEè¡ùÜáøþ,F>À)2àyK^ÁÞW1«—3€W+i¶€ ú6¢ž¶d‹…Ú€tµÏüâ Va§Á®¬'n ( #PgXGëŽ.ÜAÍJ-Vq[Ö%AZÇ–NG»ÍX´˜³¶MŒ€ J†ÝòQ¬`…¤ÌÞG0²¹gsZ¸p®åÈêúpk@ò« Уú…`rw‰¹tZCuÍÎ,Ü:£=à$›RM%a³YQ+]€î0$°±®ê#¬…vúÞ¸ ¶@w#ð¨ËZ ý"øA1´6|áõ*„þŽLÖ÷~[T¡]llu¢Æ\äU)L¹åðòÁƒõaþ9™¦Eàê%E RBÂ,‘ô°&ì¼D{Árú{q * /fîÜÅê€2{ž@(H`9>à*ìuca71D#‘s²EÅ[gXº¬†EKp$šÌm¹ Á·¯|"5"t‡\îÏbâÁ*ÄQ¦?åj™3àžœ`ÌšbAxMýÁŸÅ<ˆº€¿SÞÔ@p¸ (Pípδ¯oÂck¹ˆ,æÀ§  k`°yþO<àÔXt¬ †BD"€B&g =ƒøÛ0_ý’Ùì F—–ëGÓz·yé °¸¹<ëÈXí"8·`•¶¥ 6€ÂO” Áƒ7×jÜ#ÀZà®zSØ ²e B1¹° ´+µì”³+ ôäãîuÉXµP¯ô’vå¶ä<´Ì1Æ·f8âzWøÁle!!î÷€7U«ñÇd!‰/Ä€¹Äj6FëAÈø™ 1 KµÈË<"Žx­í> &ÔÚqÕ<Æ(Œ0>Ÿû¡ÎiH²Sú¯qÝžïƒ Ôá÷Ú,êÀúš èg¨ÑžþÒÒ ]ÈVU§_ë%­À’z»¾O­[¸¦fŠâ=–8EïÌ°Î2–¸KM-žû¹Oq ÀB¡ÍbAÝ¡J€,òÀ’™ôÁ nUלHuÚëóMÞX»¯)ô<Èx[1b @%ÞÃä ¡|ÞE\Pðî Ö4`Çà¥Díw™æÉ)áø²¤ *%z©ftËÙ@XÎäm‹¨\J(–µô(®$=´°áFÜç,òÒEdgè^+!ªGlÞr:áˆF!hñª›‚Ñ[±Ž.‚“C‹›¬':ý Jë£ð»Ê_æŒDb˸™ÿ御d#ÅP !‰Û”ÓþÎìlÁþTÇÇã8|Ån§Ê˜€¹ðù>VŠ³úâL&nõÃýÒ_ž˜¼ÂpnÞú÷5ßñ?žúž–÷­°¬ðáÀ±tÜH,26.*žUXl´ 8x,Ìø8!´¸h\"|}`a-,¨¨ ¼ª(,x|(l”P°pü´™ÐPTŒñœ$›œ<.£ æÅ ú½íÑåõ±x_ *:Š;6ÞxáTØ Äh´$œz<Ðë<Èä¨ÎxxÌ(P±# 2Äj2ãÃ>8°ÐA/Z€(càȒUˆ#æM™?ÀåI¹&Ÿ/ßXôèЃ›þc:”Ë™ó‹'(X`·AÄ‹ ,¾@â×T2`ˆõ Á)M®|å àS Qv €Ã€œŽšU ÐñÛd®yS©ÒÎo<8x¹ÂRH”‘¢‡r:ó܃ƒ‚ (D(A‚Dx>ÌpâJTt@uÅ€|0)hPÁ.F”1q†‰³ax¤õèÑ‚ &~K׌!C.ar`a¡„†Rø^‘Èðáêæâ #{RŠj´HêÁ@Pi¢‚S®›2;yª .,ðèÁÁ226O¬`PäFÃØP7iaÈtyÃA+Xpþ$‚!†ã(BuÖ5â…M8Sbm¤€ áíSÄŸ € }ÐTNL!•·l`€ Âü`¿Ià iñçÑ1À æAGƒi²2+à%ቤ(X )䀗†Õ‚Ó‡Èä“ p˜xÖ ä@€d$DP@àÞ³È2‹@æÁ¢‚5¤`‚ 2mT!ÎÂŒnJÚÁ 0ÐJT2x’0¼yá (DA ¸` JÍó úéwƒ«&A(„Pj<òª#pà›¹˜Ã£¶À?ê `,¢Ð#\€Ã ÂÜÀmµ­©¦lÇì†B `þ –^Š‡ («„6‰¢¼É;Ì°Ð ?f‰a7`È/¥@ ØÀ‚aÊúc6pÉ "˜†Y@¬Q<DÐëA $¤@AnP»ÝiU° 3p«Hj Cr¹¤Ÿ¬7¤c@)ÄàÀ:ðüY-ó* ùá“¥Ó©Ëk"¹ú«¡®>²arŒPà Ì°A¡Wï!C#§ØÈj4øCbÈ–GoÚpFq?b·‡ Âà”¸£-8°ƒ$ 6ÒFx®ßØуÛ/ƒq††—ó+“„Ynž¯„+ô ¹Ýaüwnh5³&|þðA iCo4 Ôl€BPYh$÷à1S4œp!„€À/cã@¼ºEãÔÁ^¢0B¨@ƒ÷Dð—0B Ø|3¾Ñ¡8ÎÔÒ¢ÎDcˆMp`9,±0¬nƒÀPÔÀ”@ðq@ Z‚ b‚`ÄëG `è†6‡4ýàE$ª@õó2Dð H9 ÂÆó$ ¤ØÀjÐöE3ì]ÇŒôŸ5ÙÏ~Šbܼ±E71Ô°ÅÊÎ$?f€žpÁ€€’taD N ÂÔ¯¤Ýà((þÊx„ U2áWè4„—”`$(_öRô œ P>–W„ª9ÔÀ!G`E‘á- c ¦‘œô ‚ 3Ó¶Øà P)%.Pj"D#pB€ oÊÁ¾:ø°&€@x£„˜°Ž Ý…’ƒƒ8!kó˜<3p @\00ÈdÐœ´b "k0™¾0O‡"LT‡%^ #É!DmØÐÉ®ïH€±0ÍPJ‹ª, 9:‚j( "2¹Æh@H€€±ÀóÚü…~ ÂcAŸ(*`—ñÁþ ¢q5<ã  ƒ,@íHÀ‹†ð¢SÅP‡Ð!l¢›u¦CQµ™ÃhnUàx¸ð9˜à?Ç XÀ®µ+¸Á º³¢Ì¼ 1€BpÂȪ0Â(&{˜™ØÁ“¿\Õ¯Ðýï1°axdð€”Ô3ëIU ƒìià PÀ  ¢v8h ¶•±m6•¥@ À€LZ9°Á Ìdל€xA LÀàpAQÞეvCç˜Þ*=XUH9E; Òò£á&vt!1¤l€¦X˜‡þÑ ¼ Ÿe@Uþ@6ÙáµIª B S6BÀ‘³a[e™LQhKë":ÀÈ”PÑ`0]¦«’°€¬8‡®,¡ðyÝ\æ>:cFV6²Ñ‚û sÁd&'Ð(ùÚ± à+`K4`R¨@—b`KæU/Ù^¦4n¬l À;]âƲ&GhÀ)ZQˆ• cCØP€WÂ䜫޶Žº¦«Éç"fètxäZårpþ´î3¹ðIÐ6Œ¤n’Ps¦¹ÒÈ ›"¨ŒvYøÀJz¥Ž•½(à9bn fR:p: `XúÆÂþ°›• kÕ-†¼QÇÐé‡A«{TÜvS›/È--Q 2ÖiŒ HÖ<ðH.àRаÆ3Ÿq)yÀ³ƒ¤T­6HÁ   Œ #9aÁ—Á)@éD æ+!~-]⸜–µu~Ô=hɪ|’¸%Ý{{Ùè¶E¼¡6Ftí¢Tmž †.Hž^ÁÒ ( )…Á#~\á. غȮÆJ1Pè ¬ ¾ýŠš«êª¡èy»˜Áe«¾‡8ÀaÙøV Þ0‚x”€;Œc€HÆ4ä¤:p)¥rÒ++ 8òþF¨q¾à ±ìøá÷xæfF³Œ?\]TFð˜á`CDPS0!Ĥ {! C1}¢êˆ®ŽåGšÍo"Õ‚D%¥Ÿíç Pƒ}8@Žt6rN€•ÉѺ92·mœÄÊ_ߺLhBò h r(ÃÙa:9¬¡%GrÁYð’LÒõC5@÷ΤEZ8xSw ‚`Ÿ,@†'æ @ŠÈÁð!õ‡›i….LYvt)&09»ÝÀð1Ð$“à ‹XàYü¹êAe/`Ä@TÚÁÀv×È@l1@x›ZÅJ@È@þ Õõ`Ø9 æ=^@ÍÌ\Îô$Ç´èM0Ž0Œ›¬Îq @¸xF\ÀO¸„•%ÕßjÁà ¸@ ˆ@ ÚðÛøXŠä@ÀLÌZ]…Ý^@*XR¹ÕtxEaÛ9¸Šõ)BE%Mç€vô |Ú Ø8|Ã: p¥„€€c$€W Ç¢ÀaEÀ;0’¸@  r |¬ Œ¾Ãhš]íŒNPTeþœV‡p›ºdØL¬›n äœÀKx¹ D:X ,ÀIqרTŒ@ Ø€$ä@ ŒÇ ÀÁa Üù Û˜Àx@Ð<À @÷ôY9t«‰ èÇV}µ‰Áaƒeˆ˜€ÛÍ„„@I\dX”xßטMÈP–ðHhÔ✅3ü@1Qƒ$,ä›X¬ Ä– À_$P?D€àˆœ ˆðÓÖQ ÒØÑ…|Þ9Æž§Mˆf˜¾$WèTÒ¬Q@ÑD–YËèiÇÉ}Áì;„€„TV’™€·dÄs€,ò#UÁJ®À #Rß6Mõ%C®Ý¦lCÖ$æu€ÛÔ$L¤Ã]`ÈxÄ\@ŠOd &È€EˆïdBxdQ;@È@þ Õõ`Ø9 æ=^@ÍÌ\Îô$Ç´èM0Ž0Œ›¬Îq @¸xF\ÀO¸„•%ÕßjÁà ¸@ ˆ@ ÚðÛøXŠä@ÀLÌZ]…Ý^@*XR¹ÕtxEaÛ9¸Šõ)BE%Mç€vô |Ú Ø8|Ã: p¥„€€c$€W Ç¢ÀaEÀ;0’¸@  r |¬ Œ¾Ãhš]íŒNPTeþœV‡p›ºdØL¬›n äœÀKx¹ D:X ,ÀIqרTŒ@ Ø€$ä@ ŒÇ ÀÁa Üù Û˜Àx@Ð<À @÷ôY9t«‰ èÇV}µ‰Áaƒeˆ˜€ÛÍ„„@I\dX”xßטMÈP–ðHhÔ✅3ü@1Qƒ$,ä›X¬ tiff-v3.4beta018/html/images/note.gif000644 004341 000024 00000000410 05774051502 017220 0ustar00samuser000000 000000 GIF87a ó€€€€€€€€€€€€ÀÀÀÿÿÿÿÿÿÿÿÿÿÿÿ, ½ÉI«ÛÍ+0 t¤žcYÎ)ª”N]) <‹,}(Ø°à=|Ÿ®Èä%CÊ•±Ùõp8ÝtʲŠ^+ª±‹Ã@Ã[æçjå8;qh»•;ñôØ%: ¢?r[I~‚‚~ˆzŠŽ1‘˜”š–1Š™†œ˜žE¡D£©‡9¤© œy®Š«¯ªoC³zµ¼T¦²¯¹p¨ž§È$i„€:Ê;<§BÉ ÍÚÏI*;EaÛ9¸Šõ)BE%Mç€vô |Ú Ø: p¥„€€µ¢0@«TÀaEÀF}ˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆìÐHˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø ÚžèÇV‰Áaƒeˆ˜€ÛÍ„„@I\dÿÆþÿÇ/ÿ®´›p@<à…3ü@1Qƒ$,ä›X¬ tiff-v3.4beta018/html/images/oxford.gif000644 004341 000024 00000013665 05774122313 017573 0ustar00samuser000000 000000 GIF89a(xóôôôÕÕÕ/çèOO×[ÝV?â#—Ž–ä+ؼ½½ÛØIø¬¬¬[Y],(xCþUºUÇ{E8@ =^ªl[<’ã*%Ö/M¹,"Ù.@Ö¢l¯åØH1–P£X!ŽË, Ô»·€4¹ëýXСT²b%±Ú¸|N¯Ç“Æ£T9UU…‰ ’“”•–—˜™š›œž™Ž¢¡¤ŽŸ§¨©ª«¬"z{º»¼½Ž(¯—$ ²²® aÉb“(I%“ÄÆÈÊÓÒG4¶’(¹PyÚäŨ¡ÖÂïð¬ôõö÷—΀±Û´) úyíß"Mi$”»f¤Å›d•šDº”͵‡š„ü’GO þ4,zr7¯’¼’øRª\©)J¿cUÔÉœI³¦Í›8sêÜɳ§1\@o 골ѣH“ )c§©Ó§P£JJÕ…#W«jÝÊ5ªoRúLû:Má".ˆ0[¢l[¶"Ž¡5›6m£> Ñêm;·î›±_Ù¨‚æíÛ¯0ûæ%ûW¬^Çz×:–…W¡@?»e[²‰ {û^æ‹÷q`¾ný†ä[ÛÞÅL+Â%óÕ ssa ´âÕ\¤ÔâI°H/áJÞ¡ˆsd-‡.ëEA[{< ÀÝ÷¾ÎAüpî ¾“ç` }{‹Ü;ÏÞ}-øè_à`ÿþþþþ )`àØA‚”ÀƒFaÂ7¡Aàg!nØá‡Â‘2H› Ì´`a’`µ-èá¹i@ 6½AƒAÿ Ð@à Ÿ?‚Þ@B¤‘)TqÀ“X°ã“8”U^àA€\ê§@—ÿ5É 0ߘJ¨æƒ¬Y¡† ®çœtÖ '‡‚ˆßuöùŸš§Ÿv~((¡ƒúy¨œˆ*ša£]×$¤”.'„P`@¦Âi©žÿì—é“Òé©©”¦Ú᧺çŸòHf ª2Z릙"©ë®¼úW'€&ðä¼›$¢¬²ç§þ> ê²Ï:;觋ä*¡ÊΩ!®Äë­± bx€°HB©ߦûÀxV6š­¶µbø*­°Ê+m­>ª Ì“¾„¥“£BYê½ur›îÁÿe {+¬¦a& "„ãwa—Cih¼ã9'‘?ª ”6ÖlSÉ&ë„rÊ,+µ²1/·,óQ.ñqÁ+ë™cHd‘Å$),-ôÐ*ÇÂ8­4*P0 e쬧j0KKÄÑÒWô¸ˆÔ I˜œ´ôØdwÒtÅôƒs Pó™ÎR]ÉÕ-†4‘2Wl„ –Ð-IHIÑ%A“ôßlD#JaËÓø;eG.9%g?­6 þÿHˆ¤Ú57ùç*ä —N´+ûÄ4Ê-¸€Ðºu¡Tw‹”6×®–í¸ç®ûî¼÷îûïÀ/üðÄoüïœE–üZ‹¡…ݯm&Ò<;óš3t¹rŽÛ¨Io˜eÛ³Öý\œ•ß<ùÌ÷œ7\ç÷ü‚ôe­…V ×go~ö…_‚Yl–šòt±óÈšÍt¬OÌ: Áˆ¬z1ð“‚ #«ºí¨ÅyÁ/€s›ÍG;ÈÙC£Ñ]À¬E°‹FCøë4ÇDZ„ºSž" i†@O‘¤ÖöhjC>Ô•zH¥;i_S#FˆqMeBPÃÅ7¹ÉBê”þÄ EÁ z‘N&ä!£¥ÀZà]k™fU(y%@o|£•,ƒX >s|`¸Ç-êÑ]^´ÛèEk}‚ÂÕŒ±Hc”«ˆôBU ô£È4Ò’²ÀÒ!Ø*@z¬R$ˆ= ÊP«aߥ †HE¢r’$'¯å([m’“Ô¡6¥¯~u,‚~@†Joa²L‹@ÀÄ3a;£½péÇiÒ+¿¬f­©ªý ú*€® )¬‹;ëjØ,™)Ç=ëÊ”x2ÙžgÚóžø,w ´®~ºG@ÞùN*Fói¡»yT7b$^·¥”Ù¼¥Då}È`2U´äâÛ€7 B$°Uá8•ø w–²lh$û¸@xq“‰´ò%ž>• ƒT¼‹UÔâùÄpJaú5‡l´`àȽ829Y‹3òPXw$y.$1Œ‚›7Kr’¼S$þÿ(==ï9ÈŒ„Ÿ‡*K¥è“®ôC(ñˆ…zD¤ )`LR”¢®˜E5Á‘Mlb ½A”âgD ¸ÌSìÔ(v°FÞÞƒ!‡å¹h٥ÜÏРIz¾r>(û<´9š¼’;¾%©TâT_cÕ„u*fì˜Ï<×±©p[ê2’~R%qætmª 9怮ù‰q-i ^¯ŸÏ¦Þã©ØÛôyƒH!tjìŸ×æØMzeu|Þª:~Âooä‘ø¤$~ð¡ÏzíÔ!+UÁ>U®¢}«,¡ûXéŠøŸÒ}탟ç¿úÉíȈÞΧӃ¢h€þµë‹aǦò“qø7|Z$UØòG·'˜’1ãN¬—oO$‚€°÷W}Ô,Ÿ4€ú¶qˆ{µÂdË·ÿgJ €+Ä„0ZÇq¢tΔ.䤀ˆ‚D-/¸MÊ‚}B–GF«Ò!d²P‚ ó/ÔQ9“õ÷JÇG_”o È`´c;¨„ÄçJùô#¢WE`.ÈJ×-I3ØFhÔ„Ô…ð7 /'¸zÐÇp@˜OTÂC³‚º²0ø¤Lag†µ”(s4/›Ôq¬’/îWNB0ó²3u (ðT…ÆòæD%üxŽÈ+ë¤LŠø|Î’@)Kó±þk"Gz˜„÷Òq]Nî÷H ÍDˆ™´H8¦ä{n‚Fø%•N•¸‹¼HN„H Gdo¨HS÷€T2‚ÃNÃB*Âb„ÍÄy:èDLáÄ‹Öxؘ ³…^¨ ƒ%¼ñd/ŽoØ8Žè$PŽÉ´Ǩß²‡Ò-ƒTbøxú˜@ùØûøöȆQ˜-9µ’oy! æ6>áÆ3ùãjK@Ôöl)U‘)åS†‘‘qwºÖlöÓ>ÕÓS©¦RJEj Ù=•QÊS‘?eSCðW±ö=£fmäã4£õ~ ‡=ócv„ EUUEr± wU80=@9þ@³ ™Àa‡@Æçµ9@ƒ Fé“v )¦ õUvC° Ió“ /†eÊp6´“8ù%ëU /9Ä•7#ÊÐW–`—yI—× —nÅw981˜ªà—>i˜¹0‡“˜.`–Ä¥e€æ›SU´axñ<äáaÙ™V™+  ᙩðV–:¦B¹à™6$Dš°Y˜²ð[e›>¨É3×"(”˜wù›x9r¶99VVœÃIeIöz}àµcõˆÎÉÑA6ð6¢4K7jáSP`ÅieǹYÍ°j¹u9œzZ56Q2XS]xÑÞþI:FŸái:oEnü@^²€»‰ !áYTÔoE–p•• û3  Ñ|åWÌ#šyËæ§`dE6c÷Y:7 [†ï' Îa•¥&pï¥_܉”ƒ“c1H3š&8ÝÐ4½áv'f¡zà ùE£óÉ84§¡ú9ãI[–šÍ1›‰Æ–)za a£-¢Uy faQ£üu£bðbë9£[ºå°™µy D: Z¤’3ž:K¶–%”EtÅ9˜¥¥”•Åfœ‰ bz‚ã%P–a`cº-v¦CjŸê¨l9GŠcº%§Ä!¢ž7 gbþà”×õ„r‡‘¥4— ŸÚÓP–{ð’«©bl Vi#°¦*¤‘ºZ ‘pž—ÚQG€ ª”§~Õ\Åz4°Ã\W:7Æ ¸À ­sU™¬Ñʨjš¦·š«Fšœ æ4ÙaG2ª­,a« `®ä:4“úOc©§·›š®+ñà)¯Ô¹«—C ¥°¯û: þª¯ö:¯ô*Ö°ö`š”º Ñ©h [< k<kÇ$€Ð`˜…üÂ’XNpbÔ¾RØÿaÅXçÔ-ÊáLÕ¡øÍyxÇxÉÄѺV« ±Òº™ý[Ú” eÔv—]·;®™#®Þ'à±qó!UR%‚ÐÚ1ŒQK$LJí%¢{EÈDu¿{^×&oÒ¾‡GÅ òèÅåìqy…шɲƒÊÑM)G)ÃÝÉT†Nx†`LÙ’®RÆË-Å’dÞaþüÅ!Í{í ƒêýÝ(hÇäìÝÌMz»ÐŽùµè¨ßèÈ úÙQàMVàá¸ß~à‘‹à½`àNÖdLKàþßPá ¾ßÞànáþ-Ž .à ¹K«á à îá  ·¯33Óâ.þâ0ã2>ãêÀ6Pxß dÈ×­ÇÁ20ø†ã› ä„"€Wßõ݈ŽFïH TÈ0ät‹î î¦ÇíFîë±¾æ¼ä~¾º@À”{ÉìUøÅ®Žš‚Aö„éPÌì¾î@À§‰ð'ˆ+ýlä!b\îܤt‘þJãÑ!vˆé#øMø4g{^ë­wKV¼ãUNÅ4ä9‰Í„Ù’ñÁÞ×âê»rNùÄN™žþì÷­ð9ïpJ6îÇÝ=ÙŽ×x 0ÙÈó‰H‘‚¤®èTÞpcçJú‚%0?Ûä1‚ÔíŒ#è{ÓîÖø£Œtè ‰a²GØÄD£!·èî!!¶¢ð÷ÞÜŠ¿O‚= ­¨àç?41kR&œ§fïÌÌöHO&]‚!`?{J­‚Þdí~KEæß­æW'Ô˜Š óŽC$§Î+#‹mç xJ?û Ãóµu)0ˆhŒ¹’0]>!ë!úµ$üž‡Ú¥¿Ò¼‚I40 €öÎÏi_.ºX‡kOûÖÏ‚–4Nâ/Q%ˆIO²üÅ´H‚ö‹þ¤ OÄÑ‹ÀÁ|ÌÛòÚçÂþÕNz‰˜Ìp#Ž¹ÿ‹™"PädÕ2içæÝ0ÇQã0Š!ˆ»¼+&Û¸j³ á»`aç·a9d‰p0“¨ò)m"M¦S™­F½TmS¡ÈBÍgtZ½>_±lx<]írËKgØŒ¥Òî4À¾®:°Á%ÂÄÃ-:©»ÄB¦ÊÊʱKÊ1ÍNχ?ÎPLOKKN2ÑÒMÖM„RÏTÚZÛN×LÔ]ÞÓÔVT²Ø¿YÜÏÓàÖÜYOØSåÌ_ÖãbäËM_gÍNJXïÜpeomet€ØôJvËtThJ‡‚Jôxwl|xwÖú D†NÓ¾|úØ%¬ô@‚„ñÚ8Èà»xû!T8 ZFwý)”øc>‰ÙYa¨AŠ ¢L‰­%»u ˽3‡­\É’m2ü·óâQ}'v3U“’Ã’â;UsiÇ‹@%UYÕkÇN-«‹”j»¬Ù|áãz¶R;&]‚!`?{J­‚Þdí~KEæß­æW'Ô˜Š óŽC$§Î+#‹mç xJ?û Ãóµu)0ˆhŒ¹’0]>!ë!úµ$üž‡tiff-v3.4beta018/html/images/quad.jpg000644 004341 000024 00000056540 05774123072 017241 0ustar00samuser000000 000000 ÿØÿàJFIFÿÛCÿÛCÿÀÀ"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ÿ?ú(¢€ )~œÑŽq‘õí@ E/®9½éÈÏAøÐQKSýÉ£üóþzÐQKN Ç|ôÿ>ÇÚ€Š)p} %í¾¹úLÒqŽ¼úcúÐQKLçÓþ¿ÿ>´”Ràç¯lzý=è'”RãëùRPEPEP]G‚¼!¯øûžðO…´ùõOx«YÓôÂÝwIq©ÜÇkn™8Xã y¦‘–(!Y&•Ò$w^dzŽ ÷Æ=ëßµ~ºÿÁ0~Zé¾#¾ø÷â8£/¦›¿xÞUË‹ûˆÖ-wÄ “ò-µ¬­¤Y y.u&ù<ˆš_¡álžî{—åõê{ %Jñž:½íìpTšž"i½½šq…÷œ¢Žœ˜b¨`°”åS‰©T¡Ûr—[.‘IÉù&~s|vø-ãOÙï⯋¾xúÕ-üGá+è­åžÜHlu[ËhoôoK’T¦Ó5m6æÚúÎB‹ ŽQÉÄsEàoZø¯Åz/‡îîd³·Ôî|‰n!Ò òÝÇ–%ù<Çe `Ws¹¯éãþ qûßxßàÃOÚÿÁúz\jÞðþ‰á‰ÑAn®¼¬¤ðþ¾<°L£ÃºåôÖw¨Á™luÑwº(4é÷ÿ3? '|Eð\„íÄZZ1 ¤—QÆà–È•˜ö5ëdÐá_øˆ¹] Û6á:|Y€£‹¡:ÒRÄeÚ4~³„¯ZŒ¡8NXW:3©NP—ü¼ƒ‹jÞ#ÄÏ•VÄRŸ%_«â¢ªBÏ’½iJn7N7…X6“‹Ù^=º|û.~Ï´jšçˆþ2,ûðÿÙGÁPÄnìn°`y/Œcßê þÂ?±f­kwÚÿí'ö¦ƒ\[jß ?0çk‹y<4ç HÊyÄ6ÓóÞ5£Nö›.p†LƒîO¡÷<~YôúßáÕû]\Z bAtÝŽÜôã©ÏÀö¯ôãŒ<=ú'à#*¹`ðÔýŸ2tóÌêZ-_ñ3–~3ýú5}|:ñ•æO_‰sâ©Q¯RΖ›çŠ”£Ë†ÂR’MÝ$å¶Që_µwüàÿÁ_ø'§‰?n†ÿ>(ø‡PÒ<%á¯Ùø Å~ðª[Éc¬ø¿EðÝü7z¦$2+é¶Z•Ö¥çC +ý‘c1äçÛà‡Àüvñ7ö…¢‚ÒÆÕ¢}kÄZœšNo#0S3Å’\]Ì© ³±L·‡sC M<_è#ûOéƒÄÿð@oŠ1î§ûìóâÍ°üÒøE|NúªÈNÇ"Ö¥‰§FÛ8äù£å×ùLýŽt« |'ðªÚƉq®Â|A©J»wÜ]jMº&‘90Ø¥­¸’DaIØ?‚|=Éü4ñ#Äìë ²® áL^e Ï ‚ÅÕuñÒÂf)àðPÄÖ©VtÝjS¤«Ö‡¼©R—*I©¯âÏ#ðû?Åä¹.ÂOŒ¸£‡01­Ruœ0ÙgfT0õ«NNõ'C-¥‡¦ß»í&ãRKâ¾Ï‚ÿà“ß õ=28u¿‰þ4—V–5{¦éú-¥”R•ùŒv7)w+Ç»¢Iy»—5ñßíwÿãø•û4hÍñBÔ—â/Â¥–(ï|Cee%¦­áynfŽÞÙ¹OŠ¯ D*I~óÜK6á(´­û×…žpŸðåL.ušàò<ò¶ Up–#K £ŠTܨûzêÆ\5J‰F¢Œc>VÝ9©-?Ï„^ð·Œ>&x+Âþ6Õï4 kÚý†›«jš|+qymou'–Ÿgè’yÌVþkG/ÙÄÆqæ1 ÿZ²÷ìÿÂÕtK>øsãÍEíÑoo<[ñ'RÔu™›ÒIs¤¿‰¬-,$Èù¾Ç¢éê ²íp’=FÊßÃïtý Q·¿¶ÐEÏø†X®ãe,óÚ8ì|³8̲Ü6g8àjáªB¦ñmÆ’…z~ÑT¡É9{G9+rÿ-ÏÃOñÎUóã¼ë„c‡úÍ9C)öuð8ÚØlR§Zx˜B¥ ×I8ªRXgʯ]¹=/ø+ÏìàŸ…ß>k?²?„ô»|Dð‹Xë ð%ù×`ð·Œü=| žöp/¯åÓtÿhú–“5§Ú®9u3[™]VD~!ø?þ/j^šìÝj: iöò²F‡Nñ4zm¡ñ>‰˜¤š)¿°|@Ú–Š.â•á¼î"#™@þ’> øf{¨õ=O/m¦Ã-ýÆáÂAgÜJÇŒùq·ÝÏùr+ù¦ñž«6¿âïësÈfŸW×µmJi˜å¥–öök‰$$õgi ä“_xã’ð.QŸJ· ãçÅf˜š¸¼^• >-˨„ia0ôœ}½YJoš|‘Œya¬Ÿô§Œ pÿƒü/ÁqÂñ.cÄÙæ~ñrÅ×Åa¨a0ø|&_J‚ýÕ*s­Vu«ÖÄÅÔ©R³ŠŒTcÛ“ýÛÿ‚r~ÌŸðOßx¾&øçu¤ëž5Ö’ââçOø‡âíSÂZ”öºÕ„é¶ö¦…¥êêÖ϶«{¨ù—ò-Î~Áÿ‚ŸÿÁ;ÿe-/ö>Ô¾)~ʾ øy¡|@øâ뺯µöÖ5?ø7R»_ëv¶_Û:™¼}.ãTÓüAºÞ5h´ý/RÀJü”ýž|*ú—ÀßMþ÷Sñ1µvFSöhµ»ˆ·DìHu)p7Fª‚@ñ•.ŽÏõ€|+x÷pDY¶oQ0ß{·ëŽrsè¯pù‚|Màï ÑXl†sÆ“%ÅÄŠ?‚5’VDo³ÿদÏâ7ÃÃ#<=à }J[}͵5ê—óO9SÀ–k;-:6a÷£¶‡?tcèػƺ§ìῆ_<%eauãFæëQêp³Yëuê\ÛXhmÅptÉ|9psåʲÅw©]ÏqÇœ/á×qoˆ¸îÊóJχrl."½LË:41y³ÂB7„硇–7Uaé4¥Xª’ö•#'?é/…¼Kœpsg¹–¸o$­šµB9žuO,øj.á´_ˆÞº»ÔtK)îåòí-õëBËNÖ4‰œÇÉudúd—2¥µ¶©s)ÅgŸ?ั_ˆ´‹;OŠš7þø…a‰/¢ Íãoyᚶ:¯†DúÄñoPÝxnÌíd-ŸËõ}{öÔý‹míGWý™¼3¦x‡Æšį x§FÔu?xXèžÔ-WG¼š[mõkˆõ¹.nm!žâÚYt»¶–(^9Rà/eYV±ø?ø‡œEÃË-£V¤ó¯oˆÅà¡NŒdÝzØŠµ*`ñ4Ú4• ‘©ma»}ü8ñ“ÄzxÌ7ðFy”V§…­ˆþØ£—òåXgNq¨ñ”°¸Œ6‹™R¬ë:nñ÷¬ó>ÇNùì:ÿ“ÚºÀ¾6ñ<7>ðwŠ9ý‡ÄŸ þüWÔ| ¦é:»Ft-RþsU²Óõ_‚B\iVéöâ[G)i<÷‚{·û-œ–÷?ÕOŠ?jß…¿³×‰ßÁ¾2ø³ðÏà?‚ígŽËáÞ†º¦‡áÏáÕ‚Ùì'ÓRÅ-ìc·‘'ýç˜bŽ’ê$¶Òløœ»†ðurÚ®k›ÓËpغq88ª2¯)é׺ñ6‰FR9¼-ñGÂî5õÔ¢òÖKm-Jâ •·&âÕ!…®!þ#?রÕßì ûLëàñ"ø»Áš¾—Œ¾kÒùi«Ïá=JúþÒÚÇÄ6Ð,qE­éw:}ÍäÖÑ¥úÇýªÂ· ikñ˜œvQ ÎYf4Ãã«{'Z1¦ùj{4ìÜé¶ÜÞÍí®ÇôenÎèpÖŠgJ•L¶³¡ ó¡WÚ<%\EýŒkFJQ¨âãrÛšÊI]_á øróÅž"Ò¼=cÄÚ•ÒBòà”·¶Peºº“§îím£–áúec sŠý¶økâ½#ÂzNƒáO„³Ñô+;}:Â#vȹ’âbßsw1–æêVË<²ÊÀ3þB|ø‘¢ü1ñÚλàm?ÇVw6¢ÒM6ûXÖtCfU’C ö‰qor¦Mˆ²¸UpoÔ†¿ðPoØŸÃÑÀ¬À’MÐ*¤pNsñ¼QÅÜmÃ~Ýp·æÜC¸uVËqÙm´Ü©¨fY¦®KrÚNÍ7qð‰9‡\Qý«Ä^ñ¯ahÒÕ«p¼¸Zp¤ä¹ªóPÎ8‡+Å:©¥ɇ’²÷%.goíÀÿ <+ñ»öfÒ<ã-5 |EøK¦hzîŸ7çJ×ü3­Ò£©- ÂE9’Úâ&óm®9âu’8Øž§íû:x£ö@ý®üMð3Å&in|ñO‹HÕfˆ@uß _^Úêו]|¥þÔÑ.¬îfX÷à Ë\@®ëãý,xþYýž<ám#úOì›ñ* MÖÇGÒtÈ> ø}ì­tk E¶¶EÔ.ôyo^[t†R­æ2ÆZioD‹åËø¿ÿMÿ‚Žü.ÿ‚ƒ|Jøgñ?Á_³õÿÂxN¸Ðµ_j~2²ñ%ÿŒô4ÔSUѬµ[/ hðY6‡{.¤öR}§P“ËÕ.áy!nÿ-x™}#òïóªyáÞi•ðVm n*Žo‹Î2ÒÊó,,å_/¨ðØ|׉« T°•V•KT•²j³ònžaŠÉ8š†u–crZ•slÇ1ÈðøåJUå„Çâj¿ªV–­zP«5)Î_½pU)ÍFošîm6êr&nqèürI‰õÇ#5ôÿ¸¶\ۓدüuÇãõè{Wæ·íMáiæ:‡†5ËY‰ Éiqc{cÉÃLÖ/‚y¡ëŒÿöO þÜ? ü8ÑË/…üarñV8×HXƒÞC¨;'Åå·#ps_Õü[⯌ì$èar,ƽOfájxœ;Rv¶’Uùlݵ½­sý3ú'xÉÁ ÙNŒ8“’âp¸jëÓÄƼ¥ÓŒc4½*Š[;r·~‡ö߬Ù'ˆ¿àƒŸmÍ—ý›ÿhÛ6ò¿y;5 ñºƒk}ï,2¦Ã… ` WñQû|PÓµŸ ÙxBâî(õï ù°­¤’šãJy¤{[Ëec™’3ì³yy0‡ÌÚ&ˆ·[âïø-?í…iá/üøIãé¼9û6x×ÁúÇ„u„^'ðÃï@öþ&Ón¬œ%u°ÙŽ;ë4*SUœµaR²œ'4ù]´Vþ™µè?<â/‡Þ%]úO‰tÉld”i¬®p$±Ô­ƒå~Õ§ÞÇݹ²’û¡îmÚÖÒG@FKF.@2ù¸·ÎŸþ#øË⧊.üaãÍfM{Ä7‘Ã×ÒAkh½²yVÖÐÛXÁkk'ÉPÀŠs’KÑr‰ñÍ\ã[‰*啲éѶx|Mzدm®GÉ<5(Æ“§ÏÏÍ>e.NTýëižæÜ-˜pÆO†ÂRÇÓâ,¾~Ê¥gF”0u02ƒs¥R§¶uHVQZn):ªMs#»ýšü/Äÿ|8½’ø‚ÏYÖ8‚ãXÕ”¿HÚ{;9mav,óÂ6¾v·îõ”W¼®z´ÅÇ«t==ð:w¯ÅïÙ;ãg†þ|A¾×üO¤O§kZ ߇ßQ±E›QÐ~×ug;jÖï$):2Ú›k¨Ä‹/Ùg•àʉ þ¦øöƒø'¯Ëտį B$ua¥xt©Ô±àK£³FsŒ†w#ò\mâ7ðVcVžE‘fØœ®¶ “úö…\M:¸—*œðšÃ©Î”©.T•HÆüÍ«¦Í8›Pñ‹‰ÅP–"ÂeXZ8,|§aˆÄÖÄU«ŒsíJT’ÃÒP©ÊÚNiòÈý5ý–ü?á=CÇ~Ó7Æ/QeÓîT3’Çp ñÂÄ¢ýà¯?4†‚÷Rø³àkkuýáv×ì]€F‰Š'’nøÁŒ3`íR:øüAã—Š¹f[<±ðÏÒ­J”0ô²üehèœTiN…:©‘•9Ê--ñ?C,Ï‘á©Ï‹14rŒÆ®"®+1Ž>½,2†&½I×®ùêÎ4Ü}¤åiÂ\’Ž©ÚÇÊÿðYoÙÃÄ? |eû=|tÍuàÿÚá]òé—~gŸâ†ž"»Ðë_¼Mã?è2_ÝO Fæ÷TÓ´}oMÓî †ÊòÜÇmqsk ¬—Öé\CÃäž ñ÷‹~kx‹ÁºÕÖ‰ªAò™ Ù$0’ –·ÖW -ý¤¸[[È&…øÜ„€k÷NÌxã áÌ»S6£>'xIN®+ØÖÂÒ­ MGŠ£„ÆRæ«R\=)ÓÂW­>z´!R§í ˜ø¿†ÃñÇfYö¢¥‰Ãqf+<ÀÖrö”ªÕö¸Š5”¥Š†2IM8ÝÂR§%Ρï~²iž¼7‹˜\à}ÖÚG¡|}Õ>ø›^¸×žïVмmsö8o7Q™šyã×!w`g»In® ÔNÃíqO&ãç$Ÿ¦>øÿ/ŒôHt›/ø{â'…•áñDzð²·Êÿ¢Ï¦jªu ;ym‡-n¸bÍøÉà~Tèå’E#Æêr¯e>¡”‚Ð××Ã6̨à?³¨×‡Õ#ÌéáëÒz4Ü·öqn2…÷j2IüÙüe•å9._Å?ë]L¯ŒÇÕtÞ5VQké¥Ô›q“~D©º±ÖPŒc$ùQý5üý¥ýþ)xŸáÄÍ/û'ÅÞm.K¸SÌk[Í;^Ñ´ÿøYÓ¦–(^çK×4 [MÕôÛ“yöW°ÈQ”^{ᯃáñÿŽ|5àëj×Öúö§ Æ»{÷vÚU³+I=䶶ؚu†v#&öÚ$jLŠB…j•ã†…9J¼êª1¤—¾ê¹r*vþnvÝô9qÌ6[Z¥°˜|=L]ZÐŒë[JœªÎ¤!F3©VÔâä£Nœö„e&“á»uëÔ}:Px=s_Ô·ì¿ÿ’ÿ‚tø»NÒæø‹ûIÜøÏU’}B?âO€¼hd7ªhéý¡¬éÛ7~ò+­VyT2–+궅ÿ^ÿ‚Úé†/øçJ²–@¤Í}ûRéÖºˆiãßÛÀº´lîU$x"[I]ÕY‚º/F˜UáÙºxü§9œâÚ”pØ •­gg­â›O³·™ø~Qô‚áÎ"ΖGüâ¾w‰•eFð^çÐÂTn\¼ðž*–á~¯ ®µµµ?]§:c8çñéêzÓ+ûÿ‚¥ÿÁ¿b?°çÄ?ÛöPñ¿Å/3Á:_…¼G£é‡ˆì|qàÏh:çŒü=á‹ù>Ñq£Ùk–mgg¬ÜêPjêSCØ.쥊C5¿òá/øƒÆÚ¢i>±{»–äbDvöñ½-Ìïˆáznsó1‚˜á|ßÆÿ„:8ÌEeŒ–àå…© bÅÁEºÁs9OÞ_–·NÖgô..̱òËéP˱Ï™ÊtðÙt°ÕcõŠu熫…«ƒIÖ¥Š¥^œéÔ¡(óÂQi­ËQ_]ZþÉzä–¢K¿é¶÷…¾Ï­ÅÄ*ǪIpLEvôÜÈ èq‚|_âÂ?üt+}ªÜÙÚ4ð,ÆTýfø“ûüøIºN›á©uk‹0ÑIªk÷×W—“¼ckJÑÆööQq¹’;UX÷¿/Ë_7—`^cˆŽ8Œ>ɥψ”£{l£7k®‹Ôû¯ >\qãWžgÜ?_(Àd¼?Zl~;3ÅÎxš”½¼háð¸zU«Ôj“R•IªT•Ôc9IIGð³$ðMôç§ëÛÿÕ_BüðŸámgOÔ4;ìt½F'·kh¼¨¯­Ø—( ;Vx& ùâ”ðáúΓq¢^Gcu$/;Xiwíä>ÿ(jºež©¼¹ Ésj—‰mw Ð]Å5ü!ðWÅïzÿ.ñ~»:Ãg§X {•e½Ô/%)k§iöû¸½¼–("Ê©bîˆßMƒ£[0ÄG ¥SŠeB(BU*ʳŒgìã¦Ü¹e4–‰Ýìíý ©O-ýà«ëÕ]ëc6§¼iŒ±î’ÚÃ[´Ó®/cŽw±[¥¶¹0ýgÂE“ÐúÆa–Ô£JÉÍÆ­ Ò¤Ÿüÿ… µ'EßFªÆz3Íỵ̄‰°õq|?Ãæøjuk`gíéÂ*×›”U½ž«÷ŠðÕk©ðe g¦OÐf½·Áß³?íñH“_ø}ðãWŽ´(‘ä—YðwÂßø›JŽ8ñæ;ê&‡}h¨™Ù¥só^6#uB…jî?£Ju9}y#+mÔô*â(Påöõ©Qç—,=­HSæ—òÇžKš^Jìñ+ ñ…ü4ðÃÏŽ1Y[í½¾ð.£¦YøºCfâ? ë—Rè:•ždÓ¼A§Î»m4»†OäKáDÿfø•à©HÂi±°ëòOp¸ŽvHq“Œõq_êùðãáß‚>7þÈšÂ_ˆU·‰<ñà¾á?é36aÔ4}g¶¶wH’¡ Ȳ ­nba5µÌpÜBÉ,hÃüÄÿjŸÙ{ÅŸ±íã?ÙëÅíqsqðïâŒZµqƒþ_ßÞÛê>ñ*Gµ"ÿ‰¾…sgsp‘f/ Õ²±òI¯äÜ?Ùq–g†›å©—ñ>"¥5´½‡öœå7\ÝÙY4–Çóg†¼A%áLë -qYoŸd˜šO⎎;O'gÊ©Çêý¢éEiÍ}hv_ã׸$qǧã__|#—Ãsc*;ôÈ=ý:zà qŠù FÝGo‰X{päg>™<,WÕ_ åÅÅ·¨`1ÎOÓ8ã±ý?«xòšx*¯–-ºmÞË›T–öóèôÖçû‰ô.ÄÑÄp¾GYS¦êK†ýç$}§ðã§?/7MuÓNÈþ¡¿k/øJÿà€ÿ S#ý‹öqÕoØã2H?áñÕ_Ì]¯ˆÓû(µã€«ºÜK˜ÕAÅÀ? Ùøsáö—v‘'ö†¿ö­íÁE:JÍöH|Á–h£· ñ¡!CJìæ$ÿoºøOÿÁ ¾9i°Î×/ìÑûBé²Elª÷½µ¯–8Œ*7oÙܹ™vºî ¬ˆ/€ž,³ñ'Ãí*Í%Oí ?ì»ÛrêfHâfûÆ?¼!’ܪFØÚZ'PÙRóßÐþm?ãÜ>7‘ciæÙµL­VQOÚÖ©EÖt¹’ýóÃÆ|œ¾ÿ²Um§1ü÷áþ)ÁøýÇT1ê’Ì)ñˆÑÉÕn[¬EN)«ŠÅ{tŸ·ú®*N‹ÒulÚ»=®±üC¢Xx—FÔtMJæ´Ômd·‘]CfSåLƒøe†@’ÆË‚² `A¬ÏxRÛÆžÕ4 ’#k¨KZ\÷´¾Œmp¤|˱Î×+’Ñ<‰‚ ò›Z±Õ´-VÿGÔšæÞóO¹–Öâ'•ÉY"b§Øe8ʲ’¬¤0$×õÏŠ>"bx/Øàñ|-O8Ê3Œ-z <ÃØS”Üe Fµ€ÄE?g(Î/Ú5RVJP•¾ïƱ~<>_àÚYþEŸà±®Ï5xjrªã*x¬# ,³/c8T¦ÝVªÂRj)ÂIz/ÂÝwXø]ñÛá牴9Œ:÷€~)xO[Ò§ÜËåêžñE…ý£>ܦæÍ7¯uÈ#þž?àœ²Çuñ‹~6Ÿ«Ýij\ßøS^Öü2.Ù×{ôý:õts#¹f’á4Øî¤$´’¿΋þ “û;_þÔŸ·7ìíð²;i.´Y¾!èž,ñ³vH¼ à›È¼Oâ„–UæÔ´Ý2MÖbc¾ÔíÕ—p¯õ{¶ÓÒ-Š–žs·±ì@#=øÆ3_æßñî‡8¯.ÀrÒÿh¡SR„äª:gˆpÃFNÉßÝšR´¹o¢Ñÿœ\kÇ\]áç„\UÄĹï×Ç殎y6i‹ÀU©JŽr­Nu0ó¢±4éƵ*rç‹‹’¿-ÛKù¹ø½ÿÒýŠþ é:—Šì¾ÚxRðú]k7~;Ö5ŸçÏgo<¾}¶«^¾çD¡š)çÒåž7UhæF\×ð ñ [ŸÄ¾<ñ—ˆ®ˆ7:ïŠ5ÝZ} óu Næí¨U7Jv*€ª¸P¯ôéÿ‚€ßéžø!ñwź¿O†üâíkQc—m–Ÿ¢_\ܱ…Hi@Š6Êdû¹çþeÞ5ðÍŒŸï´_]¯ˆt­{X†O ÍfIolµÉ–].Ñ¢1Å2ßÀnO»‚H!™/a• )À¯ÕqÜYCŠ°YM (^››—±¦¹«U¨©S£J*ó”R”)§ÒME[WüôGãŽ/ãÎ%ñ{‰øã>ϸƒ ^Q‚Áæ¹æ?§J•ãñ9… U±5jBŒ¿{ƒ­Vœ9y¡MÝGOÕïØŸö€øÁð'á‚õ߆^?×ü}¡â…,&†m:êõ»©o´}FÞïGÔ¢mpÞ]ýÔE»d¿¯VðUÚóâÇ ¹71hºÕÄúzë~×ü?®èó΢-Sv®–+iW¢*_8~ÏŸ´'…íuσüã›vµ†{­?JÕ-·ô•‘Aòõ¿ Ü4:æ('kG¨Ø[åÃm-ŒŸ<ý²>~Ï¿´€|cû3üKÔ¼%ªß|Fð¦­x.]SN>+ŠÖ c<^"Ó4á$š•…Ö‹p°êzf®°'Ùîí’{y ÄTŸ¥ê–ÚŒ3Û´ðO«$RBï±ÊŒ9P«Fèy‘RšúÃÃüwû2xÆŸü©Ûi0ð§†5¨<=©jq¨Yñ5dž­ä6Ï$K{uëòÖ|è Õ¼S]Áqkñ7Ãñ— ar\Çœd~3c³ =xÖyFCË0òÄUÄÕºÃa1™Œ3 ôœaRPËiÔ© ¤Ó¼Ý~‹CNðó"ÍøΧˆ8¼weYa™ÿcã²¼?µ©Cƒªbs®FZsŒ]&Ö ”ç̬âÝ߀Á1¿f¯„~Ú÷ºWƸtÏøoá·Æ ‡ºN©Ç Ú«¯XêzÅ¥ž¡©ÚL WQËs¦Ø[ZY;ݧÔäF’kõ¯þ qûjøÛà×ÅSðî/ŽzïÁ]ÖØMðûÀžƒÄ>Ò-|-ms.›a©\Íá]2®æ»ºÓîeóµ+™Í¦ÞßìÖ‰ cù‚øñÞïÀÞ-×åñF£zÚï£Ôu}uZi5 7Äk{%Ü$f…^ælIuxoÒ72yësù­c†_èOAýº> |røe ü-ý¿?f_þÔþÐ#x¼ñ—ÂÔžø¡¤ÛLH²x“O¹DÖK¨ˆ´Öú†‹s7”VMNðý¥>×'–y:¼1àî&ʲŒ^!̲n!É1ÿRÃãgšÖÎiæx.+È«æKêÉÕÁsdyŽ´£‹ÃaiQ«„ç…JÐ_‚øc…Âe^)xƒÆžËø›ˆ1œ5 ›Ã|³ˆ2úÎU•akc(b±õ²Œ.3C …â)Æ\'Ö¤¥QÑ©}œ´õ_ØŸÅ^5ÿ‚Šê ð öŽð.‰ûc|×í÷ÄmZMüIø1Ïú*x¿Ã_åm;ÄÖSi2Oow7†õ=Vîîî _³éq¼ÓÛ^ÿ?ðR_ØoÄ°í=â‚wú£ø‹ÂW6ðø§á·Šd¥Æ»à­NYã²mF€ŽßWÒï-¯4R4 ×6FöÝÖî¬Çâ‚gïøk[ÿ‚Uj><ýž´m_í—4Š¶|AMnïM „ïìeÖuÍ~M"ÓQ×þÑm9±³Ík=ÂÝù[büiý¼þ-x«ãGíâoøËâÞ¹ñ£]]3BÒnüW­KfÑ[\ØéÑCEÑ`Ò­4ýËFÓõY¯Íµžcm¦C4÷+n.>kË›ãœgæ\m‡Æg4øQáü>O&æÃqižR¯VU³,vz¸JT¥FÔê×¥GN¬ Bz’«Z?g.ãì/æ\Wâ G‡a™q-:+õØå™.t°Òúß×(UÈ°˜œMJØ8Ç ªCMû%øJªTåZ­áÿ¾&éß WÌÚZ]Ÿ’qçœGŹ§V­¿9Í3ŒVy)en®–‹¨ªÕž {YÔ¢œ£ù{);{Òg×V¿µ¦·¨ŽïÂÚmÅàE_´Euqo 0êò[Ÿ8¶î¤$Ѩ=0Ξ9ñïŽüAsâBÖÊÎæåcGŠÆDD¡Ÿs»I&À¡¤v,ø¹äñôWÓgœqÅ\K„¡€Ï3œNa…ÃN5)R­)*‘‹ŒjNTéÂuf£).z’œµzêΞ#ñx»‡Ë8?Åæ˜,-HÖ£B¼hE*ÐŒ¡µ'J:•ª¨JQS«)ÊÒzêÏ×ÿø"oí½ð‹öý²-þ#|rÓïßø'Vøw¬ø£MÓ$Ö5˪êÚ­gâHôë|ÞÜؤú(°Õ×OIïÓL½¹’ÚÖéÓÉoô—øKûNþοü iãO‚Ÿ>|LðÍí¬ àÿèZ³YùèÅ-u{o´t-J-²Gu¤ëVv:”ñKoyi ÐÉÿM\µ¿½±“ΰ»º³› <Û[‰`“kuâdlÃsówÍ?ñ…Ywç4¸‚–e‹Ë3HP¥…«*qŽ# ˆ¥FS•.j2”%N¬yÜyéÔQjׇ2æ‘øƒ‘bøó„¿Õ*¹­L¿NUçBp¡Êœ±u9¡ÏO™9%-e{é{YèßÿÓøÁàÿ~ÀŸ´0Oxjø¯Ãz_ƒ|9¢ LMg^ÿ„¯Å¾ðþ¹‘§}¯íš´Ð5MRþýmb—ÈÓ­î.&Û 9çgà^x#Åþñm¤QÝ\xoU´Ôà·œb9>Ï?œðçÈ ”e¢vY•ÎÝj…óï¾¼»¼“ºêâYÜ÷Ai]›< àvª~¼wõéþ5÷|#•Wá:#K5ãsœ£šä8*ØÏgÉWšÎ D¦íù, –Ý ª¨À»x×ÅÿÚSâƈ-ô¿êvúw†,§ûMŸ„ô[NÐã¹ µ.îaó%ŸR»‰r°\jWOl¯(µò<ù¼Ï¢¼/ d8,ZÇaòÚÅE· ³uk:MîèFµJ ÿëÌan–Ôôÿ×(Y4¸z9îe –qQ©—SÄÔ§†­ÚЭ8ûX+/r£”|‚ºoxÏž”Íáëº Ä¿Ù:¥íŠN ’â+i£Žâ<’Ls,ˆrr¤æh¯rp…H¸Î1œ^ñœT¢ýSM9 Êœ£8JPœ”gã(Élã%fšèÖ§¦ë¿¾*x–ÅôÍkǾ%»Ó%P³éÃRžÖÂä+_µYÚ4×EXîV¸ŽFS¤1ædä’Ü“žrzžþô”TÓ£FŠj*t“ÕªpŒ}ß*W~léÅæü|¡,v7Œ•8òS–+[éÃù`êÎ|‘þìl¼‚µt-Qñ&³¥h=´·º®µ¨Zizu¤(dšæöút¶¶‚4\³<³Hˆ  ’Àw¬ªýrÿ‚R~Î3xÿâmÇÆ-{OßáÏL¶¾kˆwÃ⻘ògˆ2•eÑ,ŸÏi&;ËË&‹÷‘9‹‹6ÆTÀe˜ìeN½|>µJRoÚÖŒ²ƒ¶¶”ùTŸEsó?j¿þ x[áî‰=µ¦£â}J=>»Öakj¾\“ÜÜÍ°3´vöÐÍ6ÈÔË!O.0ddýÁg?dÉõ_xGöªð†˜$¹ðÌ:‚~)­¤*$:5Øü'âk¿-–;+·>¼¹•šHã»Ð`PÐÂ|ŸÄ¯ØßVMö¢ø~ä—⇭&-¿gÔoSO¸ ¡_rnŸrm;×(p#«Â|Ï Å5¸;ÄØiáèbó\¯ ĸJR•SŠÆÑ¡šB…Gï§í'BzÊ0œnùâÏͼ+ñƇŒÕñC†¾«O=¡ÃÙå<Ç.MU¥•ñvI®ñ8:´å.o«Ï 8¼4jIJ¦‡”äíú= ~Âÿ|b©âEÔ¼y­"´^jWSiÚbL£/ö-+N–"±‘þw|Ìaå“´fë¿> YE$ß|7(aÿn[®3æ<¥óÇ$6{ñÍ@¿þxÀ¬ú¿†!óeÃJÖ7·¶ #å´éNtˆ à×¥øCöLý›m.’î†Úf±8pëý¹{ªj–à§kY\^›)”Ÿ¼“ÛJ~\­¸y?x%áö \§ÃŸ ÞMBø̇-Í1•áêëâs\&3V¤Ö³r­%)6Ûz[ü¡Çý81*•±¼Sœø‰ÌaÍ9ap¨apžÖíû:TèæX\= J^ì\0éF6j=ä{â·ì»%÷ÃOˆüà]VËà lô­SÅÚÕ”sÆÏYñák8æ’鼯´ÉªkÚzEobÏuä™®e·kH'¸·ø/CÐu¯êVÚ.¥ßk¥ä‚+k in®%làlŠvÀÎ]ȃ%ˆ×÷£ÿðþ…oÿãý§<-á­NÐt«o‡Ö7¶Ú_‡4»=:ÊÚ=ÅÞÖYaÓì ŠÚ ôk†Ž$Xa3JYv–ίìmð;Oð_Á3âÚ|3x³â½Æ¢ÚƒÄâÏ@[™aÓ¬-™Ô›x®Vrb#íF[4¸¶„'ñwˆ9xÿãlëð¶MÃþð†IÃkÆ8žÁQ¡BpÁbf¥Œ¥€¥ì°Qͳ¬ÑÁÒ*t0êUj›§QÏûèíôΗø%ÅÞ gYEz8Œ§ÄJœ¹V;3–3¦ò §3¥_3ÆÊ”9y*WÇÖ¬¨Æ§%(Q¡ Jröót~ÉÒÉ//¬4m2fŒ¿ö}Öµfor£‹csk¸ÇÈ÷+°²ì`ÀxgŠ|âßéWuÆO–ïåËm2Ž [Þ@ÒZÜ/bb•°r?a¾/ëïáÓ,—,Ñ+_)ÎOSŒðE|‰âmcJñÖ‘{£j+ÂNŒm¦l-nÔÄrbelo)þ²6’7RŒàý¦EôgðÆ,§:ɼân$ÁñÞO…ÄO.YÞcÌòœë„¥)¼6|®®.P䥉¡9Ó¡9®|5HÝÇú7€|^âìõPÌ3¬³,©”bj%9å´qjac)%ÏNuq5ãZ4”½øM)É-&žãx>ÿÇÞ-Ñ|'¦¼q]ë^BÍ.|¸!Š).n®™…½¬M±~gÙ´rkî ~ð•´þ˽Üqí›PÔØË,ÒY’$)oDD%S ï#vø·Àº­ïƒþ"xgT·%nt_éò2°LÞGÅ»ž3Ì&X%^3Œ ÇOÞ¯~Ëþ!ñ`7^ÕtÉ£¹ãµÔÚ[Iã.2#2GðÈ£8Ÿ$žñ öýéøà¸ëľdÜcÇYy‡À¸qœG,Ë]*´ç U˜Æ®׎>…xâªÆ…Zë–Š‹„S¾^<ø…W‚ó^†3?Y&A›á1•UVxhÖÆa*Ñu|M4¥kˆ£*qœ£M·7¬¶ìÿ`Ø£ö@ýµ¾|XøUã¿Âñ·áþªºß‡~&x:òæÃÄ/áAåY ý:yn4=n^´ž;´¾±3Ϧꖶvwv2@—‘~ þÒ?µÿÙ»ãÄ_‚~%¼´Ôµ_ø‚m(êv;–×T°–/ôRÜ—u-*òÊ÷ìò%¹œÃ!-5ý*þÀÿ³WÆÙçãjüP›Å‡GÔ¼7¬xg_ðµ²êŒºí–© Éf$œ%•µ“éšÄ~«ʽԭö9l„ ì²'óAûC|B×>+|sø±ñÄ—\jþ.ñï‰u›“!È·K­Vå­¬b^B[XZy6±)ÄVÖñF¼(¯É>™˜‡Ï<áþʸqñ-xæTrüª†/Ž?V<Ï [+ÁFžNïeWÕ*oÙÖ”2Œ¹&ú2ñgq'Ž¾3Ç+ñ\oá,¸{„ó¼¿+Äc1”¸[Œ³Zؼ.c—ex¼\]Z9}z9V'0©„¡Z¦œñ´!FªÒ­§á¿…IqáëvõZéõ(Ä)"bfav‘æHÁrû²‰»K.ãö_üçá¯ÀÏþÓ:WÂ_~ÓüOá/ŠºV¥á]æîêÿN›Ãþ1KÃ×vWºmŵÜ2jÓÙIáäT+ÜêÖ’JV($5gökøuqãƒZï¾7KÍfÖÖYb&7·‹R¸+’æ 4’Çæ)m¡< –õöWø›kã/ x§Âº5–«á½{I×´»é®®"ÞéZ…½õ³2ÇlÒ•@¬ÁܼÐWñûË<.ÏøŒ2n*ñ.—qF#+Ìi`qÚØÜ«„Å:r©•ã2œU8*UíUaçáêʤ£ÍN´5’]â/Š8,Mx/1ã9ð¶>¦>ɲüç «–âr|t#Zž[˜a+Ñ”eN®  š‹“Ÿ³•:¼Ðœã/5ÿ‚”Á=­?d-[Kñ—Ãí[QÕþø£V›IŠÏZ–ÞmsÂÚÁ‚K¸tÛ‹˜b¶MJÂòÞ·ÓïRÙ&…lÞÞû2´š~ ð/‹~!ëvþðv‡y®ê³å–ÞÕl1 ÓÝÜHÑÛÚ[!aæ\\Ë)Ÿ™ûWíGü“ö‹×þ ø‹áwÃEÓÓ@Ñí´Aã­cMKƒw%æµ~÷M‹ËtmíCGe®¥%²EhSSf˜4± ‡Ñ¿`ºO…~ xÄ’ÙÆþ!ñôCÄãÂ<Ác,³.‹g²î6ñéþUÙ\…7wK(«Ïú&pN}â. †²n=â V•8ãkæYí*tãÅäøllè`ª{ñ)c±t½—-yÒ÷©J8ŠÔåWž2ùþ ñÓü=ú)ð_ø§R‡qÖmØ Oi\Æ/Ž[ŽÍ+á”iÕ’ËpŸYÄU £,O59F½ZµåÕ÷ì/ñKJÒ¿´5MWÖ“Äj%¾›Ëb¹1It–b=ËДWMÝŒ1ùcÅÞñ‚oÓZ³…™!¼·‘n,îvž°Îƒ‘†ò¥ÌÞs_Ú‡þø;Z’è:vµ§¾æÂþÝd¶ž3ÑȃR8##ÚºŸðK¯Ùö‡ð±¥h^_„þ7»Ó.†‰âo Ýß¾™m­ù Ö:¯†o¯'Ó.¬’ä!º‡O]ËÀÒ¬7PÈUÇúI⧀?Fü£¥S‡1œc’ñ† R­ Φ6Žq’bkÓ§xQÍpU}ž&Œq\¯—J hðõ¢œóïþÓ âL.WâŽ[Ž†W˜ciáåœd™] ˜<¢j±‚¯Š„qƼ5ÉÔ«*x|mogv2“?…”GwXãF’I0ˆˆ 9fà bßÂ'8ë^›eðSâµý’ê6þñØÝ7Ç,öZù‰Œî‰.D/(ÇC°=Oú ûþÌö°üYø³¬­ïõÏ„'¹ð]­« ’Î-zÎûQ³¿Õ)hE€{HªcûD“l$-ÑŸ´ïÅχß5/¾"‡T¸×µm*=j+}:ÈÃxwÀ\<¸«7–_†Ìñ8iQÑX\NŽ>2ÃÒ£É)ÓŽF­LEJ´à¥ZŒ&õ—á®­ kZ ïk­iwú]ÂõŠúÒkgÈÎB‰UsîF}ñXùöëŽÞŸ_Ö¿U<ð÷Ä߶%üÞø)àoân¦ñ™ï4í;Of…à‰}«_ÌÑYhVáÜ$z…õ嵫;„í¿c|YûH~Í_e¿ˆðÿã‚õOkw6k:]®£%•Ôz†s4ðEyc¨é—Wºmü)=¼ö³Iiw2ÇqÇ&׬>ÿG,ƒ˜^ânñ†üCàž,¡ NQ˜åxì³*4êÆr¤ñx*Š²t*{:Ž& 5iΕzTjr©~•Â>'dÙþm>Í19nMÇ40²ÆÖáJ™žY»ÁÂÜøÈe³© Â4#tå9áýš‹æIGSǼ'á_Æž%Ð|% ÛIy¬ø‹V°ÑôÛh”³Ë{¨\Çk€ ¶<ÉWqí\¶8¯íöHø¥|øYàïi‘¤¯£iÐRüG±õMrïý'WÔ\X-Åì’ù³1‚Ù`·Ü kù—ÿ‚tøûö{ø_ñ¶_üz×dÐEÒ$OßÍ¡êºÖ—g®Þ¿Ù®o¯SE´Ô/ ¸ƒOi¡°”éóÛÇ%Ì·Io,J?¦ ÿÁ@b X`y?hoD®‘8ómüE…`o‰ô5’6£uGR º†W•á‡!žp†/9Ïx£†°ÙŽ;W C*Ææø >3ƒÃ4\F½zu`ñu¯*w*p”eï´¿Ï/Ú#šø³ÅœÃ¾ à8Îxg/ ³œÏ3Éxs7Ìrü×8ÄÂtðô)bpXZÔjÇ*ÂÊ|ñö—XŒeHÊt£)~ƒj |1ñkáÏ‹¾øÚËí¾ñï†õ? ë0¨_2;mJÙíÖêÔ¾å[ÛLwör20ŠêÖ …à ~-ø;âŸÙSö̇áO‹¿µ¾|^Ðì#¿Xe‚ WL^²›HÖìÄŸdÕ´É-¯íðw*N°êØþ²5/ø,üóÀ6ÅÇÆk¿Þ ex?Àž6½¹p¬Wlwº¶‡¢hL\«ή8 çj7xLf&žq‚«S.ļÏZž_R«<4šþ<®{}Å#‘îOÄg¯Nõôg‡u¬4y|çóÇL~^æ¿3þüið'Ä?hú¯„|W£ë1ÝÙÛIä[_Aý¡†Þ[k½>G[Ë[˜ +,3¯ € }…§øËIÑá[­_VÓ´«Qɺԯíl 1ÒÜË`FIn2­q_Òß7ÂÒÄ`q3Ì(âèsQ«‡©Jº¯°|’ƒ¥ËÍÍuËd›í¹üEâW†ùÞ_œfYf+$̨ã0øšÔ*aª`1®ªB¤£Éì.vÛJÊÏ™ZÇmûcÈ5ßØ×öÒËÉ™¾|B™G2<Ö>½Ô!Apym‘2ŒÁH8#ñ÷ö%Ô4¯‹?³ù´ù"š÷ÂzqðF¹m_6Îÿ@con²ª¨Ûö%´ûÀYAa9ǘC9õ?Û«þ WðÀÿ>"ü%ð_ˆ´ÿ‰¿¼àýwÁâÇÂ÷AðÝ¿ˆtû.çTÖuø]>Yí!¸šH4}>{›Ù.#D¾þÏŠD™¿œ¿Ù“ö¬ø—û.xÆ_ø&k]GFÕL1xŸÁÚÇŸ&ƒâhKˆÄpM ¶º…ªË1°Ô­ÜMjòººÏm$öÓ~ÃôBñƒ>¥Só>=ÊsŒ³†xÖŸö%:Øš)fRTéW¥›aðu\+Ï G¥oJ¥Z”9ù!ÍýÕôcú0x“ý8Ï*Ädø®âþ!Pã>¥ÄêeßÛTid4rÌu*´ªÇÛàð¸ØÅGŠ¯B0zP’VsªX?¾x ûYŽëÅþ ð׋mŽSì~&Ñ4ÝnÍwcæ[mJÞâ%pVXÐ:€WpRÊÿrCðSöCð/‚üEã¿|ø%aáßxUñ&¿sðïÂÇk¥hÖ3ê7³4¦$`$°@̤œrÄ×á„à·?lt„º×~ üB³×b‰ éÚ^§áûë .ùÖ FâK–-Ü+Éc¿’Yþ}~Ü?ðU‹µ¶…/à icá_Á™&ŠmGÃ6:„·Úç‹äµž;›OøKµ…ðÏakq7Vš-¤QÝ*Ïy&£4²Ûþ™“ð‡xaŹ¯ˆ3âi™æê•18<¯(ÅçEW(¿bñ|ñÃRÃS„šu¯z&£7óÜ—è}ôµñ2¼Ÿˆkñ?†|ƒÌpï>οÖèR¡ý™B´g‰¥“eù6mZxìf*Š•<5éSÃ)Î3ÄקÊß)|2ðÕ¿ÇÚ–æïHÒ Òü3«xÿZñ½Ö›eCc¥xpk“k#L·Š(Ö+{sÁ¥Z¢F‰–0¨6é—À¶¡c·ã€gö9ý}ñ_Íìiñoß >-Á}âù§‡¼E¦É ^ê¦&•t§žîÖæÚöeŒ4‚Ñ'·T¼xÕ¤Žyn©þš¾jzNµce©hº–«¦Ü¢Im}¦ÝAygÂæ¼5—}CÊxr–'Ç8V­‡«^îž25qrrÖá XN5&ª¸F7;‘õ×€#Ilç®å<ã·NG?ËñüþÛ³>³ðÓö×ñÇ ÙIsŽ¼em®|?„&ØåÑþ ^ CI±ÁT¦‘5ìº5ÅÁ…´é§m‘0#úÄÒüM¡ø[O—Zñ±¦èZFŸy©ê÷¶Úu…¤h 3Ïwu$PD¡FF÷wŽ™¯æ£öîý¶|/ñ/öËð'Å_†0A­xgà¢è&ª=¼–kã!¡k·ú¶­6\GttÛÖ¾¸Ó¬.%Ý5ŠÅ:¬$¢'ÁpO9Ç^2åðÍ#Åp] ,£Ä9ÌaVtrÚ51Ø?f¨ÕiÓž*­%ˆä¡ Ô”!*œ¶§¯ã¿@øñOëpþK‰ÆpÖeÀ¹‚Çãq4êÑʨñ¼+ðÅ'Š—-b1ªâðîŒdê}Z­jÞìi6ÿN~ü ³ø}à ø.Î$’=J·´žtC‹›æ->¥w†»¿šæåòR¨à}à‡q´ðoÀd'å?Žr¸ú:W+û;|UøMûAx_Mñ7Ã麤—6±Ë©ø}®!‹ÄZ ÙQö› [Jr—q=¼»£)Ù]"­Å¥ÄÖòÇ+}×á ,McÚr¼ãë:zãÔo#Vh¬¼Gá»ùõkXnXe :¦“­n°Bspt}M”nä{wüwâž‘ñàváï´F|KðñG†u«"ãÎ[æ™ô+èãÎám6›äY‡#þ>¬.€Â„®ãþ ûP|»ø1áÙ‡Ãæ•âψçÇZoüHš=ž¡mà?DÓ5[-u;ØX­õÝb]UÒ=2)MݦŸms.¢–±ÝØ ¿æûá7ƈ¼Woã/‡~ ¹ÐµxWʸDĶ:¥¡u‘ì5K)[ßYÈèŒÐαÕ%ˆ¤¨’/ó­X¿ xªxƒKŽOR2§Ns‚•l"œ[‡´£8ÆM^Ôå'J\®2·úKà׆Üaã÷Гƒ8oŠ°XŽ⌣™ÕàìVoF¶ëùfŽ§’c1¸gMb(`³ ·<:Ž“œá†ÃæPZucí?¸o8ŒBAÇ“êq’;tëïDZ¯|“â&…ðÿÂzÿŒüUªÛh¾ð¶}®ëz¥ìé­Ž›¦ÛIuu4’?GXÑwI,Œ‘F#ªŸæÀßðZ]_GÑàƒÅÿì5Mv±-ç‡üU>•¥ÝÌí…þ™«ÜØ¡#æQ|sÈ «ñ¿ígÿøßûTé­àÛáaà/†â+“àŸ Éq'ö¬°8’Þënu™ ‘VH`HltȤHåM<\/žÞ—øÁçØ)à!Fµ?ig*µ¤¹)Á¦›¼ÜÚè’굶«ù*ýœ¾3q‡àðjÒŠ\»ýš¿kÝÃÿµ?ÅxµãÒüñ»Æúæ³-ü»¼¿_ÞëÚþ‰}rNí–m¡%ž¤üù^d7%„vέûSñöKø3ûXxkEƒÆIs ýŒw†¼oá{‹EÕ-m/KäÇpñ]Yjš=Æõ¹ò¤‰¼™í'¤’I?‘/¦}~•õ_ÁÛSö‹ø mo¥øÇ×m Zñoá½~Ú×_Ñ-Ô±vŽÒ×RŠw±˜–+a5¯ÌÌà ÌO¾"c2 ŸØì,ç ÅÝÕËñ)JrSo–MEþó÷±’”*R©yÓšv·ú3ã_Ñ“ˆóüç$ãßø¿ýF㼃-Áåp•z•é`ñø\» Y¡K*8•ƒ„p˜ŠUð¸Œ6„aЦã9Tþ·¿àŸ?²?€ÿaˈ1xÅÞ)ñN£ñ6O z÷Ä?`µ‚+_ e´«k+ :ãWY5ûö¸¸¸–f‘L1Æ°*Mç~$ÿÁyþ1øGâGíðóÂÔm5Mgáw€®´Íg"̶Æ»«¶­‹q*dë ‚{¸w7ÙžüA&Ë„ž4ùgÆðV_ÛÅz$Ú—‹´Eqoök‹ÿørÛOÕæCÞ=NúMNæÆY0di4ç´e‘ØFR0±¯æþ¥©jΡyªê÷×ZŽ§¨ÜÍ{¨_O-ÕååÝÄ,÷773Ë<óJí$²ÈìîìY‰$šòx›Šáža°n-§”åYc¨ð¸HMÔPu%RrQsY¨º•ªTnUœäÖÇæ?G¢‰œ5ãÆiôŽñÇŒòþ"ãºùF'*ÁQʧíªW–'.£’}k3ÄSÁeØ(QÂdô‚Áá¥)µZ”åC’­,þ¾”dúŸÎ’Šøóý9úúÿŸçIEzËSÔtçó4ûë«):µžXñŽZ6SÒ¯]x›Ä7Ñoµ½Vò0b¸Ô.¥ŒûyíŒ~U‡Ee*%5RTiJ¢Úr§5é&¯ø˜Ë ‡œÕYУ:ŠÍT•(JjÛZn.JÝ5Ðq9ë“Ç99?™éM¢ŠÔØ(¢Š\óôè3ÓüþµÞxSâ—į±oxûÆ^' Ÿ ø“WѨ-¦ÝÛœœó܊ਬ1\62“¡‹ÃÐÅQ“NTqiפÚÙ¸UŒ¢íÒèæÅà°xú2Ãc°˜lnvç¡‹¡KFVÕsR­ ÂVz«ÅØô/üZø£ãå ㈾6ñ‚¨G‰üQ¬ë»Bãh_í;Ëœ€1ŠóÚ(¥†ÂapT• „¢›jŽ:“{µN”cßV–¢ÁàpYu†Ëðx\-¸áðxzXj1oVÕ*0…4ßV£¯SgDñ¿á«èµ?ëZ¦…¨ÂwC£ß\é×°èÑ\ÚI Ñ°õGó5ì:ŸíQûMkZKèÇí ñ³VФˆA&©|Pñ­ö”ð„Ø"m>çZ–Ñ£J1 JŽ+Áh¯cšæ˜:2Ãá3,à Bw硇Æb(QÕŸ5:U# ]hïtqã² ‹4¯K™d¹Nc‰¡gCŽËpxºôy_4}•\E•)Ùê¹$¬õZ“O<·2É=Ä’M4¬^I¥‘¤‘äc—wf$³19$’Iç­CEÀÛm¶Ûm¶ÛÕ¶÷mõo©ê¤’I$’I$•’KD’Z$–È(¢ŠC?çú}=©(¢€ (¢€?ÿÙÍT•(JjÛZn.JÝ5Ðq9ë“Ç99?™éM¢ŠÔØ(¢Š\óôè3ÓüþµÞxSâ—į±oxûÆ^' Ÿ ø“WѨ-¦ÝÛœœó܊ਬ1\62“¡‹ÃÐÅQ“NTqiפÚÙ¸UŒ¢íÒèæÅà°xú2Ãc°˜lnvç¡‹¡KFVÕsR­ ÂVz«ÅØô/üZø£ãå ㈾6tiff-v3.4beta018/html/images/ring.gif000644 004341 000024 00000010263 05774155064 017231 0ustar00samuser000000 000000 GIF89a||õ¿¿Å¸‹ çí¢Ø–àâ“çŒ å‚ì èŠìüW*ýR/Üœâ“ͯÓ§¤×™ÞþL4ÿH8´ÈªÑqôhøÍ°Ö¥9FþD;ÿÀ¾Ë²Aÿ?>ÿB_$úP0ýùe ú]&1ýP8þGÞ™ä ®Î£×ðyõn”á‡é ÿE:Wü*Iþ6ë„ú·Ævòfø Ûž÷j'û[ñxró¯ÍÕ¥-Uü,||Eþ@pH,ȤrÉl:ŸÐ¨tJ­Z¯ØɤÓåv»…xÎu·!¬z½ 齌ˆàC¥|è‡Aôz†‡‡?">)(>"= :lŸF& #))< f' 176/..+**554¾¿¿¿¼*¹·/661 Z9 r§ & R:?v?¯&21µ¹½483,-õ-$$%ú% ûþ%øðÕcAð€„ÕPqkˆ9hð£€?xâv$ÄŽ <ê\øÑcÃ!bØZÑ ¼ôZìkÀ A›rêÜɳ'þ…Ÿ4û,x‡Â.¾Ù@ñÂv¤áBGPXàPò¤Œ¸TÐp)^>~ ~ò„Á¶­Û·paôl` 3ŠBàµâŪ Hà`Ň=rpôˆ $ <ÈaB®^ ̘Q/_M k㊎ËÓ&]}w7PÈp™‰z`°èêª rHÀŠâW“žÔ­`é΀¼ÎüPH«vçè·>éR؇oÑ4j õëÚ`†Gô¸[ȉ+yÀ`ò6Za}½+`òtiþ\ž¿?ÍÔ‘@ ñ ´—v.ø‚ 0A<…ÀS•w„`0@%þðA9œ‹:+é (Æ£b<›É³âA²6\‚7Ü …;8À4Þ1lcá¯Q4@5w0B ˆ ä`BÈN Wb)ƒZpñ… ,ÒÔRI  @ÒBia—9ð"ðPÀ|ð|öÙç\PÀ#p€A“œ4U…n6êè£F*餔Vj饘>Ñ`Ðì‰Â¨¤^Rê©—|`A ða{"¦SKXþí@ðŽq,n†Awá5‹vÙ“`±2¸›4ôø(°m£&hÎ%?¶ÂfJëˆåÎKðâ£OMýU@Æ7m¬“it1 ”@D!”o_Ëø†u`¤ ŒrØcl":AY÷xF—Æ;÷\[>ýTS?$(Œ1ÉÈðšd@ƼFèmøX’QfY.4à`œYúH×\NC§-—N§5ò]a·Ð /8Ã` ÃHÅ‘pÞzl+7Ø"YóôŒŸrA£­¶h<àPÖáàËv6.…op ÁFT¡a"$À92œ+qf0™å™þÈÌÝÓí@ñ‡@fŽïp~É‘rŠPGè>$cß>•@IQ¢Ÿ &NÌî€ödñöÚ“pW -Æsï^º Uì‚m [Hh¼Ã¬•v;‚ShzØä! ÂW´Ø‚Ëp»(†y±c Åj ¥ý€H²@ v0Z"œz ê`‰\@…Ê@0Vô(L!ñˆ t@àà%.À+l ð³ ¤BÀÃ4XM‡@ ¢‡HÄ"ñˆHL¢5µ@Lä?èÀêăXq<à ÅH ‰ Ö—¨-, à.•Qù@U¬Ú"þ~ ` vÄ@~À ¡*•yÀ@c<âkò&‚ ØypÕ?(íXÁ:Á6¹É.H) xÀÑ©é‘AdØdD<àsáðQ¯z DIŒé0–ÿ†“‹òñò—ÈHƲ¶ä¥Pj`Z?èQoF€mY09@EìС|ñ±B‡:ÎÅŽvè Eõ §8Q#_ƒi \Žœ( @Ðã€bâ· ì-`f+²™ºÐêz }bÒïÔö—AP$ è¢!7Þ¢YB]¤¼ÁG†k† Ö,·8ØÅ®ggIÆBþæ …w!PÜ|ñP¿ÄàK‰Ãìà$ò&pÀlêP³$j_k ìg±£Ih‘ãÛض‘éƒdy1@Bj¾Îå(´)PAP$Œ0¨›€9pH"â„gÃsn§“µIή;ÙÏi`Š—ƒ,Í|1`D¼U­¼ 7&ØÀ90˜%–ÙEqb×T³EurÐÉ+ŽÓ¼@n­¹iD4à-‘ü H‹ùÍ2еÊäl©ÈÑOO0;š¹Xµ¹NvË ¼e µ‘y@5h 2­Mê[9ã¸ÇÙ$r´…K^ócU¬d·ÉìÝò¶·põí§UÈA¾…þŒôàf­{qæÓ¸™<µ®Ñ•.Û¨kßqÕ}Z‹: Ì“Aj¸Twå²—lüØÏe£[9Ý!-5zÁ® ì†7 J¬È¡Y…j4Ì=ˆSœÎŒ3¸Š rQ¥«Š-w¹úæÅ@ ¡‘ ¼àÛ½¡Ãeý„G&мõ¨•u‰£^KÄvÒ¦®TÁ;ùÙÆôÚŸÝ„([ÕN_ò;ÚŠVc`ÂuÔ Tè3²p];2£™ÆÝãûèlj×üRio@Újù²ë/¨%+Î{_¤<Òƒ8¥¼@ÔI¤ç:É´^ò˜¼ú=zÌc3žEQ”¥,Ìfà(Xì)¶’˜þKñ¹¦hß*F™”ëºðf0îõrª+! =çŒü²,ôACîŒP À¿éЕ õ;`Ml@—£,f¡ ºÙ‚n ò_´…ɬ‡Òƒ\¡™z«ð@€½é46Žê4ìÕ W^Dh‚»â¶Ê}îÖrÝP"Ã»ß †È{+¤–))qŠìÛ†8T¢(ö{¤Sø@I‡¢å±Áp!e‰YÀo–³¼ôŒh}¼L¹j½šz V¾RÛ– €«¾ˆ¿“à’Yº„¶´o1íd1«_Ï ÓŽ<ËòNЙA”ý:Ä$c¿BØ?ªS]@úЗÑN 1q&U+‚Ìd0Ï´}K©`Mí=ûÓ?·@þÀ°j­†±UæäPµ/å q2 " kÒ7y÷(‰Å2O± ä"+aV"óMˆ¶"‰æY*R/1"kû‚% „7qÀ>á$”÷&âåg§€‚&+ýshí‚=51ia/¬ÁI%8'À¡&A&)ÅÕ<µ%d6€.ò±TfvfÝÃ=¼ã=ñâYöbNúÂ/  ëÃ!"!¸\Æ> O`)ØKòQ/î’=)u15»ãÚ7qÆ5XSgQµQ0AÇÅŇؠ `31ôQPe³Rµ“7Ñ'vUÞC/&g]…>ñ R‰ ‡Wþó=¶‰îñŠ3dšQ1>“19ñ\ËqÓ1ü‘ŠO&SFq2Á#X¤E‰wèkåa:àÑX«C¼È hf>SƘb*ÆÌ¡Œ1õ† 1ev3X¹˜<TRÃ0‘1:À‹Ô3ˆpu1?ƒ*ÖáH_¸/E¡9%c4–7Z#V¨…; ÍÃiÀfB6YL•s%ŽiS9@S«H &cJ±LAíã_—H$v < :îÑV-Ab²C;K6[´U44qUi2q¨]Ä“ 9V=HÞp:}X8±’êµ8bcfú¸¡_xõ\7Y™# Àó:&»18 Q¡þäe^è5†Ä$VPã”w•lAUnÃ>º¥Mó±¡iXö_:¦Z|"VÉ5†’;1á3@#4lÙ–IVUpÙ; eÙåP#5|b‹‘5uða^C–5à¿Ø\Â_lY§ñ`©q]â95z3*`‰2c™1™y“%;h‘b‡I4¢ù6bš¼•šÜÅ7 p’P°c«õ—´)˜±•4™›sÑb¹…"»•5ÀÅÂEœP`xÆiab`Ã8öRšñ¥Y!ƒ“öÅ4XI‡‚[`ŠÅX³V3‘ÊW–õ”5)š—C•3c/ Z €Fä5 )þ3;`\•PTè•8Ÿ¸”¶™–¸‰Y·ÓdXa <8R#!ÔÈ UµV'ð5JÙ™h&2 V¡ˆé¸³ËÁ˜óbEÐXZ$:Ai|Ù$aKÁ˜»À™0 V;âèynƘzÁSˆSÞÑQOÚI$’+7¶ ߉¢#W$ f–¥üXž“;NÊ;Ž&>7ªt7”n’0šæÈuTóÕ3”Wh¡ ñ39Áü±WkX2 5eÌpi²ac.£<ÂQõ#ЃÛh"‹–R.…1GCŠ—32TÉŒ !¥Á3vêcO£2)Þ°0)þ0åphhëŠ(uˆÿðRÑ„¸[(à ½5à}?à•°ZO÷´^!ðdÙ§~ê.KhP¿jPôÀŠ‘6ièô\pkw6‹±’ú(çAX– .¬FiÀ€ÜøMiŠ6 Ü>’kúRiÝ5!vèš•MÒdíó!µ4h¹D–‚ø ÷BNâNäTNùb@Ô¦N"9~ïtc¡—–" B?©0j¶ ²À€FÈ Ù1 ,K 4kúç%ý7 < k× µDÀ6?¶7…DKØ4%ÑZ#µ°K¼T>¾4#Á¤g|Ó»i$€C”•¸r&©0KO’lç(±?Øg,µ€,ÅR#VBLÅ$~ÈT³¶W TÛJ;ÀHŽd Pn} {ëVÀÂI|Ë^Pz àqÓâ)™g ©„ gd”•q0„zÐE¬`l€?†P„¹•KoG7'"@pvp™†‡ãrR  FŽg{>°* GtTGy”{ÄSôGyòH†y  'as›Ò)jH¢¢»¨òx§*@H«+(‘¥w#9òD ETtEV¤E\Ô 2hPWFšä_ÈFeIÐû½C§¾ìÛ¾îû¾ð¿ò;¿8;2TÉŒ !¥Á3vêcO£2)Þ°0)þ0åphhëŠ(uˆÿðRÑ„¸[(à ½5à}?à•°ZO÷´^!ðdÙ§~ê.KhP¿jPôÀŠ‘6ièô\pkw6‹±’ú(çAX– .¬FiÀ€ÜøMiŠ6 Ü>’kúRiÝ5!vèš•MÒdíó!µ4h¹D–‚ø ÷BNâNäTNùb@Ô¦N"9~ïtc¡—–" B?©0j¶ ²À€FÈ Ù1 ,K 4kúç%ý7 < k× µDÀ6?¶7…DKØ4%ÑZ#µ°K¼T>¾4#Á¤g|Ó»i$€C”•¸r&©0KO’lç(±?Øg,µ€,ÅR#VBLÅ$~ÈT³¶W TÛJ;ÀHŽd Pn} {ëVÀÂI|Ë^Pztiff-v3.4beta018/html/images/smallliz.jpg000644 004341 000024 00000040117 05774123337 020133 0ustar00samuser000000 000000 ÿØÿàJFIFÿÛCÿÛCÿÀ€€"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?ü.½ðÍ×ØßQ†DœÚ¿Ø¦H¥ŠG ×BïÎ>ê°ïŸNBæ7XÀ`W´äÏ'n1œþµÄø3âoŠo4ù|íW§6˵ ,°ãvù@‰?{‘ƒµˆ#8nÕÒÅ©Mypêf¹v78Á9äžF2?¦+üöÅäxü1Æà3Ç,“¤áuÌÒRW_*Mꛓ٫+¿úàð—Æ^ñ‚òî6Ê2Ÿìhñ½—³•Jrçû|«ÙÍ»µÙ¥ëÚôS4EÖ^r ‹ÇûM€>»‡l×Ea-´Ñ_Cu5¤ˆ~Y-î<·~O(FCG;r ëŠ÷-R=+Jømeâ8‘"ºÄ‹sDç~Yä‰â“sí$7ÝUAÍIc«| ×ná¶ñ6“ 2\éÐlÕ4)?²§Žì¢æFæX{1[t%ù å¾6YßöŸ´¯,¾¿³j¸9J 5ö)s{–»i+Jíoä~«ÏgF¼°ŸWž&œ£h¥¥ÛjÖr·Dûv½ˆ|+ã-^mE!†ð2Z+qÔ®Ÿ2 [$¦JíÎ9'ó_L|)ø®Øë $ yžHf7)ïbo=Y¾ãª¶!` n‚¾VøSáŸüAñ~£ásâ)thVQ.‰©\EËpŒJù3ÃæylåI«2î9 Ç?£^ý|?á‰,u GW¼ñ rF³¸rС°Áž8Ô„N0 “ØWÂñ&IÆRÄ`¾­[ÛÖ¥í}8Ùû:‘µýé‹‹´£«O™ré¯Ïq¯pž &e†Ö±ÍÓ£JjMÔ›ºt’P’oGtÝšÝêš¿iÚ“ÅiþðZÿf¶¥ ¶¥âhD\e ÖvE~ô¤«–œ‘•p«¦¾-ðç„´ý[I×ï.oñ©X[›Øî&r]årYËž®ìä±9<œf¿U~"üðíý½ÊYéñ܈Ë4 £3À›p2Ê F H;‹p{þgüCð&·à jkwŠH,n ÇÆÛ•¡<…™W :‘‚¸ã® tpò|¿/\3•a#”c¢ã,Mz¼²–.²“æ©*š·îÙ([–1ºQ»“~GÕáüEÔ0”^]ÉÂNò³zÃK_»r¿º¼­ãY*ß(ÉÝ…¤œ_exæóôÑt‹ƒo®|@aclªTH"„W’®âªÈ‘oVÃd—tù?KÒ.oîÄá]ñ ‡ÀýÛà’ƒúŽ+Ö4¹u¯\ØXÄ.¡ÿ„;L6VB×zÌfi.¦‹/nÌO˜“ gJ•«íóêTñ´hÑö‘öt"ªb^ABÙsÅÛš.§*ê¹\žÈûŠØ)Jœ¡ˆ^Όӌê6œbº»ÆýWmì{ß´/ x?öÞkˆ¯õh¡XÖÉQ.nçiß&ŽÐqŒA?Þôì[ñ»Nø} x‹F‡Ä:χ5YmïdšÊÊ?+í%þT–Hœ|­À@2: æ¾\ðŽ“âK}>X¦Ðmµ"æñ¢Ôæf—Vµd·‚Vóî®K*eñ ˜f/½Hrli‹oáˆîõy?¶µ¹†á¼ù$²ˆ|¬²‹z€Þ™Å~]˜a)VÊó,­U©^µZŽ¬+F²“•J“”\¥»Ó‹„ääïÏÌ›Ö6GÎfYWžpý~ÆF¨U®¥|ŠWjöiMI4ìšz´Õž§ÕŸþ=ø»TñdfÇSym#!ÐùbD‘;’¸ËaI<~åç‹ouKšy~×¹"†;c·ó²ÈÝóžŠF9ë_)i0x‡Æ·Ž¯+Yi9·ŒAfêZìeÖ)™£V Bœí xÆ+Õüã[ÏÜêúGŽ£6ÇZ‚ ,î„hè÷VÌÇ9Tyd9 Í|n;…ðÔ°Ø<6Ñ­ŽËéÅâ°ª\•ã)Nþ÷´Q¼£ :žë²¿TÒ8ëð¶[€Áå¸,ª7¯‚§Ô£Š*3”›{E«;k'{iå—«üSø™ð«Wµ×tf [@2ÿ¥hº‚`I;¼¹ÇÌå… »x#<îçÜþþѺÄ)¿âYq.…­Ü&ãEšuò ”òu+&ùÏÇòߎ´Çñ=ýÕ¥ÚÝYÙLûl"´F™¦”çËgHÃ0/¹~îá·ÉÑ¿eÏŽ3]cAð¾£ocm•¼O,ßd‚Ú<ü¸REüœBØ=§ÖÑàþ⌞+¨àóº4b£^5zöþuN>ʬ¢­Ëø×VæŸ*ˆ³ü³…± Ç×Âe˜Ç N"¾"’ö“½•á¹Åÿ*’Z·Ê½æ~@x'Æ2隤úf±ÙEÌÙ†PcGŸ˜Èç €yëœ úý7¥j6¥Xnfd$lpzãæëÀíØçé^ùûH~ÂxzêKß ][^E´3XÁp”ƒÆÀ2äŽ27g¹¯‰ÂŸ‰úÉm ‚ý˜Ÿ•TÊ¡WÔc;GbHíÞ¿±1¼AÁ¼uí¼³6Ã`*Wþ6%Òæ\¶j“« Ùÿ7Egßü¿ðGˆuk[ÓôMN=¯ wwâ"ò+©\¹)'©}kî]ŸéCAÑnY}ÎÆ+y­%2«O䑼L¸V10rA_ŽñŽ:xˆª¸ 5)b(T–uyTa8ÝNð”[sO›M#g£ßCrêyž3-ÄTÃÊ|1âjâ*%ì•&¹yµSºr³´R{ô9ü\ñ™©K«^êXŸ#ØÅâMÌþ[vœïÈ8üx® Äóiß4Ä–ÏtÞ\Œ¨cd ³2ʼnŸN: õOü1ºK ouëb÷çšÖç‘&2–Wió1ò‚Ià+Ça×õ‡Ú&¦4û1õ9¼í>ææ1s,` „ù8ùrሠž=ñ_O *§R‚«K9œ©Îž'žœ0é·ö¢Ú«+5vÕíªÒë«%¯•Ï©dóŒ³?yRœI§&ôמúÛd´ûáÕ~Á¡é/¬éqOkqbí#3Ç(iÒÞÊÙ` :†ŒÜG^þEá*þÛ^ñeÌÚœÞy,à˜[£"Éq& CÛ,BB¿»UY Âeœ8L`nÏSañ[âÍ©ëjñ›˜›ûúÚ4ó ótÿ"Fwz†Êàtæ¼÷ÆZ­Æ¯¨]jóÚ¼)qqq5±†.ÉÕE»ç…ˆ!rîÙ€sôÙM î+…̱¸|KÅÅÒ§Z”§RPJQ›-xC^-+©-_.‰£ô|« ˜TQÃc«Ò¨êéxʧ*vpMh·³óî{—Å-Cáömáý?K‹TÔK½_YºW’Gšÿèñí¸o TÞûöm|=5ÅÖ¡ãmøÿKŽÛK..4¶‰ZÞ1nª ÆK<˜•“n1œ±ùÖ‰ºµ¦”ÖözŠðýŸì×72[}ªF“Ó9XäT<€?7Íà‰Iøqm§†²š]ü¦øM*ÃE;;¼kÞU`ÀI$”ÖyÎK‹Â`èâp8 ÖÅTÆAb§ÆT'í'VR‡3„`šŠŠŒcÊåUÖ5ŒÃÑËñ8KEÎSÄ(7Ißìß[ò»^ EKš?ïõ˜5oi¶’Ú_­Öœú×Ù∤qI>P˜«2œ“Áà±á% ü1øGáéæ½ñ-“x—Å$Œ- ™/$åD©mk`«¡‹vïµJÒ'ϳ5Ý_øžþ6½“ÁÞ¹·ÒnKÇ4ZËMqhªŸ! 2C•(A0ÈÇjô‹}/Ã^!ñ5ÔÞÓ ±¹ž?³Ir̨®ùšIÀ2ª1b¬Ðµîž ø]à+ËCMÔ|VñjVmåj:@½²ò¡Sóùÿ1î*ãs1;‰5úÞE“apo •eÿVª©EÅf¬¡SVå9ÎÎMÝ´’ŽÉugñŸqnŽ/™fÆ×Æb§WÁÏëu½’§IJ’våSœ[ŠÙI/u~Uü8ð/¾ èšl¾ ø=®Kyæ…º¿»ŽÙm®Ä2KesÎ8ï××|Gð{LŠÉþÑðO[xá…#ºž×IŠù0¬»•m­Q®Ž1Ÿ1bhøÁ%˜ûïàŸ„^KØΟf³ ‡´hè¡‘” ç¨-œaqÓè;á&ƒvRi"ŒÈBIä$lT°^ôuòÔpÅÀ€¸œ†”ø3‰«ƒXšš´'Œj›£FKØÒ\Êò¤¤¹“Kng.·Ðü;‰~•ø,£K/O O•áðõ¥^k RO–<”Ü朽ï{Ú9Å)+)j×ñ‹ñûà/ÂoxJýô%|?¬iÐM9[<ÛL²Á“ Ì"š9·KìuVÃ.Í~OxÛJÒ5”ƒÄ6qc¦Þ˱˜Ú//ʕЖŒŒõ‚éë_ÜÏƾø»ûFh¿ |Gá}ÿÁº¿‚õŸøI.-æ²²Õìîça6qÂ/&šDie„lª^PœÊŸÚ7þÃðÏá5ÍÇôoxš]jÌ·%—[Õtµ¼™¤òá†Ú ./–ݘù›’c ‹ `rLç'Âg¸ØŠØì°4ªó_ û9Ô”¤´KÝM'dÖ«C÷¿>”ÒÅÐÃq=jÙeŽË^>/ØGÙâ£6¥ -´¡Ëí‚Ÿï‹Š¼[“ºþt¼F–r\°ÒÖ鬌>t2Ý¡F–&ùD‘‚ ²Àp žFkêïØÓǾðŸŠn4¤‹y,ri·±°UY>Îñmv$-K•9 îÛÁ¯¼?iïÙ@ðGÁøSÀú—¨ÜyºŽ¿/‰ôýº„þ%Ðm­á“@Õ-oü´¹Ó£ògò¯´g†8áÓÉyQwŸÆ;Í'\ðî¦ÆKÛ+ËyC#˜¥F‡xb¨[ ¤a€$ ó#‰Áã°µ²ïƒF\ðöí^|¿ œ]¹—2´œߥ®bp×ä~-pì«`\¯WÚÓ¢±5i:¸ÈÅòÇK“á£=Nó\²ÕjÝ}QŸÄþ(ð§‡leÓïtÍsTÓÅûoó%òb'vvÿÛ‚z÷iûI|:Ðeó­›•í JäyVû6?€¾[ÌÃòOÀ/‰:ÍŸˆ¼oo&ûd7ð@dÛ3º[© VA(CµüÖTdÞKdþ‰xÏF°ñ\ÖgeÔ¯ïäŸË¸Yc2Ã!ó V*Ù-Ã8×à<[œãrŒö”±.p¼ÛK Íì9bùW²ææ–¼Ž÷nîý4_ˆÉñ\ÄyRúÝ8á)Ó’R¡+΢甜«6Üom4K­ÏÇ›“¬Å³ù–â{Õ6a2r¡²9Þ ŒƒŒu÷ŸûN×Y¹ûŽ¬¡¾Ð¶ùHS¶á3ç3wò¤“ƒŸ¿¼yû=E¦i+yyö5•ÜÊåVÚûraieÇ÷A\ n¯u†ì·E­a•!š(.Ã/”“©f ÁIq•F ª'Œçúü³ŒrœÒ.tå[ (Åûõm§ï>{5t¿ºÝ£³Õ?Û2>-Êsj_XÃÎ¥' •GÛ¿+¶‹Ïúgjóehíž{Guie_4EÃ#¨©?2²*³ülÃ+ž‹Âºv™ ¸¼Ol_cGö¦áøÉO”dr=¸Áí_GÜxRþÖÅR{öw!‚!ŠI|Á•«–Ê8ÜÁË6WgÈüGiw¥j:\úäO=­´›äŒGˆUsÀ‘S8b§gʯÊßU¥ï­»z»ð£ÄðxVýä³Ò¤Ôt•ƒM˜l2c÷žÂ6’b 9"DPHÏZý8ø ⛿&¼ÖÓÔY;]V})ôÓi¶2¡$’qã–S·NÉ ù!á_é~×ä—R±žk/>TŠk[Ói¨?– Ú4Ï)v‰Œ8‘—–7cÝü1û@øÎæ=ZËCžþÆÏScBæ_³iðò\ÜÊå%¹dPså•f`岂¼¾\NYœÔÌ)}RT½y:‰{X»§&š·µo™9s.žáùp…lÚªöèT¯ Rp–"2›§M;ÝB2§Í¶Ý›ßínz]ïÆÿˆžñ.»áû}JÊÛPMfûì‹-¿˜^&ºvImzʃ±€(H#vsŽ§Â_¿hoŠ^?žM3Æ7ZDp[¦›}¯y^MÔ:w–ŽÑ¬lá‘D…°ä8·5ã~Ñ,SÆ6þ ñž¬š† n¢¹“X»m¶xšEÈSrÛ˜uH `ÈH2ýñÃÏx†Øø£àçŒtÖñ|úLK©ø~¨,¢Ö-ke‰±å’è~fÙԒÊ᧩ŒÅbðyN+FI·Nud¢ Ú»ö6彯îÝ6›~êjÇÆñmLŸ†«àð8œ ŠÆãh'KSN¦ ¤£ñ5$â¹’”¹ª(«EËE§õ¢ivzl-œiú)Àl@$Ÿ§P íÖ»‘©ˆ,ÌUã}¦ ò8‘”Ç#Œî<¶HÊŽ2OJþj¾)Ácõ o4þÕ¼ŽK¸c‹ÆÚŸü#ºµÃÆè>Ño¡ZC¬l³‚#$ÇÏÔàßå€Ò(ȯ—!ý³?n_‹íÖ¿×Eð½Ömu>o¡ékÝjÏ5àþÊÒõíP»žÂ3[P1¨’Ú8Ú5y–¿°èçðª*Xl.•;¸Î¯¹F“JüÒ¼¯eÓ}^Çø‡Žá)ãªAÔÌðxÊ®¤dðøYOŒ—¼šTâšN}ye{E=SV_ Ÿþ3øÀ_ðUÍ_ñ‘uw§èž¼ðÝ¿‹"Ö%tÒ5««1ö}5ôH F_íVë"VšQ8SÆ©è!ý¬þþ×,î¼[¨xÿá÷„¾ xÚ èí{{¡ë¬ŸaÑ‹âU›Kñl^Êò^8ÙešgYE~gü0ðG‹|k¬LšïˆŽ§ãVòßKªêq_êþñ>‹%ȱK}gN°Õo5 ;Ø%òüÙäPZISìÀ¢Èߣ?³Î‡ªxWÄqjú‡ÃÏ øûTÔµN­–®Ú–¤5[k;X|2ãL¼²²œ FFæú×Ά/.H6 ß fPÌ• û%¥[©ˆÅa£wÎ\Þÿ¼Ûm_•(ò«;ÛSôÓ.• F]ÿW³I,.KG+Ž6Q§ ËÙÁFN1’j“©7)/y+.{+½ïˆ^7ð‹ô8›ªÁ}vÑJöRBÞišk95 $–êÝ–(£Ù<ëqnÁÙ@¶EfÙýbé_¼1}càÅŸ µÏÜø«ÃÑO¯ ½@ÒuYJÅÿüî¨án$ÞÈHR_€Å³ÇãÿüWöEñïÃþÏz6“¢|7¼ˆËã»-"Åí5û ÍJñ k»1QD`X¦vvbd\ü¼Èø¿„s,]³<Ž¶ìZ†cS S£„éƵLUkS©)(EËšP\¶j\ªWý÷èñâ¾_甸O7yÞ[ŒÎé}C†+愪ex:Ñ•HÞQçŒ]Z“©.G7UÔ½6Òœ`ć°^Ãû]|7ø{uu§OlŽ&ÕSJky£F´„\Km#¨’0É÷™J–ØGÍÍ~É|YÒõí¢ÑG•}h±Ïms¶Ó¿–¡A™v¡Ï8ÁÇAŒ×æ—ìåû#_ü.ñŸí1â¿Ø?ÃÏ ý¶K­FöGד_ið[º,NYämÇÉi‡Î¬ª7-YøíûwkºäÒøcáÆŠ¶–žÊÛXZMBæÎ6e‰ ¶\yJÙ;C—lAæ¿&âŸÅU2œ/ â)c©åØxPÇVt•%S ÕNyJ1\ÑRäm^î-Fí4ieyñÇR«”c!árÕ*¦cNRxiò)BŒ¹]ÚTÔåå%Λ²š·oã‰Éá™îôÏjÒ]]…Ž9ô«›xÄqÜMÔ±*ážHð`I·œ8nß=kü6¡kagº¼sk|$zj@€xåso0’Q’U#,»›?'?%ë>,Õ5!0ñPžæY¯Úù5 ©æ–é&”ƒ%°‘œ±C÷¹'@àdTPjI ßö†š¢m@\$v‘° ˜Ø·Ú´AT¿1ƒè`<;Àa©óbå[^JjS…:\é{©Jœ‘mskŸóiý'•ð-¦½¾"5ëF)Å(òÆm$¤”"Õ“z¤Ûí{ŸWê¾%ѵæZø~ÚÖ'pc6Ú‡Ú.7ì_ßl1 ê1•@¹R3œ×žøÁzµÝªÝZj4w »ËÔP/wk3ppÆôª/Ä{«(£”hÖSK-gÔa‰L$›æ`Äwcò‘Ô}kÐôÍN=;ÊÔ‡^wŸuúMr­ F@Qae*€+/@={šÊxLnIR3ÂÅ%%Nßúɹ6£d­}5v[«M|Ëñ ¥+Áŵ}bþw¾ÏW3Ìü9ð}|1mmâ]vóG×#’ÜKöXî²Ö¥H&UŒåƒŸ1eÆr8¬ÿ|\ÐçI4è¼;måÀñ[[ÉÐE˜¾ã³(\´‹ü$`g<ö›ŒÄ—w³éÏ—}?ìÓÆ¥b„UØ-ÈázFOò^ÜÊ5?“ ÕÒ>íäbénKyŠ–˜ççUb3“Žà}ü‡C7Ìœø‚£uꟻ¤–ï•BIE§´’¶—•ŠX©Mˉ“Ärû²æµä·édÞ¾ºè‘§¥ñ5ü-©x—EÑuøC¬Ñ¾×©EbòXجr”]K’ÛÊìV*cEPhêqôÿ>?Ñ´–0A5´j¶÷j’-äq‘¸/ ч ¸‘¹r7ž OàŸ¿>x__øvÂÚn¯g}c©hº´&â4’ö$‚&T9XÝÑIÆârAËè¿ J•ð8Œ:y¾O-u/‚œ“•GO’<ÎòŠ9*ªvP“‹ŠRm6â±¾üXÒV“ʃf¿qbýCàÏísu Ú=ÿ‹´ýO]¹Ñ†• ø]SÁúýäè÷6h¾*Œ‘³zÖìWM°·[‰g’Hü8ñíuá?‰¿ƒ¡ñ—Ã=ÚÿÃ0Ùi¢;[›ùlõKé¥U—Q¯õõý!nÇiñkRÙ—+ç^B2OЗß~|øªt±/ŽRÐÞÛ]Я<'ãÆÑ¡y/,íõ±éúN´|e%ůö„ÖÐ[j¶>"ò"Ío-´>j°þÎø3eô°øü%L]w¤9ÁrÙÝÝ9ÇußkŸóå–qþ†x‡šð~&–KOsVNJÕ¯ð»i§]ûŸÛ/Ã/ÙŸÀ¿ ´Ëh|'á½3F¿š¥k«}¶êS {ÙvË$˜Œ+3÷SŠôQàsâ(üM¦½•¶­§”µXtë)¥¸Bª?³îÔÈÖÅÁ#œƒÓ_†¿ÿຠ<;ð¯C¾øð÷âLj~Áxº|M†ÎÆìi´ßÚ3.‡¨] ,bÕgÓl¬ {ÍB‘f»Ôb´¶k"SêoìÓÿý?iIµ}áŸÄ[ˆõûS§qi¬iö7/c%ÚÈ šN3÷•Â™¯”\#•åÓ¥C•T½Í¹cÉV+I6¤Óê´wzY\çÆqVw™ÔÇcñ©ær¯Bu©¿¬EÑ«V.så·´QPz©Aò¥}RM~‘Gwáéc¶ûu´©s¼yRIi±T÷,ë£:óǽrt-+Æ Öô{øã¾ðÞ§¥ÜiÚ¤ƒZ\ÂÐÍòíÞv+n;Tð¤ÕÐøO[ðŸì^ Å^×ÝY#-¤jvZˆ ]B¶²É.ÒÇïøäóÛ«]<ù+” < ’Â6„D”Ê›dóFÒâ'`ŠîåH ¯Ö¥UøXÇ ‹Á<3i$¡ÏÌœ'²zo½ÓÞú¯ÉèãÖ[šáñq©^5ðx¸b!Mû[ÖQq'ÈœãîJÞëKGcøfÿ‚ëž#ø}âÛ¿ÙÚÆ;¿ xéÑáž)#°Õâ™å¸‚æg+²µ»ÃlG2Dàà©óFÓNÔï!KÝ3X¶:dÅÖ9'H®­œ6>ÕjdtSjüÛ¶ò×õaÿÛý—ãñÁKo^‚;gáýæ›gâ›h£]ÝxD\ÜÉ5䊊L–ú\×›îå%J¤ÐˆüÒSù>M+@½Ò[X²ÖÞ‚ãÉ»·½·xa·h>[È‚O7 ¥þR3ódWóÎ'„©ðmZ¹}.g…j“…hRö‘—µ”[R”T§¼¹,ù—ºÒÞÇýýÙø†÷Gžx^ÊòÚDßzrO6y v·}ØÉ&Hö‚|Ç“#®â„÷Þðí¿„aöD©, –?Ö¤Ÿêä‹%±±™‡qÚ½ÐÛÚÍ47µÕ¥ýü5¸ê8 ÆìDÚ€çn[vwp;ó~i÷úñÖù&}R¶†M6òÊKÈ¢Óoo´q´RM0ÊÛæ ±B’Sq6¹Fy[:Ìð4s:˜<$_%>[Æœ¡gï«ýæY¤µ\Ú£åñØøcs,$qõ#B3I.fùußá掫]Õû£ôãà_ìÿ…øçñ{º×Â=-~.üK¹ñ§ˆ¾(|Cð·Úo´|ðŠMä U•íä7!$±’ÞMVÖ[ýN–Þ t…÷¶‚G ’E|vkƒÃ8ºp§ˆÂâ¹wus%{IZNéÊêýÖ—GØåtêc$ùó¼Uešöys-%ª’MËtºwÕ&¿©_Ÿ|eñsá·ÄM'öœøkã/…ÚçƒîþÝàÿxfÿÃ>3º°¹±†JÌ€[ÝXÜ]ÝØDº­¬ÍogäG{rfkxÿží;þ óó^½åßÄ; ¯„ö±Yi“Ç­Øiwb¤KÛ††Ñâ½Ó‘ÛÍš[vž'ãh³Tüñ§WøŸo­ÛèÞ‡GÔ¡Ô>Íá©üiñé‰ð”wsjžM?W·²Ðd°œÙÇ4ÂÉ–IœyM *“'é¿ÁŸÞøÒÒþê¶ZÍþ•¨4Ñø[ÄV¢ãD´ÖãEÖn ³Ô}Af4FÞD)¥²ÆŸ—q¥‡^Ëì«WŠp¨±-Éݾe­›Ù¦º6ÖOºÉ8Ë‹²YáéäŽa–a2êÿ]ÂӤ㇣ŠÌ`”' 2Q“QJ<Ë™¨¥ZÇä?‰ÿbOŠÚ$z¾¡àí[NñÖ•£}tjÓ¼A3ß@/íþ˧γÅvÐØ4RÜ*\Áµ˜¾va‚j^øá«iï5ø–Ö-åî%¼°œ… ´˜€J#q@¸Î_' ý9ê_ ~#øB;F_ ^èZ-Ö—©jßðŒ_ÛÚêß#MöKÔäG¨@š]ŒVh¬ “xmùfðýòØÝÇÄoÝèÚüÐXÞ-•åìvzMì3›k=NÞ0O+\$Ræ·Ê„pqóxÜ–„ÓšQ…¾Ì½×-U–‹[´ž÷ºZ»לôâãü£„£žåYfu_ R3y¾"¥EŒÂÅ{²ž—/²œÜoMÆ6“mÜþ}ü5âWµ3ËdU&¸€Âë$j9äl.ÌŽ=àèOuáˆ!º[›ËÛùQ®æò§u·bc(Ëòo ¤c·zûÓö¢ýš|º$ÿ>èréž €_]j0YN¿Ù¼vîêóK§cšÊñ¶3|ä-‹|áWóÛC}KS·N²ót‹#r«¨j&ÖIÚ)®”$Kä«A «(Éç˜òü÷>Ë–ué¹B’œ#ÍVMÙFú$ùyž¶åI;µ³ØÿP<&ñ'ñ‹…(qYÉK^Ë–JT£Œç²¾#’'bäÔ~>dåu#ë ü=´Õ´Q}%åÍö—áãk=¾•¾+1%VMðyPùÙ# ¥Ôu¯Rð‡ÅM¾‚ÃWðî«âMFÓO‡Zñ›G§ÛZ¾ä3)·ïeùpŒv–;‰Ú¥OÏÞþÎðö³aáñ“ñ¾š8ѧ‘ î±$ñ“ŸR t^)“NºšúÇìŒ#k©c³iLù3¬è¤&Ϫ<…+€¤ƒœWãX¬».Ž*TgCUÊ“«Ez’ås¨¯FVPr»TäÛÝs­Ïc3ËðØç‰Ãc)â(×T¥R“´T!-y\ß=îŸdî¶ì~Aà[o h@Ãm¤""iµ[Ü\ù„¥ÄétþlL5‰Ô[¢ å dÖ\¾“QøGñ@‹›Bá´}ZXàO2±=­»jÖ’Jû³)ßbGQBTÚÃ+‰û)kºiÕô†><]oSÓ“O½¹ÑÜ·G§ÝÁ SÜÛ†¸ 44Fø•åP]‚ãœ}IñtÛhß>#øƒáý¢½õ¯€õèî#³Ž5‚CqlÚ5¢ùeLLbžâ)s°ÈG#¬d¹Fa ÇV-'%Š…[ªµœ~Ô#(Ù«|RWIÞÇó7æØ̯2žO‰œã_šÀãê>\©ÎrTÿxýþg(´ãÞ.É]I_øýµšòßÆ~ ñ¡q ëv—Z%Å­Â^ÝjHÙg²¶´ÕSU·ö”ŸiÝ£´Qº‡iÚ¥¦øMî.og#[•5K¸,môH®-¦Ó$³‚ú2hµ&û6è¼¹/¢†0#†aMojÞm B7²¶±%õãÇ;À4Ñk§¶Ÿ{j·ó´w!®O2ØÃnÅž&ÉU©4¾ i·ž]¦§jVpˆÒöêò[›»5e· ök{K™Ñ¥šH§r?ŸD»™Ò¯2þÔN8|mòjV•9^œlÜõÑhûjµ¾ÇøÅÄÞñ§a0™—d50zÒ‹~ÚPSiÿ,t”ÚÑ'Ôèü?i®ø" B k׺DKvw‹EžÚæÚ}îi4Œ³+É/Ùošá–Kk„¨Hƒof4¿ëõ®¯ãÿ h­Ö÷Ï×áñ–œÓ\Ý9r/gŽD¿–YY‰F–YËÙÈ(÷/ xV[¯ ]k~7ÑÓMÓ {WR¾ÔfÒ4è,žiaµ¼·kÈ¡žöI¤‰ÉHayZBFÜ€+æÙ>)|/A£kŃGƒ]´-%•œÍqdŽBm’{È]ËóGæmÌeN;˜xüCÄâ©eòÅbg†©*˜ŠŠÓJ1vp‡,R³m;oßÏlC7Âaa:PºõTpò®¹!R³ƒjšm­yní{'¦åZxnÂOê2øRñJÅæ^xkKðÖ©0ð÷†çµ"UÔõK«qæjR(B›Ta·nRد¤þøö_ˆš„þ'¸Ð´oøËO¹Ò…¯†¼O}ª_YªZ¯—µÓCbKxÐ"½ò”¡*NÓ_JøSÆÿ±_ŠæÑ4$|<¼º·°Ó§‚âóûóÈÓÑ…±gŒª›©øûOú5Â8áŽÖf_¸¼7ÿàøAûChÃÆ >$Å øËL†U°ñ€n_Tº†âÐ¥Þ›s¬XYÚÛi“Ü1Œ[Iö@)i†Tçróbx/ÇÑ•,] VºT±Uáìç̞ѼRtÓ{ò¶Ý׳>Íx;‡Åû­S«jUh`èVÄ{$Û½zŽ›|©E«ói¡ùó©|sð‰yqwñáûé>3Óï.%JÐôkkiòvÄ’Ásnd…VP³%#bÙl[ý“ÿmÿ‚~øÁ¡jŸ>\á^ß/QñG…涳×L¼#í ›ŽÎè Ã1ƒÀÉÜkïˆðHŸ‰´•¾¥~°[øº}3Ãð뫧ZÁ¨ëV–‘0½Öô›KÉ­¬Ä³;I$sKLfC(‘ã­oþOûyøNüKá¯èþ4³·¹O<é¬VÏg+;F„ÙÉb,ª+?“,£vrØ™]|–T¡K•ñPV«^j¤¹›Œ“’w´9V–½¼:Í+Ñ”éákÅQ‹ŠŒàœ”’ºi¶ÓNN.î÷VÓ§Óßµ?ü Á|Tñ§ÁíÆV¶Þ!¶Òôïµx›P2x3Á:eœÿ`ðå…Ž‘n²iþµ‚Gxšçí$Ä[ÌE;}g¢ßø£Á¾"ðWƒ¼{40k쯵í'Q–íÁÀñ'ñOÚ—Ã~ ׬ô‰4[/û6ËMá’$[y&žPe˜´0 Pò|ÃÐþ Ä\?›åžÈœdðÔêÎ55©^>üaR.¤¥9Þê4“Jñ³Lÿc<3ñw!ñg‡p˜ü›0ÁË:ÅRŠÆåøŠ–¯†Nœ\íMMM4Þœ×o[õ>Äøiaý§ãQ°–K[KX>Ó~ù7ÀC™e€6)y …Ý_T|Xñ·Ù~üJ²Ó- ¶»½Ó'¿3ÄGÚ/¬,É1FÚûä%·ŽX‘ÁÍ~oøâ^¡áŸ x¯Å!¹–éVÖâk7R®›iok`±À^·—L-\Hç3$¢8Õ·¾üp·ø¯á¯èzåÝ»êZÄZ´;n¤“u„H<‹K}ÊC¸‡Ë „2«Ûpíòe nM—æuéS«‰Ã`«FŽ"²»Œ¥RÕ¨4“wÓ•¬šZÚQ>OÄ,†§×(ÖÄEã(`e†Œ-)K–Qš•[o%Q¶’²j+Kݙ߶?ÃxO[Ðü#qk¦i_…ü-¦XÇ£x†cW±Ñ¢M¨žYËÚ¾>ÕµÁç`<|O¬xgUµ¶ðŸÄh,퇫>©iúa³—_Kû1¾’™ç¼ŠÎ2fÚK)£ €ìò-Ö~ЇÄ?Zjž-³]_ÃÚ£B HZIíµÛÙ WY¯U—É[D"þè(Y·o…ðÓOÔ–öÛÃÿˆüC«x‚{›]ãMÔRÏ]ŽED’ÆÊÎÓÍž[2)®.&e¾Ì»˜Ñçû'‚°K…8[ N¬çN¾.R|Cœ§Q©+É·6÷jÒk}véþUxÙÅð~½¦U&œ><‹0Ê+Æ‚ÆbÜ`¯B0•J5½¥Q;]]~"xÁž·º‹þkÙ®¯fßy¦ÙJf2\ÙE²É{U‰ !™’VlmÏ$~¼ø1ñÅß ¯m5‚þ-Õ¼0 ’ Kn‰vaÓî6º˜ßRÓ¤ÝÌlâ1(’?,€xÎýâºý‡~ëú‚YjÓ&µÕ,®¬´m[My`»°µ¹¶š/.Öw‰R0wmýæì‚G‚>Nø“ÿ¯³øu$úçµ{û9$Óm-4û]D}¦ÖÖ˜ùM¨ì쨿¼VùY$qðÏŠ¹&u ¯:ÆWËq”æÔòëR–U9>[S„&’ŒâÓn¤“Ri;Å/ì¿•>–_‘b2¯8‡*ÆÒ§K0ÎiQ­[=ÌiÍûº®½j”•WkìáNÍ«$õ}¿Â¯ø+/Åï èwz_¼1gâS^Õl$ÔüWeq§ß̉"yÉcœ‚vŠFEòä‡{±’7?D¾ÿÁg-þ˱nŠÞqtjãðÜ9ˆÈaŠ_X©<"«Ÿ*•V”ªÎ sFRJÖWÑ[ëŽßþ kðCþKKx»À^.´ÔBhwÖž.Ó“ÃO{7–wÆ]}¦Ý’åFÉóynÇ¿…ºßüYÿ‚lümë¯ð¯Àúd:üÖ“ë—CGÓ!ü3Ðnuˆõ=û Ê+_A5¬š.¡6¦¦îäI¤ùZ–‘¨A$-¦±¹†…Ò[yCd~D~Ѿ,𧊾+O‡ÖSÄtt»›ÄZ’Û;Û;^ÜÄtõ±É˜`gK“,\HPO¸ÜŸ…þ9~Õ¿?á%XøÙâ« Ë4w>"ºkÈ-£»hU£êFf•Ö'l|ÌÁrI=¸ø·Ãþðβ<.ÊWQ/§I«ÝÛ5ö§âÙ º”Ïq#4ÑÁºÙ§²*¬‘ n"¿˜ø£<­šÓ§–„qu±3N Å>YK–7œÜS´b¤ÜW3R»•”lÿÖþŒ9÷„E_Šs®,ÂæX¸:´1ʧ%†¯'.dëSæp~Y(ûŠ1tù,žæ‹üKw“¨x;Ÿ·ÜjÑÇö²¡Dò`i$µ–FvÝ æYÎ?{Èï^áOê¾¾»’kmAåUY²X|†7Û #wÏÏ8Ú+ OñøÔÿ·%”Ï3ά%,IÚÇœ©%T¨6ôÀÏ~}[ÇÚn“­è–ž%°¶xuh­£G+9#’sž¸öçë\ôrÊ9E8døÌ4g‡Í’•Xòگ˥ӳQiE-Ÿ*OtþµÌ±øHWÂbjÒŒ©bcÏ*RR’jí=ß•ÓO¯m¿ÿÙ)8ÆŠV½tÒjé¥/&¿¨¿†¿>!ü3Ðnuˆõ=û Ê+_A5¬š.¡6¦¦îäI¤ùZ–‘¨A$-¦±¹†…Ò[yCd~D~Ѿ,𧊾+O‡ÖSÄtt»›ÄZ’Û;Û;^ÜÄtõ±É˜`gK“,\HPO¸ÜŸ…þ9~Õ¿?á%XøÙâ« Ë4w>"ºkÈ-£»hU£êFf•Ö'l|ÌÁrI=¸ø·Ãþðβ<.ÊWQ/§I«ÝÛ5ö§âÙ º”Ïq#4ÑÁºÙ§²*¬‘ n"¿˜ø£<­šÓ§–„qu±3N Å>YK–7œÜS´b¤ÜW3R»•”lÿÖþŒ9÷„E_Šs®,ÂæX¸:´1ʧ%†¯'.dëSæp~Y(ûŠ1tù,žæ‹üKw“¨x;Ÿ·ÜjÑÇö²¡Dò`i$µ–FvÝ æYÎ?{Èï^áOê¾¾»’kmAåUY²X|†7Û #wÏÏ8Ú+ OñøÔÿ·%”Ï3ά%,IÚÇœ©%T¨6ôÀÏ~}[ÇÚn“­è–ž%°¶xuh­£tiff-v3.4beta018/html/images/strike.gif000644 004341 000024 00000012752 05774104222 017566 0ustar00samuser000000 000000 GIF89a€dõý±Yâ´`tH s=ùñ½ùå—¼k2½d&`L'^A _-\ Š>….7':è¿uΫuq3r¥Šu¨ˆO÷7ú„)Ío-Îa ©LœHÑÀÈÓ¸™vstkc[ͨ\¿˜Wöv%ðlHGHB9+O=>1þµFüž@ÇY¹T¬[&›Y&§‡FûÊ]ßq)Üb‹I(!%c1nX,õÓxL" â„8º”K›{>‰n:,€dEþÀŸpH,ȤrÉl:ŸÐht±Z¯XlÊ׃‰r±¯Æ¬!|# —ª¦x@LªU¡¶Þh»²f()6? >wYB ./=ŽL /›lŽ:/]0/ 6—M6 8#4 © )8 90\4 ·O 5(8>8'808!_ !7>>7))5 [>ˆ\ÞXy(6Êà)‚ÆxË0<<"<#<Á8 pxCQo¹&j˜XXcœ‘d8îÁ‰@Ĉ ÌtM°Q„EŒo܈ˆräL%AÑe„/þ#‚.‘$Å5„À‚þ  JQ¹Sè­z“Ž³QäÈ’'©m˜ Á€„8'BBŽ$¨éñ¢ƒƒ X˜ð¡ZµÂNàqFn#I–Gî‡0`€•Æ ˆ 0 Jtü«ï¾üöë/,]ÀC8Ä]å0Â"çòkÃ6>ô/¾ÿ2pÃDô€€ÁHØ‚40`‰5ôàQàfúŠÀ <â¨THEJ¯ô ûÐØÊœ¼`_=B*h¤@:èFÚÀ¯°6­;»Ñ kÀ0Ö¸ u¸@’Š‡¦á¦¨€‹Wð (ÀB` °IÈN{Ð5o°m øè–x” 'YÆ NÀ ž^ÁtOAÈ0jÜ]Ñ[b²xƒsP¸ƒµœÑƒ T·+ €5Fà\œÖ¥nÆk®àÂþo˜T Ϙ]œ‹€ÜF 2cêDF>ddum«×’n¡¤å€ØYå µx[;a9b‘õvá.QœX¢¹ ¬·­IåP7<ç^UslKèF|"äâò͇ŠÉT÷#°ð‚Á^øeå]·¡¬PÀ…ûƒáËZS+ ?EÊØèªàˆ¢ô%yB0X2„Sd‹*äØI N° Fzßh]åîb¼Üá¦}çÁÖb6'bþ¸KwI"ˆAL¹jðŒ§Ï"ÃLP„Âäí™‚Ä xO"ÍED8›åÝPèÇ-ýmCxƒSÐþZTÀ0X>Ô[7n¼ðÎ]J~½a¥*”ÑÄ&^xP`3’á4`ÃæµµÓ˜LUP0šÓ0`Ñ`ôòn=¬LÏÙ¡Mm|²l_ƒ|Ë{^XÇ“wÙ7(ᨠuÀ=QtO C–Z£Gdáƒ.8F(„Íb¨7ÂѤ†À?ÿYkÅ À¶öòØgC,†Ð p…ï,ÊQ˜Ž|äC¥ 4:€!êí ’SàhA>™¬´DGeyAéó‚l‚[ŠôAÆx¼ß9¯¯× ¡“+nDŒo© Íh9/¢ä3™þ‡2ŽÂÂ…,ð43ÑY`‡6>±Ï@?Z–$ªS)Ž¸ŠàÁ\}ƒÅÒ£Že¬Y(V¤~y£G]hP‘b"[@ÅCªhY3XO‡d O!U'S-¨'òÉ€9; Æ7¾MúèŠB'‚ÎØ¥GW\N…5H=¥©WW„ŽZt¢4ÉÇF/2| D° QòºPrd¦5]H<èbxÅE}r±hÀ³%(6r‘·7&Û¤¡b–¨÷RgR&I ªAúHç¿ Øä÷…(Cf™¾ršØGb9ŠBœ•½Òtvr{‹¤"ê"²r#tþ"¼”"3Â,~&^4$r)uB'orL}âE; ÄB!òæ1,¤Ä¨Ld)¾RKLÔGõ$Fd{¿’b,U”y¢"yŒwIZt+B,-àJprL3|PEH²åuBô"™$Mÿb)¢Gº¢)åMXrNžB"žI,@%ç$ 0 x¢E‚—Dpµ§'+p5Ò+¼4'o¢„TpEGf!,ûgP uÛÄM°`ˆîÑ@¢7FÖô·M›0 פnîaçyòô)óq&ó”MžÂ)šb«4ðAŒ×on´B-pŒG eÝ ± PÑþ¢³¨-°_ºh‹Ù-²ø !!ØbB€ŒÂ¸¾£ŒõŒÐÒ8ÔXÖxؘڨ£ãÛbcjÐõ7•Ts^ü’hÄõD€3} crã_"ÐX%iYpSÀã\ãè0ÊTûÂÐUQ0¸õ \åwUÃQ8€ZOÀRsñRnB03¡3)ø¦sxCF…L (p\v‘U€0Å#€P\]007ðÅÅÌpW†UTbû"p@*"àùÕ9f@=@ i’#_! )Hð vá“ð…ú2)6²Ó R þ@q2E)b XpeX)‘2 )P0À yfõŽÑp ^o™U/0À7°ŽJ™UŒæ9P…V9´0VY`’4ãµ±:@`>ý²˜…Y@˜I²µ”Ù66ÀC‹ÂR€ ™Å ûø ­©bUû² Ð4ª_•^@X ƒT`åiM32Ç u%6 _ÃÙ`!`  P9° ‹èˆfU4/¸S LE5˜Åx7“˜  Vf•W0Àã 8Ð!ðÏ"3ÕZ2ð ‹R)À¡?¥ÆU7.ZÀZ¶cfõCþ‘8¼eIŽ½•“U®cžV°Õ¥PbÐ\Þð Gà£Sc"СåœÌÀTÿ¹fP7à’•OÀ\@8_‰öÙZj 6Ï65`¡à9àØ  ¢g#a:Æ)Üõh º P]*f]³ó^RLu2_a‘_žS#7ÁcwÑ›¾àð–x&RQaÕUjæu¥J`V½é“aÇ€3é\u7qUá9¸¸ÝâÆP5 ¦S4õµ˜³Ór!"ð]¥Ö Æ3T£vS6T:Sô—Z7*þ–i®•H€ïâ-HeI–©Žg2q06"Щ2†“³Q;3¡«NÀc¨£q9€*Wc–:d–I樷e$¶R™ƒž¡-J9ƒ“ @f?ß0¹C›=u’–c­„óf6dEà Íå§W• &4E@/Ü e¥c9uƒu¶[»õ ¥†X‘®$¸“Ò;=`{€±{ð8ëej¨–cöÊN‘E Èc©:MH1iÀ1E†Æs¸Š \æ°Ò“ÛЛa°¶i˜õ fÐnQÀ|бyñ?ªvs$kÐgòs §="`LÆ;þÏS¤ü µ›ÓD15ß z°aÁU¨# 7ð/pmFXaã§yñ Â!@»å°eã µ~æl§¡º>X«_Ûs ’æ<:¶{bz;FQ º=®˜jdôjCγ[¦%=ax1=z[µ [@Õfm”Á: =ŒAÓƒ­ÖÖ<’6i(q=ÁF€¨aAߦ«ä°pØpŠá°üSf¶p¹÷ƒmË6µÀk;¶ƒ­ª‹<õ³=`µaWñ½<”B6·i ’A‚q¾¼{=’Û¥ñ½¨ëg5„kÖVÓC=öK؃Ï»>˜‹¹¸Q?¼±:`þ¼&k*dõñB´$\nš± Ü!l³«îk'|2”†!m(º¹’ÆT 7lŒF?ÇiE7GRDÔXa=à7ðv¼Vrœfç{@#÷o†A»¤xsœO1—BE»õû½¼ÖišákÜi†q§°£C@ÄÇ÷!óA†ùÄ!7o“q@¤A,'tßqn‰s-äqeH¤Ã”¸n7wãCÁ G$ csšI€uÈá,@Gu0pÕ!E›°iDŒ@ôÈ$hàñI Æ†a÷A%Q´ O²"@uÿþ±Ã's%äF*ǽ&WoàË`LH{×vZ$"–øequ¡”Ë2} 4},ד·/ð*TÇWÀë‘Í;°s9É…sRóƾ»J®Ñ¾‚~¤ƒEä†Ò‘nBÄu/H'ktG©¢Ì±ç$Ñ÷’ç)°¢vaWÆgô×LåÄBGRE Ë/°GV¢„x“³‚L4ƒ²! Ë/€~ÄÊ%±"ÙLžršW@F.M$àMéF†9èIH¢+Q¤=@%»lmÒ€†+!"xƒ÷Þ—!ÒL«²l|~D:‚Ôþ·ò·ÍÂyË¡b„Ò++ÀÒ1%\í+Ñq )B$/{™w^ôE)‰t„ò(½’*˜8Ô'"KÔ)Ç7"ª4#}·!%ðK’‡mÄ*ŠÒ(´`o-NG$~tLº$I„,}¤{ErHÔ"‚·$„nr!P|Æ7xœô&ÍBÒM—|rKááu/‚KO}qÃrPÛÇ}ݧIi²'a€†tIe‚"2H*À„`Â~AR6` Ñz]Ï™#Ô¡%ЄüB”IÇÄJ™„LÞg~iÒJ8Õ¯}€Åd~$pIýE¸rF¸çÔtHD´þX"}hQÑÉREŽâÔ®¸/Ää}ºd&~2Ø“‡á×8‡}M'¥Ýw­~ž"…wHÉÇö·Ö!L‹%}̲! ¾/ÂÕÕ{½òJ¹$uËô&$‚L)‚V"(ŠTD’zÆ„EõWHƒÒ!Gô‰‚EŸ„(È à/œÒ¯B„˜’{oB|n$câ”Ì5²­t!Ò~–wÛŽwáHŽž9xEâ(NíGÚç/CØ+ðý'ÌROaÛ“¤5x#h‘*¬Â]ôóÁ„à·"$®Í‚ˆä·=Åò(†þLûWÚwî/]ØJ;À)î±!Z˜…ö÷#;΄TþÄ„#EìçKÏa^{B²D¼RKH^ÉQ,ÇQ}8¬,´!®9…%°%p[xŸÈŠ3Ý…VH…§WšR›2°x°Mú1*gÐñ+Ì&2`"RÝ4 „}xèI˜rÇ,‚2ìÿÒ@Bˆ}<  DßzÍB²ŒÇ=ýAïv1m…brF¿T"ó4î…è)›wBÅœO«ØûDËG2ÒÇ⌬/€) ÿQ‰Ã¼%#/ˆÜttLí(ðwBWÓ˜‡ø)XRˆÊ.aE0s0¤ J¸OWQ%ÎD,ÔV`í‚ôѤ¿ÈŒ²È¤L:MŸ-$¿õ à;B -ÙBŒ QŒÅȤÓÊŽÇ·ŒRo! öû;'¥Ýw­~ž"…wHÉÇö·Ö!Ltiff-v3.4beta018/html/images/warning.gif000644 004341 000024 00000000437 05774320156 017735 0ustar00samuser000000 000000 GIF89a((òçççnnn¾¾¾üÿ!ù,((äºÜþp…H+ ˆÍ»ÿ`ˆ)fžhª¦Ú؆pìµY)ß0M¸0ü=îuû€¸¡­Èô”<Òç¼A™ªìC6Ó\©…U h°u¼ëžÓÔ-›Ò¢¿ê4½7µ {€~MzsKƒ„p`€3ˆeŽ…†!‚”–|šy—q™Œ˜¢’  ¡—a¬¤®©•«f¨.‰³A¼Bµ>1xuºe°²›{ŽÉwôÆË!ÊÕ\ΟX¿ÔȽ§W?ãäåæçHÙèëëÌÀàrÔðIˆöˆó½#+ýþÿ Ä;Ý}xèI˜rÇ,‚2ìµ¢0@«T  DFƒˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆ†Æ ˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úž¤L:¿õ à;B -ÙBŒ QŒÅȤÓÊÿÇêÿÈ/ÿ®Ì›p@<à~ž"…wHÉÇö·Ö!Ltiff-v3.4beta018/contrib/dbs/README000644 004341 000024 00000000240 04753171312 016442 0ustar00samuser000000 000000 Wed May 9 09:11:35 PDT 1990 This directory contains programs from Dan Sears (dbs@decwrl.dec.com). Contact him directly if you have questions/problems. Sam ƒ„p`€3ˆeŽ…†!‚”–|šy—q™Œ˜¢’  ¡—a¬¤®©•«f¨.‰³A¼Bµ>1xuºe°²›{ŽÉwôÆË!ÊÕ\ΟX¿ÔȽ§W?ãäåæçHÙèëëÌÀàrÔðIˆöˆó½#+ýþÿ Ä;Ý}xèI˜rÇ,‚2ìµ¢0@«T  DF„ˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|‰P»ˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úž¤L:¿õ à;B -ÙBŒ QŒÅȤÓÊÿÈÿÈ//ÿ®Ð›p@<à~ž"…wHÉÇö·Ö!Ltiff-v3.4beta018/contrib/dbs/Imakefile000444 004341 000024 00000000536 05123471271 017400 0ustar00samuser000000 000000 # # Imakefile -- to generate a Makefile, do xmkmf # TIFF = ../../libtiff EXTRA_LIBRARIES = $(TIFF)/libtiff.a EXTRA_INCLUDES = -I$(TIFF) AllTarget(bi gray pal rgb) NormalProgramTarget(bi,tiff-bi.o,,,) NormalProgramTarget(gray,tiff-grayscale.o,,,-lm) NormalProgramTarget(pal,tiff-palette.o,,,) NormalProgramTarget(rgb,tiff-rgb.o,,,-lm) Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆB,ˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úž¤L:¿õ à;B -ÙBŒ QŒÅȤÓÊÿÈ7ÿÈS/ÿ®Ô›p@<à~ž"…wHÉÇö·Ö!Ltiff-v3.4beta018/contrib/dbs/tiff-bi.c000444 004341 000024 00000005263 05116230131 017243 0ustar00samuser000000 000000 /* * tiff-bi.c -- create a Class B (bilevel) TIFF file * * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #define WIDTH 512 #define HEIGHT WIDTH typedef unsigned char u_char; void main(argc, argv) int argc; char ** argv; { int i; u_char * scan_line; TIFF * tif; if (argc != 2) { fprintf(stderr, "Usage: %s tiff-image\n", argv[0]); exit(0); } if ((tif = TIFFOpen(argv[1], "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]); exit(0); } TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 1); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); scan_line = (u_char *) malloc(WIDTH / 8); for (i = 0; i < (WIDTH / 8) / 2; i++) scan_line[i] = 0; for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++) scan_line[i] = 255; for (i = 0; i < HEIGHT / 2; i++) TIFFWriteScanline(tif, scan_line, i, 0); for (i = 0; i < (WIDTH / 8) / 2; i++) scan_line[i] = 255; for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++) scan_line[i] = 0; for (i = HEIGHT / 2; i < HEIGHT; i++) TIFFWriteScanline(tif, scan_line, i, 0); free(scan_line); TIFFClose(tif); exit(0); } DTH / 8) / 2; i++) scan_line[i] = 0; for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); i++) scan_line[i] = 255; for (i = 0; i < HEIGHT / 2; i++) TIFFWriteScanline(tif, scan_line, i, 0); for (i = 0; i < (WIDTH / 8) / 2; i++) scan_line[i] = 255; for (i = (WIDTH / 8) / 2; i < (WIDTH / 8); itiff-v3.4beta018/contrib/dbs/tiff-grayscale.c000444 004341 000024 00000010275 05244274325 020641 0ustar00samuser000000 000000 /* * tiff-grayscale.c -- create a Class G (grayscale) TIFF file * with a gray response curve in linear optical density * * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #include #define WIDTH 512 #define HEIGHT WIDTH typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned long u_long; char * programName; void Usage(); void main(argc, argv) int argc; char ** argv; { int bits_per_pixel, cmsize, i, j, k, gray_index, chunk_size, nchunks; u_char * scan_line; u_short * gray; u_long refblackwhite[2*1]; TIFF * tif; programName = argv[0]; if (argc != 4) Usage(); if (!strcmp(argv[1], "-depth")) bits_per_pixel = atoi(argv[2]); else Usage(); switch (bits_per_pixel) { case 8: nchunks = 16; chunk_size = 32; break; case 4: nchunks = 4; chunk_size = 128; break; case 2: nchunks = 2; chunk_size = 256; break; default: Usage(); } cmsize = nchunks * nchunks; gray = (u_short *) malloc(cmsize * sizeof(u_short)); gray[0] = 3000; for (i = 1; i < cmsize; i++) gray[i] = (u_short) (-log10((double) i / (cmsize - 1)) * 1000); refblackwhite[0] = 0; refblackwhite[0] = (1L< #include #define WIDTH 512 #define HEIGHT WIDTH #define SCALE(x) ((x) * 257L) typedef unsigned char u_char; typedef unsigned short u_short; char * programName; void Usage(); void main(argc, argv) int argc; char ** argv; { int bits_per_pixel, cmsize, i, j, k, cmap_index, chunk_size, nchunks; u_char * scan_line; u_short *red, *green, *blue; TIFF * tif; programName = argv[0]; if (argc != 4) Usage(); if (!strcmp(argv[1], "-depth")) bits_per_pixel = atoi(argv[2]); else Usage(); switch (bits_per_pixel) { case 8: nchunks = 16; chunk_size = 32; break; case 4: nchunks = 4; chunk_size = 128; break; case 2: nchunks = 2; chunk_size = 256; break; case 1: nchunks = 2; chunk_size = 256; break; default: Usage(); } if (bits_per_pixel != 1) { cmsize = nchunks * nchunks; } else { cmsize = 2; } red = (u_short *) malloc(cmsize * sizeof(u_short)); green = (u_short *) malloc(cmsize * sizeof(u_short)); blue = (u_short *) malloc(cmsize * sizeof(u_short)); switch (bits_per_pixel) { case 8: for (i = 0; i < cmsize; i++) { if (i < 32) red[i] = 0; else if (i < 64) red[i] = SCALE(36); else if (i < 96) red[i] = SCALE(73); else if (i < 128) red[i] = SCALE(109); else if (i < 160) red[i] = SCALE(146); else if (i < 192) red[i] = SCALE(182); else if (i < 224) red[i] = SCALE(219); else if (i < 256) red[i] = SCALE(255); if ((i % 32) < 4) green[i] = 0; else if (i < 8) green[i] = SCALE(36); else if ((i % 32) < 12) green[i] = SCALE(73); else if ((i % 32) < 16) green[i] = SCALE(109); else if ((i % 32) < 20) green[i] = SCALE(146); else if ((i % 32) < 24) green[i] = SCALE(182); else if ((i % 32) < 28) green[i] = SCALE(219); else if ((i % 32) < 32) green[i] = SCALE(255); if ((i % 4) == 0) blue[i] = SCALE(0); else if ((i % 4) == 1) blue[i] = SCALE(85); else if ((i % 4) == 2) blue[i] = SCALE(170); else if ((i % 4) == 3) blue[i] = SCALE(255); } break; case 4: red[0] = SCALE(255); green[0] = 0; blue[0] = 0; red[1] = 0; green[1] = SCALE(255); blue[1] = 0; red[2] = 0; green[2] = 0; blue[2] = SCALE(255); red[3] = SCALE(255); green[3] = SCALE(255); blue[3] = SCALE(255); red[4] = 0; green[4] = SCALE(255); blue[4] = SCALE(255); red[5] = SCALE(255); green[5] = 0; blue[5] = SCALE(255); red[6] = SCALE(255); green[6] = SCALE(255); blue[6] = 0; red[7] = 0; green[7] = 0; blue[7] = 0; red[8] = SCALE(176); green[8] = SCALE(224); blue[8] = SCALE(230); red[9] = SCALE(100); green[9] = SCALE(149); blue[9] = SCALE(237); red[10] = SCALE(46); green[10] = SCALE(139); blue[10] = SCALE(87); red[11] = SCALE(160); green[11] = SCALE(82); blue[11] = SCALE(45); red[12] = SCALE(238); green[12] = SCALE(130); blue[12] = SCALE(238); red[13] = SCALE(176); green[13] = SCALE(48); blue[13] = SCALE(96); red[14] = SCALE(50); green[14] = SCALE(205); blue[14] = SCALE(50); red[15] = SCALE(240); green[15] = SCALE(152); blue[15] = SCALE(35); break; case 2: red[0] = SCALE(255); green[0] = 0; blue[0] = 0; red[1] = 0; green[1] = SCALE(255); blue[1] = 0; red[2] = 0; green[2] = 0; blue[2] = SCALE(255); red[3] = SCALE(255); green[3] = SCALE(255); blue[3] = SCALE(255); break; case 1: red[0] = 0; green[0] = 0; blue[0] = 0; red[1] = SCALE(255); green[1] = SCALE(255); blue[1] = SCALE(255); break; } if ((tif = TIFFOpen(argv[3], "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", argv[3]); exit(0); } TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bits_per_pixel); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); scan_line = (u_char *) malloc(WIDTH / (8 / bits_per_pixel)); for (i = 0; i < HEIGHT; i++) { for (j = 0, k = 0; j < WIDTH;) { cmap_index = (j / chunk_size) + ((i / chunk_size) * nchunks); switch (bits_per_pixel) { case 8: scan_line[k++] = cmap_index; j++; break; case 4: scan_line[k++] = (cmap_index << 4) + cmap_index; j += 2; break; case 2: scan_line[k++] = (cmap_index << 6) + (cmap_index << 4) + (cmap_index << 2) + cmap_index; j += 4; break; case 1: scan_line[k++] = ((j / chunk_size) == (i / chunk_size)) ? 0x00 : 0xff; j += 8; break; } } TIFFWriteScanline(tif, scan_line, i, 0); } free(scan_line); TIFFClose(tif); exit(0); } void Usage() { fprintf(stderr, "Usage: %s -depth (8 | 4 | 2 | 1) tiff-image\n", programName); exit(0); } an_line[k++] = (cmap_index << 6)tiff-v3.4beta018/contrib/dbs/tiff-rgb.c000444 004341 000024 00000014416 05244274334 017442 0ustar00samuser000000 000000 /* * tiff-rgb.c -- create a 24-bit Class R (rgb) TIFF file * * Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #include #include #define ROUND(x) (u_short) ((x) + 0.5) #define CMSIZE 256 #define WIDTH 525 #define HEIGHT 512 #define TIFF_GAMMA 2.2 typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned long u_long; void Usage(); char * programName; void main(argc, argv) int argc; char ** argv; { char * input_file; double image_gamma; int i, j; TIFF * tif; u_char * scan_line; u_short red[CMSIZE], green[CMSIZE], blue[CMSIZE]; u_long refblackwhite[2*3]; programName = argv[0]; switch (argc) { case 2: image_gamma = TIFF_GAMMA; input_file = argv[1]; break; case 4: if (!strcmp(argv[1], "-gamma")) { image_gamma = atof(argv[2]); input_file = argv[3]; } else Usage(); break; default: Usage(); } for (i = 0; i < CMSIZE; i++) { if (i == 0) red[i] = green[i] = blue[i] = 0; else { red[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); green[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); blue[i] = ROUND((pow(i / 255.0, 1.0 / image_gamma) * 65535.0)); } } refblackwhite[0] = 0; refblackwhite[1] = 255; refblackwhite[2] = 0; refblackwhite[3] = 255; refblackwhite[4] = 0; refblackwhite[5] = 255; if ((tif = TIFFOpen(input_file, "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", input_file); exit(0); } TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); #ifdef notdef TIFFSetField(tif, TIFFTAG_WHITEPOINT, whitex, whitey); TIFFSetField(tif, TIFFTAG_PRIMARYCHROMATICITIES, primaries); #endif TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refblackwhite); TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, red, green, blue); scan_line = (u_char *) malloc(WIDTH * 3); for (i = 0; i < 255; i++) { for (j = 0; j < 75; j++) { scan_line[j * 3] = 255; scan_line[(j * 3) + 1] = 255 - i; scan_line[(j * 3) + 2] = 255 - i; } for (j = 75; j < 150; j++) { scan_line[j * 3] = 255 - i; scan_line[(j * 3) + 1] = 255; scan_line[(j * 3) + 2] = 255 - i; } for (j = 150; j < 225; j++) { scan_line[j * 3] = 255 - i; scan_line[(j * 3) + 1] = 255 - i; scan_line[(j * 3) + 2] = 255; } for (j = 225; j < 300; j++) { scan_line[j * 3] = (i - 1) / 2; scan_line[(j * 3) + 1] = (i - 1) / 2; scan_line[(j * 3) + 2] = (i - 1) / 2; } for (j = 300; j < 375; j++) { scan_line[j * 3] = 255 - i; scan_line[(j * 3) + 1] = 255; scan_line[(j * 3) + 2] = 255; } for (j = 375; j < 450; j++) { scan_line[j * 3] = 255; scan_line[(j * 3) + 1] = 255 - i; scan_line[(j * 3) + 2] = 255; } for (j = 450; j < 525; j++) { scan_line[j * 3] = 255; scan_line[(j * 3) + 1] = 255; scan_line[(j * 3) + 2] = 255 - i; } TIFFWriteScanline(tif, scan_line, i, 0); } for (i = 255; i < 512; i++) { for (j = 0; j < 75; j++) { scan_line[j * 3] = i; scan_line[(j * 3) + 1] = 0; scan_line[(j * 3) + 2] = 0; } for (j = 75; j < 150; j++) { scan_line[j * 3] = 0; scan_line[(j * 3) + 1] = i; scan_line[(j * 3) + 2] = 0; } for (j = 150; j < 225; j++) { scan_line[j * 3] = 0; scan_line[(j * 3) + 1] = 0; scan_line[(j * 3) + 2] = i; } for (j = 225; j < 300; j++) { scan_line[j * 3] = (i - 1) / 2; scan_line[(j * 3) + 1] = (i - 1) / 2; scan_line[(j * 3) + 2] = (i - 1) / 2; } for (j = 300; j < 375; j++) { scan_line[j * 3] = 0; scan_line[(j * 3) + 1] = i; scan_line[(j * 3) + 2] = i; } for (j = 375; j < 450; j++) { scan_line[j * 3] = i; scan_line[(j * 3) + 1] = 0; scan_line[(j * 3) + 2] = i; } for (j = 450; j < 525; j++) { scan_line[j * 3] = i; scan_line[(j * 3) + 1] = i; scan_line[(j * 3) + 2] = 0; } TIFFWriteScanline(tif, scan_line, i, 0); } free(scan_line); TIFFClose(tif); exit(0); } void Usage() { fprintf(stderr, "Usage: %s -gamma gamma tiff-image\n", programName); exit(0); } ) { scan_line[j * 3] = i; scan_line[(j * 3) + 1] = 0; scan_line[(j * 3) + 2] = i; } for (j = 450; j < 525; j++) { scan_line[j * 3] = i; scan_line[(j * 3) + 1] = tiff-v3.4beta018/contrib/dbs/xtiff/README000644 004341 000024 00000000471 05030213254 017557 0ustar00samuser000000 000000 xtiff 2.0 xtiff is a tool for viewing a TIFF file in an X window. It was written to handle as many different kinds of TIFF files as possible while remaining simple, portable and efficient. xtiff requires X11 R4, the Athena Widgets and Sam Leffler's libtiff package (which can be found on ucbvax.berkeley.edu). FŠˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆ†ÅĈ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø Úž scan_line[j * 3] = iÿÉÿÉ)/ÿ®è›p@<à[(j * 3) + 1] = tiff-v3.4beta018/contrib/dbs/xtiff/Imakefile000644 004341 000024 00000000733 05773656124 020536 0ustar00samuser000000 000000 # # Imakefile -- to generate a Makefile for xtiff, use: # /usr/local/X11/mit/config/imake \ # -I/usr/local/X11/mit/config \ # -DTOPDIR=/usr/local/X11/mit \ # -DCURDIR=/usr/local/X11/mit \ # -DDESTDIR=/usr/local/X11/mit # SYS_LIBRARIES = -lm LOCAL_LIBRARIES = XawClientLibs DEPLIBS = XawClientDepLibs TIFF = ../../../libtiff EXTRA_LIBRARIES = $(TIFF)/libtiff.so -lm EXTRA_INCLUDES = -I$(TIFF) SimpleProgramTarget(xtiff) 1ÿÉS/ÿ®ì›p@<à[(j * 3) + 1] = tiff-v3.4beta018/contrib/dbs/xtiff/patchlevel.h000644 004341 000024 00000000025 05056547662 021217 0ustar00samuser000000 000000 #define PATCHLEVEL 0 enerate a Makefile for xtiff, use: # /usr/local/X11/mit/config/imake \ # -I/usr/local/X11/mit/config \ # -DTOPDIR=/usr/local/X11/mit \ # -DCURDIR=/usr/local/X11/mit \ # -DDESTDIR=/usr/local/X11/mit # SYS_LIBRARIES = -lm LOCAL_LIBRARIES wClientLibs µ¢0@«T DEPFŒˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆìÒˆˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø ÚžF) leProgramTarget(xtifÿÉ^ÿÉ€/ÿ®ð›p@<à[(j * 3) + 1] = tiff-v3.4beta018/contrib/dbs/xtiff/xtiff.c000444 004341 000024 00000121445 05773656377 020225 0ustar00samuser000000 000000 /* * xtiff - view a TIFF file in an X window * * Dan Sears * Chris Sears * * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Digital not be * used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Revision 1.0 90/05/07 * Initial release. * Revision 2.0 90/12/20 * Converted to use the Athena Widgets and the Xt Intrinsics. * * Notes: * * According to the TIFF 5.0 Specification, it is possible to have * both a TIFFTAG_COLORMAP and a TIFFTAG_COLORRESPONSECURVE. This * doesn't make sense since a TIFFTAG_COLORMAP is 16 bits wide and * a TIFFTAG_COLORRESPONSECURVE is tfBitsPerSample bits wide for each * channel. This is probably a bug in the specification. * In this case, TIFFTAG_COLORRESPONSECURVE is ignored. * This might make sense if TIFFTAG_COLORMAP was 8 bits wide. * * TIFFTAG_COLORMAP is often incorrectly written as ranging from * 0 to 255 rather than from 0 to 65535. CheckAndCorrectColormap() * takes care of this. * * Only ORIENTATION_TOPLEFT is supported correctly. This is the * default TIFF and X orientation. Other orientations will be * displayed incorrectly. * * There is no support for or use of 3/3/2 DirectColor visuals. * TIFFTAG_MINSAMPLEVALUE and TIFFTAG_MAXSAMPLEVALUE are not supported. * * Only TIFFTAG_BITSPERSAMPLE values that are 1, 2, 4 or 8 are supported. */ #include #include #include #include #include #include #include #include #include #include #include #include #define XK_MISCELLANY #include #include "xtifficon.h" #define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ #define ROUND(x) (u_short) ((x) + 0.5) #define SCALE(x, s) (((x) * 65535L) / (s)) #define MCHECK(m) if (!m) { fprintf(stderr, "malloc failed\n"); exit(0); } #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define VIEWPORT_WIDTH 700 #define VIEWPORT_HEIGHT 500 #define KEY_TRANSLATE 20 #ifdef __STDC__ #define PP(args) args #else #define PP(args) () #endif void main PP((int argc, char **argv)); void OpenTIFFFile PP((void)); void GetTIFFHeader PP((void)); void SetNameLabel PP((void)); void CheckAndCorrectColormap PP((void)); void SimpleGammaCorrection PP((void)); void GetVisual PP((void)); Boolean SearchVisualList PP((int image_depth, int visual_class, Visual **visual)); void GetTIFFImage PP((void)); void CreateXImage PP((void)); XtCallbackProc SelectProc PP((Widget w, caddr_t unused_1, caddr_t unused_2)); void QuitProc PP((void)); void NextProc PP((void)); void PreviousProc PP((void)); void PageProc PP((int direction)); void EventProc PP((Widget widget, caddr_t unused, XEvent *event)); void ResizeProc PP((void)); int XTiffErrorHandler PP((Display *display, XErrorEvent *error_event)); void Usage PP((void)); int xtVersion = XtSpecificationRelease; /* xtiff depends on R4 or higher */ /* * Xt data structures */ Widget shellWidget, formWidget, listWidget, labelWidget, imageWidget; enum { ButtonQuit = 0, ButtonPreviousPage = 1, ButtonNextPage = 2 }; String buttonStrings[] = { "Quit", "Previous", "Next" }; static XrmOptionDescRec shellOptions[] = { { "-help", "*help", XrmoptionNoArg, (caddr_t) "True" }, { "-gamma", "*gamma", XrmoptionSepArg, NULL }, { "-usePixmap", "*usePixmap", XrmoptionSepArg, NULL }, { "-viewportWidth", "*viewportWidth", XrmoptionSepArg, NULL }, { "-viewportHeight", "*viewportHeight", XrmoptionSepArg, NULL }, { "-translate", "*translate", XrmoptionSepArg, NULL }, { "-verbose", "*verbose", XrmoptionSepArg, NULL } }; typedef struct { Boolean help; float gamma; Boolean usePixmap; int viewportWidth; int viewportHeight; int translate; Boolean verbose; } AppData, *AppDataPtr; AppData appData; XtResource clientResources[] = { { "help", XtCBoolean, XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, help), XtRImmediate, (XtPointer) False }, { "gamma", "Gamma", XtRFloat, sizeof(float), XtOffset(AppDataPtr, gamma), XtRString, (XtPointer) TIFF_GAMMA }, { "usePixmap", "UsePixmap", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, usePixmap), XtRImmediate, (XtPointer) True }, { "viewportWidth", "ViewportWidth", XtRInt, sizeof(int), XtOffset(AppDataPtr, viewportWidth), XtRImmediate, (XtPointer) VIEWPORT_WIDTH }, { "viewportHeight", "ViewportHeight", XtRInt, sizeof(int), XtOffset(AppDataPtr, viewportHeight), XtRImmediate, (XtPointer) VIEWPORT_HEIGHT }, { "translate", "Translate", XtRInt, sizeof(int), XtOffset(AppDataPtr, translate), XtRImmediate, (XtPointer) KEY_TRANSLATE }, { "verbose", "Verbose", XtRBoolean, sizeof(Boolean), XtOffset(AppDataPtr, verbose), XtRImmediate, (XtPointer) True } }; Arg formArgs[] = { { XtNresizable, True } }; Arg listArgs[] = { { XtNresizable, False }, { XtNborderWidth, 0 }, { XtNdefaultColumns, 3 }, { XtNforceColumns, True }, { XtNlist, (int) buttonStrings }, { XtNnumberStrings, XtNumber(buttonStrings) }, { XtNtop, XtChainTop }, { XtNleft, XtChainLeft }, { XtNbottom, XtChainTop }, { XtNright, XtChainLeft } }; Arg labelArgs[] = { { XtNresizable, False }, { XtNwidth, 200 }, { XtNborderWidth, 0 }, { XtNjustify, XtJustifyLeft }, { XtNtop, XtChainTop }, { XtNleft, XtChainLeft }, { XtNbottom, XtChainTop }, { XtNright, XtChainLeft } }; Arg imageArgs[] = { { XtNresizable, True }, { XtNborderWidth, 0 }, { XtNtop, XtChainTop }, { XtNleft, XtChainLeft }, { XtNbottom, XtChainTop }, { XtNright, XtChainLeft } }; XtActionsRec actionsTable[] = { { "quit", QuitProc }, { "next", NextProc }, { "previous", PreviousProc }, { "notifyresize", ResizeProc } }; char translationsTable[] = "q: quit() \n \ Q: quit() \n \ WM_PROTOCOLS: quit()\n \ p: previous() \n \ P: previous() \n \ n: next() \n \ N: next() \n \ : notifyresize()"; /* * X data structures */ Colormap xColormap; Display * xDisplay; Pixmap xImagePixmap; Visual * xVisual; XImage * xImage; GC xWinGc; int xImageDepth, xScreen, xRedMask, xGreenMask, xBlueMask, xOffset = 0, yOffset = 0, grabX = -1, grabY = -1; u_char basePixel = 0; /* * TIFF data structures */ TIFF * tfFile = NULL; u_long tfImageWidth, tfImageHeight; u_short tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, tfPhotometricInterpretation, tfGrayResponseUnit, tfImageDepth, tfBytesPerRow; int tfDirectory = 0, tfMultiPage = False; double tfUnitMap, tfGrayResponseUnitMap[] = { -1, -10, -100, -1000, -10000, -100000 }; /* * display data structures */ double *dRed, *dGreen, *dBlue; /* * shared data structures */ u_short * redMap = NULL, *greenMap = NULL, *blueMap = NULL, *grayMap = NULL, colormapSize; u_char * imageMemory; char * fileName; void main(argc, argv) int argc; char ** argv; { XSetWindowAttributes window_attributes; Widget widget_list[3]; Arg args[5]; setbuf(stdout, NULL); setbuf(stderr, NULL); shellWidget = XtInitialize(argv[0], "XTiff", shellOptions, XtNumber(shellOptions), &argc, argv); XSetErrorHandler(XTiffErrorHandler); XtGetApplicationResources(shellWidget, &appData, (XtResourceList) clientResources, (Cardinal) XtNumber(clientResources), (ArgList) NULL, (Cardinal) 0); if ((argc <= 1) || (argc > 2) || appData.help) Usage(); if (appData.verbose == False) { TIFFSetErrorHandler(0); TIFFSetWarningHandler(0); } fileName = argv[1]; xDisplay = XtDisplay(shellWidget); xScreen = DefaultScreen(xDisplay); OpenTIFFFile(); GetTIFFHeader(); SimpleGammaCorrection(); GetVisual(); GetTIFFImage(); /* * Send visual, colormap, depth and iconPixmap to shellWidget. * Sending the visual to the shell is only possible with the advent of R4. */ XtSetArg(args[0], XtNvisual, xVisual); XtSetArg(args[1], XtNcolormap, xColormap); XtSetArg(args[2], XtNdepth, xImageDepth == 1 ? DefaultDepth(xDisplay, xScreen) : xImageDepth); XtSetArg(args[3], XtNiconPixmap, XCreateBitmapFromData(xDisplay, RootWindow(xDisplay, xScreen), xtifficon_bits, xtifficon_width, xtifficon_height)); XtSetArg(args[4], XtNallowShellResize, True); XtSetValues(shellWidget, args, 5); /* * widget instance hierarchy */ formWidget = XtCreateManagedWidget("form", formWidgetClass, shellWidget, formArgs, XtNumber(formArgs)); widget_list[0] = listWidget = XtCreateWidget("list", listWidgetClass, formWidget, listArgs, XtNumber(listArgs)); widget_list[1] = labelWidget = XtCreateWidget("label", labelWidgetClass, formWidget, labelArgs, XtNumber(labelArgs)); widget_list[2] = imageWidget = XtCreateWidget("image", widgetClass, formWidget, imageArgs, XtNumber(imageArgs)); XtManageChildren(widget_list, XtNumber(widget_list)); /* * initial widget sizes - for small images let xtiff size itself */ if (tfImageWidth >= appData.viewportWidth) { XtSetArg(args[0], XtNwidth, appData.viewportWidth); XtSetValues(shellWidget, args, 1); } if (tfImageHeight >= appData.viewportHeight) { XtSetArg(args[0], XtNheight, appData.viewportHeight); XtSetValues(shellWidget, args, 1); } XtSetArg(args[0], XtNwidth, tfImageWidth); XtSetArg(args[1], XtNheight, tfImageHeight); XtSetValues(imageWidget, args, 2); /* * formWidget uses these constraints but they are stored in the children. */ XtSetArg(args[0], XtNfromVert, listWidget); XtSetValues(imageWidget, args, 1); XtSetArg(args[0], XtNfromHoriz, listWidget); XtSetValues(labelWidget, args, 1); SetNameLabel(); XtAddCallback(listWidget, XtNcallback, (XtCallbackProc) SelectProc, (XtPointer) NULL); XtAddActions(actionsTable, XtNumber(actionsTable)); XtSetArg(args[0], XtNtranslations, XtParseTranslationTable(translationsTable)); XtSetValues(formWidget, &args[0], 1); XtSetValues(imageWidget, &args[0], 1); /* * This is intended to be a little faster than going through * the translation manager. */ XtAddEventHandler(imageWidget, ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask | KeyPressMask, False, EventProc, NULL); XtRealizeWidget(shellWidget); window_attributes.cursor = XCreateFontCursor(xDisplay, XC_fleur); XChangeWindowAttributes(xDisplay, XtWindow(imageWidget), CWCursor, &window_attributes); CreateXImage(); XtMainLoop(); } void OpenTIFFFile() { if (tfFile != NULL) TIFFClose(tfFile); if ((tfFile = TIFFOpen(fileName, "r")) == NULL) { fprintf(appData.verbose ? stderr : stdout, "xtiff: can't open %s as a TIFF file\n", fileName); exit(0); } tfMultiPage = (TIFFLastDirectory(tfFile) ? False : True); } void GetTIFFHeader() { register int i; if (!TIFFSetDirectory(tfFile, tfDirectory)) { fprintf(stderr, "xtiff: can't seek to directory %d in %s\n", tfDirectory, fileName); exit(0); } TIFFGetField(tfFile, TIFFTAG_IMAGEWIDTH, &tfImageWidth); TIFFGetField(tfFile, TIFFTAG_IMAGELENGTH, &tfImageHeight); /* * If the following tags aren't present then use the TIFF defaults. */ TIFFGetFieldDefaulted(tfFile, TIFFTAG_BITSPERSAMPLE, &tfBitsPerSample); TIFFGetFieldDefaulted(tfFile, TIFFTAG_SAMPLESPERPIXEL, &tfSamplesPerPixel); TIFFGetFieldDefaulted(tfFile, TIFFTAG_PLANARCONFIG, &tfPlanarConfiguration); TIFFGetFieldDefaulted(tfFile, TIFFTAG_GRAYRESPONSEUNIT, &tfGrayResponseUnit); tfUnitMap = tfGrayResponseUnitMap[tfGrayResponseUnit]; colormapSize = 1 << tfBitsPerSample; tfImageDepth = tfBitsPerSample * tfSamplesPerPixel; dRed = (double *) malloc(colormapSize * sizeof(double)); dGreen = (double *) malloc(colormapSize * sizeof(double)); dBlue = (double *) malloc(colormapSize * sizeof(double)); MCHECK(dRed); MCHECK(dGreen); MCHECK(dBlue); /* * If TIFFTAG_PHOTOMETRIC is not present then assign a reasonable default. * The TIFF 5.0 specification doesn't give a default. */ if (!TIFFGetField(tfFile, TIFFTAG_PHOTOMETRIC, &tfPhotometricInterpretation)) { if (tfSamplesPerPixel != 1) tfPhotometricInterpretation = PHOTOMETRIC_RGB; else if (tfBitsPerSample == 1) tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; else if (TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, &blueMap)) { tfPhotometricInterpretation = PHOTOMETRIC_PALETTE; redMap = greenMap = blueMap = NULL; } else tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; } /* * Given TIFFTAG_PHOTOMETRIC extract or create the response curves. */ switch (tfPhotometricInterpretation) { case PHOTOMETRIC_RGB: redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize - 1); break; case PHOTOMETRIC_PALETTE: if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, &blueMap)) { redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize - 1); } else { CheckAndCorrectColormap(); for (i = 0; i < colormapSize; i++) { dRed[i] = (double) redMap[i]; dGreen[i] = (double) greenMap[i]; dBlue[i] = (double) blueMap[i]; } } break; case PHOTOMETRIC_MINISWHITE: redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(colormapSize-1-i, colormapSize-1); break; case PHOTOMETRIC_MINISBLACK: redMap = (u_short *) malloc(colormapSize * sizeof(u_short)); greenMap = (u_short *) malloc(colormapSize * sizeof(u_short)); blueMap = (u_short *) malloc(colormapSize * sizeof(u_short)); MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize-1); break; default: fprintf(stderr, "xtiff: can't display photometric interpretation type %d\n", tfPhotometricInterpretation); exit(0); } } void SetNameLabel() { char buffer[BUFSIZ]; Arg args[1]; if (tfMultiPage) sprintf(buffer, "%s - page %d", fileName, tfDirectory); else strcpy(buffer, fileName); XtSetArg(args[0], XtNlabel, buffer); XtSetValues(labelWidget, args, 1); } /* * Many programs get TIFF colormaps wrong. They use 8-bit colormaps instead of * 16-bit colormaps. This function is a heuristic to detect and correct this. */ void CheckAndCorrectColormap() { register int i; for (i = 0; i < colormapSize; i++) if ((redMap[i] > 255) || (greenMap[i] > 255) || (blueMap[i] > 255)) return; for (i = 0; i < colormapSize; i++) { redMap[i] = SCALE(redMap[i], 255); greenMap[i] = SCALE(greenMap[i], 255); blueMap[i] = SCALE(blueMap[i], 255); } TIFFWarning(fileName, "Assuming 8-bit colormap"); } void SimpleGammaCorrection() { register int i; register double i_gamma = 1.0 / appData.gamma; for (i = 0; i < colormapSize; i++) { if (((tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) && (i == colormapSize - 1)) || ((tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) && (i == 0))) redMap[i] = greenMap[i] = blueMap[i] = 0; else { redMap[i] = ROUND((pow(dRed[i] / 65535.0, i_gamma) * 65535.0)); greenMap[i] = ROUND((pow(dGreen[i] / 65535.0, i_gamma) * 65535.0)); blueMap[i] = ROUND((pow(dBlue[i] / 65535.0, i_gamma) * 65535.0)); } } free(dRed); free(dGreen); free(dBlue); } static char* classNames[] = { "StaticGray", "GrayScale", "StaticColor", "PseudoColor", "TrueColor", "DirectColor" }; /* * Current limitation: the visual is set initially by the first file. * It cannot be changed. */ void GetVisual() { register XColor *colors = NULL; register u_long *pixels = NULL; register int i; switch (tfImageDepth) { /* * X really wants a 32-bit image with the fourth channel unused, * but the visual structure thinks it's 24-bit. bitmap_unit is 32. */ case 32: case 24: if (SearchVisualList(24, DirectColor, &xVisual) == False) { fprintf(stderr, "xtiff: 24-bit DirectColor visual not available\n"); exit(0); } colors = (XColor *) malloc(3 * colormapSize * sizeof(XColor)); MCHECK(colors); for (i = 0; i < colormapSize; i++) { colors[i].pixel = (u_long) (i << 16) + (i << 8) + i; colors[i].red = redMap[i]; colors[i].green = greenMap[i]; colors[i].blue = blueMap[i]; colors[i].flags = DoRed | DoGreen | DoBlue; } xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), xVisual, AllocAll); XStoreColors(xDisplay, xColormap, colors, colormapSize); break; case 8: case 4: case 2: /* * We assume that systems with 24-bit visuals also have 8-bit visuals. * We don't promote from 8-bit PseudoColor to 24/32 bit DirectColor. */ switch (tfPhotometricInterpretation) { case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: if (SearchVisualList((int) tfImageDepth, GrayScale, &xVisual) == True) break; case PHOTOMETRIC_PALETTE: if (SearchVisualList((int) tfImageDepth, PseudoColor, &xVisual) == True) break; default: fprintf(stderr, "xtiff: Unsupported TIFF/X configuration\n"); exit(0); } colors = (XColor *) malloc(colormapSize * sizeof(XColor)); MCHECK(colors); for (i = 0; i < colormapSize; i++) { colors[i].pixel = (u_long) i; colors[i].red = redMap[i]; colors[i].green = greenMap[i]; colors[i].blue = blueMap[i]; colors[i].flags = DoRed | DoGreen | DoBlue; } /* * xtiff's colormap allocation is private. It does not attempt * to detect whether any existing colormap entries are suitable * for its use. This will cause colormap flashing. Furthermore, * background and foreground are taken from the environment. * For example, the foreground color may be red when the visual * is GrayScale. If the colormap is completely populated, * Xt will not be able to allocate fg and bg. */ if (tfImageDepth == 8) xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), xVisual, AllocAll); else { xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), xVisual, AllocNone); pixels = (u_long *) malloc(colormapSize * sizeof(u_long)); MCHECK(pixels); (void) XAllocColorCells(xDisplay, xColormap, True, NULL, 0, pixels, colormapSize); basePixel = (u_char) pixels[0]; free(pixels); } XStoreColors(xDisplay, xColormap, colors, colormapSize); break; case 1: xImageDepth = 1; xVisual = DefaultVisual(xDisplay, xScreen); xColormap = DefaultColormap(xDisplay, xScreen); break; default: fprintf(stderr, "xtiff: unsupported image depth %d\n", tfImageDepth); exit(0); } if (appData.verbose == True) fprintf(stderr, "%s: Using %d-bit %s visual.\n", fileName, xImageDepth, classNames[xVisual->class]); if (colors != NULL) free(colors); if (grayMap != NULL) free(grayMap); if (redMap != NULL) free(redMap); if (greenMap != NULL) free(greenMap); if (blueMap != NULL) free(blueMap); colors = NULL; grayMap = redMap = greenMap = blueMap = NULL; } /* * Search for an appropriate visual. Promote where necessary. * Check to make sure that ENOUGH colormap entries are writeable. * basePixel was determined when XAllocColorCells() contiguously * allocated enough entries. basePixel is used below in GetTIFFImage. */ Boolean SearchVisualList(image_depth, visual_class, visual) int image_depth, visual_class; Visual **visual; { XVisualInfo template_visual, *visual_list, *vl; int i, n_visuals; template_visual.screen = xScreen; vl = visual_list = XGetVisualInfo(xDisplay, VisualScreenMask, &template_visual, &n_visuals); if (n_visuals == 0) { fprintf(stderr, "xtiff: visual list not available\n"); exit(0); } for (i = 0; i < n_visuals; vl++, i++) { if ((vl->class == visual_class) && (vl->depth >= image_depth) && (vl->visual->map_entries >= (1 << vl->depth))) { *visual = vl->visual; xImageDepth = vl->depth; xRedMask = vl->red_mask; xGreenMask = vl->green_mask; xBlueMask = vl->blue_mask; XFree((char *) visual_list); return True; } } XFree((char *) visual_list); return False; } void GetTIFFImage() { int pixel_map[3], red_shift, green_shift, blue_shift; register u_char *scan_line, *output_p, *input_p; register int i, j, s; scan_line = (u_char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); MCHECK(scan_line); if ((tfImageDepth == 32) || (tfImageDepth == 24)) { output_p = imageMemory = (u_char *) malloc(tfImageWidth * tfImageHeight * 4); MCHECK(imageMemory); /* * Handle different color masks for different frame buffers. */ if (ImageByteOrder(xDisplay) == LSBFirst) { /* DECstation 5000 */ red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 3 : (xRedMask == 0xFF0000 ? 2 : (xRedMask == 0xFF00 ? 1 : 0)); green_shift = pixel_map[1] = xGreenMask == 0xFF000000 ? 3 : (xGreenMask == 0xFF0000 ? 2 : (xGreenMask == 0xFF00 ? 1 : 0)); blue_shift = pixel_map[2] = xBlueMask == 0xFF000000 ? 3 : (xBlueMask == 0xFF0000 ? 2 : (xBlueMask == 0xFF00 ? 1 : 0)); } else { /* Ardent */ red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 0 : (xRedMask == 0xFF0000 ? 1 : (xRedMask == 0xFF00 ? 2 : 3)); green_shift = pixel_map[0] = xGreenMask == 0xFF000000 ? 0 : (xGreenMask == 0xFF0000 ? 1 : (xGreenMask == 0xFF00 ? 2 : 3)); blue_shift = pixel_map[0] = xBlueMask == 0xFF000000 ? 0 : (xBlueMask == 0xFF0000 ? 1 : (xBlueMask == 0xFF00 ? 2 : 3)); } if (tfPlanarConfiguration == PLANARCONFIG_CONTIG) { for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; for (input_p = scan_line, j = 0; j < tfImageWidth; j++) { *(output_p + red_shift) = *input_p++; *(output_p + green_shift) = *input_p++; *(output_p + blue_shift) = *input_p++; output_p += 4; if (tfSamplesPerPixel == 4) /* skip the fourth channel */ input_p++; } } } else { for (s = 0; s < tfSamplesPerPixel; s++) { if (s == 3) /* skip the fourth channel */ continue; for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, s) < 0) break; input_p = scan_line; output_p = imageMemory + (i*tfImageWidth*4) + pixel_map[s]; for (j = 0; j < tfImageWidth; j++, output_p += 4) *output_p = *input_p++; } } } } else { if (xImageDepth == tfImageDepth) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * tfImageHeight); MCHECK(imageMemory); for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) break; } else if ((xImageDepth == 8) && (tfImageDepth == 4)) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); /* * If a scanline is of odd size the inner loop below will overshoot. * This is handled very simply by recalculating the start point at * each scanline and padding imageMemory a little at the end. */ for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfImageWidth]; input_p = scan_line; for (j = 0; j < tfImageWidth; j += 2, input_p++) { *output_p++ = (*input_p >> 4) + basePixel; *output_p++ = (*input_p & 0xf) + basePixel; } } } else if ((xImageDepth == 8) && (tfImageDepth == 2)) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * 4 * tfImageHeight + 4); MCHECK(imageMemory); for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfImageWidth]; input_p = scan_line; for (j = 0; j < tfImageWidth; j += 4, input_p++) { *output_p++ = (*input_p >> 6) + basePixel; *output_p++ = ((*input_p >> 4) & 3) + basePixel; *output_p++ = ((*input_p >> 2) & 3) + basePixel; *output_p++ = (*input_p & 3) + basePixel; } } } else if ((xImageDepth == 4) && (tfImageDepth == 2)) { output_p = imageMemory = (u_char *) malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfBytesPerRow * 2]; input_p = scan_line; for (j = 0; j < tfImageWidth; j += 4, input_p++) { *output_p++ = (((*input_p>>6) << 4) | ((*input_p >> 4) & 3)) + basePixel; *output_p++ = ((((*input_p>>2) & 3) << 4) | (*input_p & 3)) + basePixel; } } } else { fprintf(stderr, "xtiff: can't handle %d-bit TIFF file on an %d-bit display\n", tfImageDepth, xImageDepth); exit(0); } } free(scan_line); } void CreateXImage() { XGCValues gc_values; GC bitmap_gc; xOffset = yOffset = 0; grabX = grabY = -1; xImage = XCreateImage(xDisplay, xVisual, xImageDepth, xImageDepth == 1 ? XYBitmap : ZPixmap, /* offset */ 0, (char *) imageMemory, tfImageWidth, tfImageHeight, /* bitmap_pad */ 8, /* bytes_per_line */ 0); /* * libtiff converts LSB data into MSB but doesn't change the FillOrder tag. */ if (xImageDepth == 1) xImage->bitmap_bit_order = MSBFirst; if (xImageDepth <= 8) xImage->byte_order = MSBFirst; /* * create an appropriate GC */ gc_values.function = GXcopy; gc_values.plane_mask = AllPlanes; if (tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) { gc_values.foreground = XWhitePixel(xDisplay, xScreen); gc_values.background = XBlackPixel(xDisplay, xScreen); } else { gc_values.foreground = XBlackPixel(xDisplay, xScreen); gc_values.background = XWhitePixel(xDisplay, xScreen); } xWinGc = XCreateGC(xDisplay, XtWindow(shellWidget), GCFunction | GCPlaneMask | GCForeground | GCBackground, &gc_values); /* * create the pixmap and load the image */ if (appData.usePixmap == True) { xImagePixmap = XCreatePixmap(xDisplay, RootWindow(xDisplay, xScreen), xImage->width, xImage->height, xImageDepth); /* * According to the O'Reilly X Protocol Reference Manual, page 53, * "A pixmap depth of one is always supported and listed, but windows * of depth one might not be supported." Therefore we create a pixmap * of depth one and use XCopyPlane(). This is idiomatic. */ if (xImageDepth == 1) { /* just pass the bits through */ gc_values.foreground = 1; /* foreground describes set bits */ gc_values.background = 0; /* background describes clear bits */ bitmap_gc = XCreateGC(xDisplay, xImagePixmap, GCForeground | GCBackground, &gc_values); XPutImage(xDisplay, xImagePixmap, bitmap_gc, xImage, 0, 0, 0, 0, xImage->width, xImage->height); } else XPutImage(xDisplay, xImagePixmap, xWinGc, xImage, 0, 0, 0, 0, xImage->width, xImage->height); XDestroyImage(xImage); free(imageMemory); } } XtCallbackProc SelectProc(w, unused_1, unused_2) Widget w; caddr_t unused_1; caddr_t unused_2; { XawListReturnStruct *list_return; list_return = XawListShowCurrent(w); switch (list_return->list_index) { case ButtonQuit: QuitProc(); break; case ButtonPreviousPage: PreviousProc(); break; case ButtonNextPage: NextProc(); break; default: fprintf(stderr, "error in SelectProc\n"); exit(0); } XawListUnhighlight(w); } void QuitProc(void) { exit(0); } void NextProc() { PageProc(ButtonNextPage); } void PreviousProc() { PageProc(ButtonPreviousPage); } void PageProc(direction) int direction; { XEvent fake_event; Arg args[4]; switch (direction) { case ButtonPreviousPage: if (tfDirectory > 0) TIFFSetDirectory(tfFile, --tfDirectory); else return; break; case ButtonNextPage: if (TIFFReadDirectory(tfFile) == True) tfDirectory++; else return; break; default: fprintf(stderr, "error in PageProc\n"); exit(0); } xOffset = yOffset = 0; grabX = grabY = -1; GetTIFFHeader(); SetNameLabel(); GetTIFFImage(); if (appData.usePixmap == True) XFreePixmap(xDisplay, xImagePixmap); else XDestroyImage(xImage); CreateXImage(); /* * Using XtSetValues() to set the widget size causes a resize. * This resize gets propagated up to the parent shell. * In order to disable this visually disconcerting effect, * shell resizing is temporarily disabled. */ XtSetArg(args[0], XtNallowShellResize, False); XtSetValues(shellWidget, args, 1); XtSetArg(args[0], XtNwidth, tfImageWidth); XtSetArg(args[1], XtNheight, tfImageHeight); XtSetValues(imageWidget, args, 2); XtSetArg(args[0], XtNallowShellResize, True); XtSetValues(shellWidget, args, 1); XClearWindow(xDisplay, XtWindow(imageWidget)); fake_event.type = Expose; fake_event.xexpose.x = fake_event.xexpose.y = 0; fake_event.xexpose.width = tfImageWidth; /* the window will clip */ fake_event.xexpose.height = tfImageHeight; EventProc(imageWidget, NULL, &fake_event); } void EventProc(widget, unused, event) Widget widget; caddr_t unused; XEvent *event; { int ih, iw, ww, wh, sx, sy, w, h, dx, dy; Dimension w_width, w_height; XEvent next_event; Arg args[2]; if (event->type == MappingNotify) { XRefreshKeyboardMapping((XMappingEvent *) event); return; } if (!XtIsRealized(widget)) return; if ((event->type == ButtonPress) || (event->type == ButtonRelease)) if (event->xbutton.button != Button1) return; iw = tfImageWidth; /* avoid sign problems */ ih = tfImageHeight; /* * The grabX and grabY variables record where the user grabbed the image. * They also record whether the mouse button is down or not. */ if (event->type == ButtonPress) { grabX = event->xbutton.x; grabY = event->xbutton.y; return; } /* * imageWidget is a Core widget and doesn't get resized. * So we calculate the size of its viewport here. */ XtSetArg(args[0], XtNwidth, &w_width); XtSetArg(args[1], XtNheight, &w_height); XtGetValues(shellWidget, args, 2); ww = w_width; wh = w_height; XtGetValues(listWidget, args, 2); wh -= w_height; switch (event->type) { case Expose: dx = event->xexpose.x; dy = event->xexpose.y; sx = dx + xOffset; sy = dy + yOffset; w = MIN(event->xexpose.width, iw); h = MIN(event->xexpose.height, ih); break; case KeyPress: if ((grabX >= 0) || (grabY >= 0)) /* Mouse button is still down */ return; switch (XLookupKeysym((XKeyEvent *) event, /* KeySyms index */ 0)) { case XK_Up: if (ih < wh) /* Don't scroll if the window fits the image. */ return; sy = yOffset + appData.translate; sy = MIN(ih - wh, sy); if (sy == yOffset) /* Filter redundant stationary refreshes. */ return; yOffset = sy; sx = xOffset; dx = dy = 0; w = ww; h = wh; break; case XK_Down: if (ih < wh) return; sy = yOffset - appData.translate; sy = MAX(sy, 0); if (sy == yOffset) return; yOffset = sy; sx = xOffset; dx = dy = 0; w = ww; h = wh; break; case XK_Left: if (iw < ww) return; sx = xOffset + appData.translate; sx = MIN(iw - ww, sx); if (sx == xOffset) return; xOffset = sx; sy = yOffset; dx = dy = 0; w = ww; h = wh; break; case XK_Right: if (iw < ww) return; sx = xOffset - appData.translate; sx = MAX(sx, 0); if (sx == xOffset) return; xOffset = sx; sy = yOffset; dx = dy = 0; w = ww; h = wh; break; default: return; } break; case MotionNotify: /* * MotionEvent compression. Ignore multiple motion events. * Ignore motion events if the mouse button is up. */ if (XPending(xDisplay)) /* Xlib doesn't flush the output buffer */ if (XtPeekEvent(&next_event)) if (next_event.type == MotionNotify) return; if ((grabX < 0) || (grabY < 0)) return; sx = xOffset + grabX - (int) event->xmotion.x; if (sx >= (iw - ww)) /* clamp x motion but allow y motion */ sx = iw - ww; sx = MAX(sx, 0); sy = yOffset + grabY - (int) event->xmotion.y; if (sy >= (ih - wh)) /* clamp y motion but allow x motion */ sy = ih - wh; sy = MAX(sy, 0); if ((sx == xOffset) && (sy == yOffset)) return; dx = dy = 0; w = ww; h = wh; break; case ButtonRelease: xOffset = xOffset + grabX - (int) event->xbutton.x; xOffset = MIN(iw - ww, xOffset); xOffset = MAX(xOffset, 0); yOffset = yOffset + grabY - (int) event->xbutton.y; yOffset = MIN(ih - wh, yOffset); yOffset = MAX(yOffset, 0); grabX = grabY = -1; default: return; } if (appData.usePixmap == True) { if (xImageDepth == 1) XCopyPlane(xDisplay, xImagePixmap, XtWindow(widget), xWinGc, sx, sy, w, h, dx, dy, 1); else XCopyArea(xDisplay, xImagePixmap, XtWindow(widget), xWinGc, sx, sy, w, h, dx, dy); } else XPutImage(xDisplay, XtWindow(widget), xWinGc, xImage, sx, sy, dx, dy, w, h); } void ResizeProc() { Dimension w_width, w_height; int xo, yo, ww, wh; XEvent fake_event; Arg args[2]; if ((xOffset == 0) && (yOffset == 0)) return; XtSetArg(args[0], XtNwidth, &w_width); XtSetArg(args[1], XtNheight, &w_height); XtGetValues(shellWidget, args, 2); ww = w_width; wh = w_height; XtGetValues(listWidget, args, 2); wh -= w_height; xo = xOffset; yo = yOffset; if ((xOffset + ww) >= tfImageWidth) xOffset = MAX((int) tfImageWidth - ww, 0); if ((yOffset + wh) >= tfImageHeight) yOffset = MAX((int) tfImageHeight - wh, 0); /* * Send an ExposeEvent if the origin changed. * We have to do this because of the use and semantics of bit gravity. */ if ((xo != xOffset) || (yo != yOffset)) { fake_event.type = Expose; fake_event.xexpose.x = fake_event.xexpose.y = 0; fake_event.xexpose.width = tfImageWidth; fake_event.xexpose.height = tfImageHeight; EventProc(imageWidget, NULL, &fake_event); } } int XTiffErrorHandler(display, error_event) Display *display; XErrorEvent *error_event; { char message[80]; /* * Some X servers limit the size of pixmaps. */ if ((error_event->error_code == BadAlloc) && (error_event->request_code == X_CreatePixmap)) fprintf(stderr, "xtiff: requested pixmap too big for display\n"); else { XGetErrorText(display, error_event->error_code, message, 80); fprintf(stderr, "xtiff: error code %s\n", message); } exit(0); } void Usage() { fprintf(stderr, "Usage xtiff: [options] tiff-file\n"); fprintf(stderr, "\tstandard Xt options\n"); fprintf(stderr, "\t[-help]\n"); fprintf(stderr, "\t[-gamma gamma]\n"); fprintf(stderr, "\t[-usePixmap (True | False)]\n"); fprintf(stderr, "\t[-viewportWidth pixels]\n"); fprintf(stderr, "\t[-viewportHeight pixels]\n"); fprintf(stderr, "\t[-translate pixels]\n"); fprintf(stderr, "\t[-verbose (True | False)]\n"); exit(0); } message); } exit(0); } void Usage() { fprintf(stderr, "Usage xtiff: [options] tiff-file\n"); fprintf(stderr, "\tstandard Xt options\n"); fprintf(stderr, "\t[-help]\n"); fprintf(stderr, "\t[-gamtiff-v3.4beta018/contrib/dbs/xtiff/xtifficon.h000644 004341 000024 00000001572 05056547662 021071 0ustar00samuser000000 000000 #define xtifficon_width 32 #define xtifficon_height 32 static char xtifficon_bits[] = { 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60, 0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c, 0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03, 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00, 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06, 0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00, 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03, 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; 61, 0x00, 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1etiff-v3.4beta018/contrib/ras/ras2tif.c000644 004341 000024 00000014650 05015656237 017335 0ustar00samuser000000 000000 #ifndef lint static char sccsid[] = "@(#)ras2tif.c 1.2 90/03/06"; #endif /*- * ras2tif.c - Converts from a Sun Rasterfile to a Tagged Image File. * * Copyright (c) 1990 by Sun Microsystems, Inc. * * Author: Patrick J. Naughton * naughton@wind.sun.com * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. * * This file is provided AS IS with no warranties of any kind. The author * shall have no liability with respect to the infringement of copyrights, * trade secrets or any patents by this file or any part thereof. In no * event will the author be liable for any lost revenue or profits or * other special, indirect and consequential damages. * * Comments and additions should be sent to the author: * * Patrick J. Naughton * Sun Microsystems * 2550 Garcia Ave, MS 14-40 * Mountain View, CA 94043 * (415) 336-1080 * * Revision History: * 11-Jan-89: Created. * 06-Mar-90: fix bug in SCALE() macro. * got rid of xres and yres, (they weren't working anyways). * fixed bpsl calculation. * * Description: * This program takes a Sun Rasterfile [see rasterfile(5)] as input and * writes a MicroSoft/Aldus "Tagged Image File Format" image or "TIFF" file. * The input file may be standard input, but the output TIFF file must be a * real file since seek(2) is used. */ #include #include #include #include "tiffio.h" typedef int boolean; #define True (1) #define False (0) #define SCALE(x) (((x)*((1L<<16)-1))/255) boolean Verbose = False; boolean dummyinput = False; char *pname; /* program name (used for error messages) */ void error(s1, s2) char *s1, *s2; { fprintf(stderr, s1, pname, s2); exit(1); } void usage() { error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL); } main(argc, argv) int argc; char *argv[]; { char *inf = NULL; char *outf = NULL; FILE *fp; int depth, i; long row; TIFF *tif; Pixrect *pix; /* The Sun Pixrect */ colormap_t Colormap; /* The Pixrect Colormap */ u_short red[256], green[256], blue[256]; struct tm *ct; struct timeval tv; long width, height; long rowsperstrip; short photometric; short samplesperpixel; short bitspersample; int bpsl; static char *version = "ras2tif 1.0"; static char *datetime = "1990:01:01 12:00:00"; gettimeofday(&tv, (struct timezone *) NULL); ct = localtime(&tv.tv_sec); sprintf(datetime, "19%02d:%02d:%02d %02d:%02d:%02d", ct->tm_year, ct->tm_mon + 1, ct->tm_mday, ct->tm_hour, ct->tm_min, ct->tm_sec); setbuf(stderr, NULL); pname = argv[0]; while (--argc) { if ((++argv)[0][0] == '-') { switch (argv[0][1]) { case 'v': Verbose = True; break; case 'q': usage(); break; case '\0': if (inf == NULL) dummyinput = True; else usage(); break; default: fprintf(stderr, "%s: illegal option -%c.\n", pname, argv[0][1]); exit(1); } } else if (inf == NULL && !dummyinput) { inf = argv[0]; } else if (outf == NULL) outf = argv[0]; else usage(); } if (outf == NULL) error("%s: can't write output file to a stream.\n", NULL); if (dummyinput || inf == NULL) { inf = "Standard Input"; fp = stdin; } else if ((fp = fopen(inf, "r")) == NULL) error("%s: %s couldn't be opened.\n", inf); if (Verbose) fprintf(stderr, "Reading rasterfile from %s...", inf); pix = pr_load(fp, &Colormap); if (pix == NULL) error("%s: %s is not a raster file.\n", inf); if (Verbose) fprintf(stderr, "done.\n"); if (Verbose) fprintf(stderr, "Writing %s...", outf); tif = TIFFOpen(outf, "w"); if (tif == NULL) error("%s: error opening TIFF file %s", outf); width = pix->pr_width; height = pix->pr_height; depth = pix->pr_depth; switch (depth) { case 1: samplesperpixel = 1; bitspersample = 1; photometric = PHOTOMETRIC_MINISBLACK; break; case 8: samplesperpixel = 1; bitspersample = 8; photometric = PHOTOMETRIC_PALETTE; break; case 24: samplesperpixel = 3; bitspersample = 8; photometric = PHOTOMETRIC_RGB; break; case 32: samplesperpixel = 4; bitspersample = 8; photometric = PHOTOMETRIC_RGB; break; default: error("%s: bogus depth: %d\n", depth); } bpsl = ((depth * width + 15) >> 3) & ~1; rowsperstrip = (8 * 1024) / bpsl; TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bitspersample); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); TIFFSetField(tif, TIFFTAG_DOCUMENTNAME, inf); TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, "converted Sun rasterfile"); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); TIFFSetField(tif, TIFFTAG_STRIPBYTECOUNTS, height / rowsperstrip); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_SOFTWARE, version); TIFFSetField(tif, TIFFTAG_DATETIME, datetime); memset(red, 0, sizeof(red)); memset(green, 0, sizeof(green)); memset(blue, 0, sizeof(blue)); if (depth == 8) { TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); for (i = 0; i < Colormap.length; i++) { red[i] = SCALE(Colormap.map[0][i]); green[i] = SCALE(Colormap.map[1][i]); blue[i] = SCALE(Colormap.map[2][i]); } } if (Verbose) fprintf(stderr, "%dx%dx%d image, ", width, height, depth); for (row = 0; row < height; row++) if (TIFFWriteScanline(tif, (u_char *) mprd_addr(mpr_d(pix), 0, row), row, 0) < 0) { fprintf("failed a scanline write (%d)\n", row); break; } TIFFFlushData(tif); TIFFClose(tif); if (Verbose) fprintf(stderr, "done.\n"); pr_destroy(pix); exit(0); } green[i] = SCALE(Colormap.map[1][i]); blue[i] = SCALE(Colormap.map[2][i]); }tiff-v3.4beta018/contrib/ras/tif2ras.c000644 004341 000024 00000021471 05015657107 017331 0ustar00samuser000000 000000 #ifndef lint static char sccsid[] = "@(#)tif2ras.c 1.2 90/03/06"; #endif /*- * tif2ras.c - Converts from a Tagged Image File Format image to a Sun Raster. * * Copyright (c) 1990 by Sun Microsystems, Inc. * * Author: Patrick J. Naughton * naughton@wind.sun.com * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. * * This file is provided AS IS with no warranties of any kind. The author * shall have no liability with respect to the infringement of copyrights, * trade secrets or any patents by this file or any part thereof. In no * event will the author be liable for any lost revenue or profits or * other special, indirect and consequential damages. * * Comments and additions should be sent to the author: * * Patrick J. Naughton * Sun Microsystems * 2550 Garcia Ave, MS 14-40 * Mountain View, CA 94043 * (415) 336-1080 * * Revision History: * 10-Jan-89: Created. * 06-Mar-90: Change to byte encoded rasterfiles. * fix bug in call to ReadScanline(). * fix bug in CVT() macro. * fix assignment of td, (missing &). * * Description: * This program takes a MicroSoft/Aldus "Tagged Image File Format" image or * "TIFF" file as input and writes a Sun Rasterfile [see rasterfile(5)]. The * output file may be standard output, but the input TIFF file must be a real * file since seek(2) is used. */ #include #include #include "tiffio.h" typedef int boolean; #define True (1) #define False (0) #define CVT(x) (((x) * 255) / ((1L<<16)-1)) boolean Verbose = False; char *pname; /* program name (used for error messages) */ void error(s1, s2) char *s1, *s2; { fprintf(stderr, s1, pname, s2); exit(1); } void usage() { error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL); } main(argc, argv) int argc; char *argv[]; { char *inf = NULL; char *outf = NULL; FILE *fp; long width, height; int depth, numcolors; register TIFF *tif; TIFFDirectory *td; register u_char *inp, *outp; register int col, i; register long row; u_char *Map = NULL; u_char *buf; short bitspersample; short samplesperpixel; short photometric; u_short *redcolormap, *bluecolormap, *greencolormap; Pixrect *pix; /* The Sun Pixrect */ colormap_t Colormap; /* The Pixrect Colormap */ u_char red[256], green[256], blue[256]; setbuf(stderr, NULL); pname = argv[0]; while (--argc) { if ((++argv)[0][0] == '-') switch (argv[0][1]) { case 'v': Verbose = True; break; case 'q': usage(); break; default: fprintf(stderr, "%s: illegal option -%c.\n", pname, argv[0][1]); exit(1); } else if (inf == NULL) inf = argv[0]; else if (outf == NULL) outf = argv[0]; else usage(); } if (inf == NULL) error("%s: can't read input file from a stream.\n", NULL); if (Verbose) fprintf(stderr, "Reading %s...", inf); tif = TIFFOpen(inf, "r"); if (tif == NULL) error("%s: error opening TIFF file %s", inf); if (Verbose) TIFFPrintDirectory(tif, stderr, True, False, False); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample > 8) error("%s: can't handle more than 8-bits per sample\n", NULL); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); switch (samplesperpixel) { case 1: if (bitspersample == 1) depth = 1; else depth = 8; break; case 3: case 4: depth = 24; break; default: error("%s: only handle 1-channel gray scale or 3-channel color\n"); } TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); if (Verbose) fprintf(stderr, "%dx%dx%d image, ", width, height, depth); if (Verbose) fprintf(stderr, "%d bits/sample, %d samples/pixel, ", bitspersample, samplesperpixel); pix = mem_create(width, height, depth); if (pix == (Pixrect *) NULL) error("%s: can't allocate memory for output pixrect...\n", NULL); numcolors = (1 << bitspersample); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); if (numcolors == 2) { if (Verbose) fprintf(stderr, "monochrome "); Colormap.type = RMT_NONE; Colormap.length = 0; Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; } else { switch (photometric) { case PHOTOMETRIC_MINISBLACK: if (Verbose) fprintf(stderr, "%d graylevels (min=black), ", numcolors); Map = (u_char *) malloc(numcolors * sizeof(u_char)); for (i = 0; i < numcolors; i++) Map[i] = (255 * i) / numcolors; Colormap.type = RMT_EQUAL_RGB; Colormap.length = numcolors; Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; break; case PHOTOMETRIC_MINISWHITE: if (Verbose) fprintf(stderr, "%d graylevels (min=white), ", numcolors); Map = (u_char *) malloc(numcolors * sizeof(u_char)); for (i = 0; i < numcolors; i++) Map[i] = 255 - ((255 * i) / numcolors); Colormap.type = RMT_EQUAL_RGB; Colormap.length = numcolors; Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; break; case PHOTOMETRIC_RGB: if (Verbose) fprintf(stderr, "truecolor "); Colormap.type = RMT_NONE; Colormap.length = 0; Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; break; case PHOTOMETRIC_PALETTE: if (Verbose) fprintf(stderr, "colormapped "); Colormap.type = RMT_EQUAL_RGB; Colormap.length = numcolors; memset(red, 0, sizeof(red)); memset(green, 0, sizeof(green)); memset(blue, 0, sizeof(blue)); TIFFGetField(tif, TIFFTAG_COLORMAP, &redcolormap, &greencolormap, &bluecolormap); for (i = 0; i < numcolors; i++) { red[i] = (u_char) CVT(redcolormap[i]); green[i] = (u_char) CVT(greencolormap[i]); blue[i] = (u_char) CVT(bluecolormap[i]); } Colormap.map[0] = red; Colormap.map[1] = green; Colormap.map[2] = blue; break; case PHOTOMETRIC_MASK: error("%s: Don't know how to handle PHOTOMETRIC_MASK\n"); break; case PHOTOMETRIC_DEPTH: error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n"); break; default: error("%s: unknown photometric (cmap): %d\n", photometric); } } buf = (u_char *) malloc(TIFFScanlineSize(tif)); if (buf == NULL) error("%s: can't allocate memory for scanline buffer...\n", NULL); for (row = 0; row < height; row++) { if (TIFFReadScanline(tif, buf, row, 0) < 0) error("%s: bad data read on line: %d\n", row); inp = buf; outp = (u_char *) mprd_addr(mpr_d(pix), 0, row); switch (photometric) { case PHOTOMETRIC_RGB: if (samplesperpixel == 4) for (col = 0; col < width; col++) { *outp++ = *inp++; /* Blue */ *outp++ = *inp++; /* Green */ *outp++ = *inp++; /* Red */ inp++; /* skip alpha channel */ } else for (col = 0; col < width; col++) { *outp++ = *inp++; /* Blue */ *outp++ = *inp++; /* Green */ *outp++ = *inp++; /* Red */ } break; case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: switch (bitspersample) { case 1: for (col = 0; col < ((width + 7) / 8); col++) *outp++ = *inp++; break; case 2: for (col = 0; col < ((width + 3) / 4); col++) { *outp++ = (*inp >> 6) & 3; *outp++ = (*inp >> 4) & 3; *outp++ = (*inp >> 2) & 3; *outp++ = *inp++ & 3; } break; case 4: for (col = 0; col < width / 2; col++) { *outp++ = *inp >> 4; *outp++ = *inp++ & 0xf; } break; case 8: for (col = 0; col < width; col++) *outp++ = *inp++; break; default: error("%s: bad bits/sample: %d\n", bitspersample); } break; case PHOTOMETRIC_PALETTE: memcpy(outp, inp, width); break; default: error("%s: unknown photometric (write): %d\n", photometric); } } free((char *) buf); if (Verbose) fprintf(stderr, "done.\n"); if (outf == NULL || strcmp(outf, "Standard Output") == 0) { outf = "Standard Output"; fp = stdout; } else { if (!(fp = fopen(outf, "w"))) error("%s: %s couldn't be opened for writing.\n", outf); } if (Verbose) fprintf(stderr, "Writing rasterfile in %s...", outf); if (pr_dump(pix, fp, &Colormap, RT_BYTE_ENCODED, 0) == PIX_ERR) error("%s: error writing Sun Rasterfile: %s\n", outf); if (Verbose) fprintf(stderr, "done.\n"); pr_destroy(pix); if (fp != stdout) fclose(fp); exit(0); } strcmp(outf, "Standard Output") == 0) { outf = "Standard Output"; fp = stdout; } else { if (!(fp = fopen(outf, "w"))) error("%s: %s couldn't be opened for writing.\n", outf); } itiff-v3.4beta018/contrib/vms/libtiff/makevms.com000644 004341 000024 00000013344 05745166071 021422 0ustar00samuser000000 000000 $!======================================================================== $! $! Name : MAKEVMS $! $! Purpose : Compile TIFF library $! $! Arguments : $! $! Created 1-DEC-1994 Karsten Spang $! $!======================================================================== $ CURRENT_DIR=F$ENVIRONMENT("DEFAULT") $ ON CONTROL_Y THEN GOTO EXIT $ ON ERROR THEN GOTO EXIT $! $! Get hold on definitions $! $! Older versions of VMS may not recoqnize the "ARCH_NAME" keyword $! This happens only on VAX $! $ SAVE_MESS=F$ENVIRONMENT("MESSAGE") $ SET MESSAGE/NOID/NOFAC/NOSEV/NOTEXT $ ARCH=F$GETSYI("ARCH_NAME") $ SET MESSAGE 'SAVE_MESS' $ IF F$TYPE(ARCH).EQS."" THEN ARCH="VAX" $ ARCH=F$EDIT(ARCH,"UPCASE") $! $ DEFINE/NOLOG SYS SYS$LIBRARY $ THIS_FILE=F$ENVIRONMENT("PROCEDURE") $ PROC_NAME=F$PARSE(THIS_FILE,,,"NAME","SYNTAX_ONLY") $ THIS_DIR=F$PARSE(THIS_FILE,,,"DEVICE","SYNTAX_ONLY")+ - F$PARSE(THIS_FILE,,,"DIRECTORY","SYNTAX_ONLY") $ SET DEFAULT 'THIS_DIR' $ IF ARCH.EQS."ALPHA" $ THEN $ CONF_FP="HAVE_IEEEFP=1" $ ELSE $ CONF_FP="HAVE_IEEEFP=0" $ ENDIF $ CONF_LIBRARY="USE_VARARGS=0,USE_PROTOTYPES=1,USE_CONST=1,"+ - "BSDTYPES,MMAP_SUPPORT" $ IF P1.EQS."DEBUG" $ THEN $ DEBUG_OPTIONS="/DEBUG/NOOPTIMIZE" $ CONF_LIBRARY=CONF_LIBRARY+",DEBUG" $ LINK_OPTIONS="/DEBUG" $ ELSE $ DEBUG_OPTIONS="" $ LINK_OPTIONS="" $ ENDIF $ DEFINES="/DEFINE=("+CONF_FP+","+CONF_LIBRARY+")" $ C_COMPILE="CC"+DEBUG_OPTIONS+DEFINES $ IF ARCH.EQS."ALPHA" $ THEN $ C_COMPILE=C_COMPILE+ - "/FLOAT=IEEE_FLOAT/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES" $ ENDIF $! $ SOURCES="TIF_AUX,TIF_CCITTRLE,TIF_CLOSE,TIF_COMPRESS,"+ - "TIF_DIR,TIF_DIRINFO,TIF_DIRREAD,TIF_DIRWRITE,"+ - "TIF_DUMPMODE,TIF_ERROR,TIF_FAX3,TIF_FAX4,TIF_FLUSH,TIF_GETIMAGE,"+ - -! "TIF_JPEG,"+ - "TIF_LZW,TIF_NEXT,TIF_OPEN,TIF_PACKBITS,"+ - "TIF_PRINT,TIF_READ,TIF_STRIP,TIF_SWAB,TIF_THUNDER,TIF_TILE,"+ - "TIF_VERSION,TIF_VMS,TIF_WARNING,TIF_WRITE" $ LIBFILE="TIFF" $ IF F$SEARCH(LIBFILE+".OLB").EQS."" THEN - LIBRARY/CREATE 'LIBFILE' $! $! Create VERSION.H $! $ IF F$SEARCH("VERSION.H").EQS."" $ THEN $ OPEN/READ VERS [-]VERSION. $ READ VERS PRIMVERS $ CLOSE VERS $ OPEN/READ VERS [-.DIST]TIFF.ALPHA $ READ VERS ALPHAVERS $ CLOSE VERS $ ALPHAVERS=F$ELEMENT(2," ",ALPHAVERS) $ OPEN/WRITE VERS VERSION.H $ WRITE VERS "#define VERSION ""LIBTIFF, Version "+PRIMVERS+ALPHAVERS+ - "\nCopyright (c) 1988-1995 Sam Leffler\n"+ - "Copyright (c) 1991-1995 Silicon Graphics, Inc.""" $ CLOSE VERS $ ENDIF $! $! Create G3STATES.H $! $ IF F$SEARCH("G3STATES.H").EQS."" $ THEN $ WRITE SYS$OUTPUT "Creating G3STATES.H" $ IF F$SEARCH("MKG3STATES.EXE").EQS."" $ THEN $ IF F$SEARCH("MKG3STATES.OBJ").EQS."" $ THEN $ C_COMPILE MKG3STATES $ ENDIF $ IF ARCH.EQS."ALPHA" $ THEN $ LINK MKG3STATES $ ELSE $ LINK MKG3STATES,SYS$INPUT:/OPTIONS SYS$SHARE:VAXCRTL/SHARE $ ENDIF $ DELETE MKG3STATES.OBJ;* $ ENDIF $ MKG3STATES:=$'THIS_DIR'MKG3STATES $! $! return (0) in mkg3states causes a $! %NONAME-W-NOMSG, Message number 00000000 $! warning to be written at the end of g3states.h $! unless messages are suppressed $! $ SET MESSAGE/NOID/NOFAC/NOSEV/NOTEXT $ DEFINE/USER SYS$OUTPUT G3STATES.H $ MKG3STATES -C $ SET MESSAGE 'SAVE_MESS' $ DELETE MKG3STATES.EXE;* $ ENDIF $! $! Loop over modules $! $ NUMBER=0 $COMPILE_LOOP: $ FILE=F$ELEMENT(NUMBER,",",SOURCES) $ IF FILE.EQS."," THEN GOTO END_COMPILE $ C_FILE=F$PARSE(FILE,".C",,,"SYNTAX_ONLY") $ C_FILE=F$SEARCH(C_FILE) $ IF C_FILE.EQS."" $ THEN $ WRITE SYS$OUTPUT "Source file "+FILE+" not found" $ GOTO EXIT $ ENDIF $ C_DATE=F$CVTIME(F$FILE_ATTRIBUTES(C_FILE,"RDT")) $ OBJ_FILE=F$PARSE("",".OBJ",C_FILE,,"SYNTAX_ONLY") $ OBJ_FILE=F$EXTRACT(0,F$LOCATE(";",OBJ_FILE),OBJ_FILE) $ FOUND_OBJ_FILE=F$SEARCH(OBJ_FILE) $ IF FOUND_OBJ_FILE.EQS."" $ THEN $ OBJ_DATE="" $ ELSE $ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT")) $ ENDIF $ IF OBJ_DATE.LTS.C_DATE $ THEN $ WRITE SYS$OUTPUT "Compiling "+FILE $ ON ERROR THEN CONTINUE $ C_COMPILE/OBJECT='OBJ_FILE' 'C_FILE' $ ON ERROR THEN GOTO EXIT $ LIBRARY 'LIBFILE' 'OBJ_FILE' $ PURGE 'OBJ_FILE' $ ENDIF $ NUMBER=NUMBER+1 $ GOTO COMPILE_LOOP $END_COMPILE: $ IF ARCH.EQS."ALPHA" $ THEN $ OPT_FILE="TIFFSHRAXP" $ ELSE $ OPT_FILE="TIFFSHRVAX" $ FILE="TIFFVEC" $ MAR_FILE=F$PARSE(FILE,".MAR",,,"SYNTAX_ONLY") $ MAR_FILE=F$SEARCH(MAR_FILE) $ MAR_FILE=F$SEARCH("TIFFVEC.MAR") $ MAR_DATE=F$CVTIME(F$FILE_ATTRIBUTES(MAR_FILE,"RDT")) $ OBJ_FILE=F$PARSE("",".OBJ",MAR_FILE,,"SYNTAX_ONLY") $ OBJ_FILE=F$EXTRACT(0,F$LOCATE(";",OBJ_FILE),OBJ_FILE) $ FOUND_OBJ_FILE=F$SEARCH(OBJ_FILE) $ IF FOUND_OBJ_FILE.EQS."" $ THEN $ OBJ_DATE="" $ ELSE $ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT")) $ ENDIF $ IF OBJ_DATE.LTS.MAR_DATE $ THEN $ WRITE SYS$OUTPUT "Compiling "+FILE $ MACRO 'MAR_FILE' $ LIBRARY 'LIBFILE' 'OBJ_FILE' $ PURGE 'OBJ_FILE' $ ENDIF $ ENDIF $ WRITE SYS$OUTPUT "Creating shareable library" $ LINK/SHAREABLE='THIS_DIR'TIFFSHR'LINK_OPTIONS' 'OPT_FILE'/OPTIONS $ PURGE/LOG TIFFSHR.EXE $EXIT: $ SET DEFAULT 'CURRENT_DIR' $ EXIT $ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT")) $ ENDIF $ IF OBJ_DATE.LTS.MAR_DATE $ THEN $ WRITE SYS$OUTPUT "Compiling "+FILE $ MACRO 'MAR_FILE' $ LIBRARY 'LIBFILE' 'OBJ_FILE' $ PURGEtiff-v3.4beta018/contrib/vms/libtiff/tiff.opt000644 004341 000024 00000000022 05744741566 020727 0ustar00samuser000000 000000 TIFFSHR/SHAREABLE ENDIF $ ENDIF $ WRITE SYS$OUTPUT "Creating shareable library" $ LINK/SHAREABLE='THIS_DIR'TIFFSHR'LINK_OPTIONS' 'OPT_FILE'/OPTIONS $ PURGE/LOG TIFFSHR.EXE $EXIT: $ SET DEFAULT 'CURRENT_DIR' $ EXIT $ OBJ_DATE=F$CVTIME(F$FILE_ATTRES(FOUND_OBJµ¢0@«TDT")F’ˆ!$ˆ Ôˆ'¨ˆ;Mˆ²¸ˆLÔˆ+Pˆ²¸ˆM|ˆìÕXˆ²¸ˆ²¸ˆ»¨ˆ²¸ˆ+Pˆ²¸ˆxÿ$ˆ€ˆÑØèˆxø ÚžMAR_' $ LIBRARÿÊgÿÊ‹/ÿ¯›p@<à PURGEtiff-v3.4beta018/contrib/vms/libtiff/tiffshraxp.opt000750 004341 000024 00000006225 05745164126 022156 0ustar00samuser000000 000000 ! VMS linker options file for linking the TIFF library into a shareable image ! IDENTIFICATION="LIBTIFF 3.4-002" ! ! Please update the minor version number below, when adding new routines GSMATCH=LEQUAL,1,8 ! ! Here goes the definitions of all public functions in the library, plus ! a few extra that are called by the tools. ! The sequence MUST NOT be changed, otherwise you will have to relink ! all applications. Add new functions at the end. ! SYMBOL_VECTOR=(- TIFFCheckTile=PROCEDURE,- TIFFClose=PROCEDURE,- TIFFComputeStrip=PROCEDURE,- TIFFComputeTile=PROCEDURE,- TIFFCurrentDirectory=PROCEDURE,- TIFFCurrentRow=PROCEDURE,- TIFFCurrentStrip=PROCEDURE,- TIFFCurrentTile=PROCEDURE,- TIFFError=PROCEDURE,- TIFFFdOpen=PROCEDURE,- TIFFFileName=PROCEDURE,- TIFFFileno=PROCEDURE,- TIFFFlush=PROCEDURE,- TIFFFlushData=PROCEDURE,- TIFFGetField=PROCEDURE,- TIFFGetFieldDefaulted=PROCEDURE,- TIFFGetMode=PROCEDURE,- TIFFIsTiled=PROCEDURE,- TIFFModeCCITTFax3=PRIVATE_PROCEDURE,- ! gone in 3.3 beta 024 TIFFNumberOfStrips=PROCEDURE,- TIFFNumberOfTiles=PROCEDURE,- TIFFOpen=PROCEDURE,- TIFFPrintDirectory=PROCEDURE,- TIFFReadBufferSetup=PROCEDURE,- TIFFReadDirectory=PROCEDURE,- TIFFReadEncodedStrip=PROCEDURE,- TIFFReadEncodedTile=PROCEDURE,- TIFFReadRawStrip=PROCEDURE,- TIFFReadRawTile=PROCEDURE,- TIFFReadRGBAImage=PROCEDURE,- TIFFReadScanline=PROCEDURE,- TIFFReadTile=PROCEDURE,- TIFFReverseBits=PROCEDURE,- TIFFScanlineSize=PROCEDURE,- TIFFSetDirectory=PROCEDURE,- TIFFSetErrorHandler=PROCEDURE,- TIFFSetField=PROCEDURE,- TIFFSetWarningHandler=PROCEDURE,- TIFFStripSize=PROCEDURE,- TIFFSwabShort=PROCEDURE,- TIFFSwabLong=PROCEDURE,- TIFFSwabArrayOfShort=PROCEDURE,- TIFFSwabArrayOfLong=PROCEDURE,- TIFFTileRowSize=PROCEDURE,- TIFFTileSize=PROCEDURE,- TIFFVGetField=PROCEDURE,- TIFFVGetFieldDefaulted=PROCEDURE,- TIFFVSetField=PROCEDURE,- TIFFWarning=PROCEDURE,- TIFFWriteDirectory=PROCEDURE,- TIFFWriteEncodedStrip=PROCEDURE,- TIFFWriteEncodedTile=PROCEDURE,- TIFFWriteRawStrip=PROCEDURE,- TIFFWriteRawTile=PROCEDURE,- TIFFWriteScanline=PROCEDURE,- TIFFWriteTile=PROCEDURE,- ! ! New entries in version 3.1 ! TIFFClientOpen=PROCEDURE,- TIFFVStripSize=PROCEDURE,- ! For tiffcp ! ! New entries in version 3.2 ! TIFFGetVersion=PROCEDURE,- TIFFGetBitRevTable=PROCEDURE,- _TIFFmalloc=PROCEDURE,- ! For fax2tiff ! ! New entries in version 3.3 ! TIFFIsByteSwapped=PROCEDURE,- TIFFSetWriteOffset=PROCEDURE,- ! ! New entries in version 3.3 beta 020 ! TIFFSetSubDirectory=PROCEDURE,- TIFFUnlinkDirectory=PROCEDURE,- ! ! These needs to be global on the Alpha (used in fax2tiff) ! tiffDataWidth=DATA,- tiffFieldInfo=DATA,- ! ! New entries in version 3.3 beta 026 (for the tools) ! _TIFFfree=PROCEDURE,- _TIFFrealloc=PROCEDURE,- _TIFFmemset=PROCEDURE,- _TIFFmemcpy=PROCEDURE,- _TIFFmemcmp=PROCEDURE,- ! ! New entries in version 3.4 beta 002 ! TIFFRasterScanlineSize=PROCEDURE,- TIFFDefaultStripSize=PROCEDURE,- TIFFDefaultTileSize=PROCEDURE,- TIFFVTileSize=PROCEDURE,- ! not new, but omitted previously TIFFSwabDouble=PROCEDURE,- TIFFSwabArrayOfDouble=PROCEDURE,- TIFFLastDirectory=PROCEDURE) ! not new either ! ! Then take the object library ! TIFF/LIBRARY a 026 (for the tools) ! _TIFFfree=PROCEDURE,- _TIFFrealloc=PROCEDURE,- _TIFFmemset=PROCEDURE,- _TIFFmemcpy=PROCEDURE,- _TIFFmemcmp=PROCEDURE,- ! ! New entries in version 3.4 beta 002 ! TIFFRasterScanlineSize=PROCEDURE,- TIFFDefaultStripSize=PROCEDURE,- TIFFDefaultTileSize=PROCEDURE,- TIFFVTileSize=PROCEDURE,- ! not new, but omitted previously TIFFSwabtiff-v3.4beta018/contrib/vms/libtiff/tiffshrvax.opt000644 004341 000024 00000000617 05745164130 022160 0ustar00samuser000000 000000 ! VMS linker options file for linking the TIFF library into a shareable image ! IDENTIFICATION="LIBTIFF 3.4-002" ! ! Please update the minor version number below, when adding new routines GSMATCH=LEQUAL,1,8 ! ! Place the transfer vector at the beginning of the image ! CLUSTER=TIFFVEC,,,TIFFVEC ! ! Then take the object library ! TIFF/LIBRARY ! ! The C RTL shareable image ! SYS$SHARE:VAXCRTL/SHARE ’ÿˆ ˆ  ˆ µ’ª°%âˆ8ŒIFFVSize=PROCEDURE,- ! nÿÊÉÿÊí/ÿ¯›p@<àiously TIFFSwabtiff-v3.4beta018/contrib/vms/libtiff/tiffvec.mar000644 004341 000024 00000005661 05745164125 021407 0ustar00samuser000000 000000 .TITLE TIFFVEC - Transfer vector for TIFF library .IDENT /LIBTIFF 3.4-002/ ; .PSECT TIFFVEC,EXE,NOWRT,PIC,SHR,GBL,QUAD ; ; Macro that defines one entry in the transfer vector ; .MACRO VECTOR,NAME .ALIGN QUAD .TRANSFER NAME .MASK NAME JMP L^NAME+2 .ENDM ; ; Here goes the definitions of all public functions in the library, plus ; a few extra that are called by the tools. ; The sequence MUST NOT be changed, otherwise you will have to relink ; all applications. Add new functions at the end. ; VECTOR TIFFCheckTile VECTOR TIFFClose VECTOR TIFFComputeStrip VECTOR TIFFComputeTile VECTOR TIFFCurrentDirectory VECTOR TIFFCurrentRow VECTOR TIFFCurrentStrip VECTOR TIFFCurrentTile VECTOR TIFFError VECTOR TIFFFdOpen VECTOR TIFFFileName VECTOR TIFFFileno VECTOR TIFFFlush VECTOR TIFFFlushData VECTOR TIFFGetField VECTOR TIFFGetFieldDefaulted ; ; TIFFGetFileSize was removed in version 3.2. It has been replaced by a ; dummy value that makes the program abort with a privileged instruction ; fault, in case an old program calls TIFFGetFileSize. ; ; VECTOR TIFFGetFileSize .QUAD 0 ; VECTOR TIFFGetMode VECTOR TIFFIsTiled ; ; TIFFModeCCITTFax3 gone in 3.3 beta 024 ; VECTOR TIFFModeCCITTFax3 .QUAD 0 VECTOR TIFFNumberOfStrips VECTOR TIFFNumberOfTiles VECTOR TIFFOpen VECTOR TIFFPrintDirectory VECTOR TIFFReadBufferSetup VECTOR TIFFReadDirectory VECTOR TIFFReadEncodedStrip VECTOR TIFFReadEncodedTile VECTOR TIFFReadRawStrip VECTOR TIFFReadRawTile VECTOR TIFFReadRGBAImage VECTOR TIFFReadScanline VECTOR TIFFReadTile VECTOR TIFFReverseBits VECTOR TIFFScanlineSize VECTOR TIFFSetDirectory VECTOR TIFFSetErrorHandler VECTOR TIFFSetField VECTOR TIFFSetWarningHandler VECTOR TIFFStripSize VECTOR TIFFSwabShort VECTOR TIFFSwabLong VECTOR TIFFSwabArrayOfShort VECTOR TIFFSwabArrayOfLong VECTOR TIFFTileRowSize VECTOR TIFFTileSize VECTOR TIFFVGetField VECTOR TIFFVGetFieldDefaulted VECTOR TIFFVSetField VECTOR TIFFWarning VECTOR TIFFWriteDirectory VECTOR TIFFWriteEncodedStrip VECTOR TIFFWriteEncodedTile VECTOR TIFFWriteRawStrip VECTOR TIFFWriteRawTile VECTOR TIFFWriteScanline VECTOR TIFFWriteTile ; ; New entries in version 3.1 ; VECTOR TIFFClientOpen VECTOR TIFFVStripSize ; For tiffcp ; ; New entries in version 3.2 ; VECTOR TIFFGetVersion VECTOR TIFFGetBitRevTable VECTOR _TIFFmalloc ; For fax2tiff ; ; New entries in version 3.3 ; VECTOR TIFFIsByteSwapped VECTOR TIFFSetWriteOffset ; ; New entries in version 3.3 beta 020 ; VECTOR TIFFSetSubDirectory VECTOR TIFFUnlinkDirectory ; ; New entries in version 3.3 beta 026 (for the tools) ; VECTOR _TIFFfree VECTOR _TIFFrealloc VECTOR _TIFFmemset VECTOR _TIFFmemcpy VECTOR _TIFFmemcmp ; ; New entries in version 3.4 beta 002 ; VECTOR TIFFRasterScanlineSize VECTOR TIFFDefaultStripSize VECTOR TIFFDefaultTileSize VECTOR TIFFVTileSize ; not new, but omitted previously VECTOR TIFFSwabDouble VECTOR TIFFSwabArrayOfDouble VECTOR TIFFLastDirectory ; not new either .END beta 020 ; VECTOR TIFFSetSubDirectory VECTOR TIFFUnlinkDirectory ; ; New entrtiff-v3.4beta018/contrib/vms/tools/makevms.com000644 004341 000024 00000010003 05745155653 021134 0ustar00samuser000000 000000 $!======================================================================== $! $! Name : MAKEVMS $! $! Purpose : Compile TIFF tools $! $! Arguments : $! $! Created 6-DEC-1991 Karsten Spang $! $!======================================================================== $ CURRENT_DIR=F$ENVIRONMENT("DEFAULT") $ ON CONTROL_Y THEN GOTO EXIT $ ON ERROR THEN GOTO EXIT $! $! Get hold on definitions $! $! Older versions of VMS may not recoqnize the "ARCH_NAME" keyword $! This happens only on VAX $! $ SAVE_MESS=F$ENVIRONMENT("MESSAGE") $ SET MESSAGE/NOID/NOFAC/NOSEV/NOTEXT $ ARCH=F$GETSYI("ARCH_NAME") $ SET MESSAGE 'SAVE_MESS' $ IF F$TYPE(ARCH).EQS."" THEN ARCH="VAX" $ ARCH=F$EDIT(ARCH,"UPCASE") $! $ DEFINE SYS SYS$LIBRARY $ THIS_FILE=F$ENVIRONMENT("PROCEDURE") $ PROC_NAME=F$PARSE(THIS_FILE,,,"NAME","SYNTAX_ONLY") $ THIS_DIR=F$PARSE(THIS_FILE,,,"DEVICE","SYNTAX_ONLY")+ - F$PARSE(THIS_FILE,,,"DIRECTORY","SYNTAX_ONLY") $ SET DEFAULT 'THIS_DIR' $ LIB_DIR=F$PARSE("[-.LIBTIFF]") $ LIB_DIR=F$PARSE(LIB_DIR,,,"DEVICE","SYNTAX_ONLY")+ - F$PARSE(LIB_DIR,,,"DIRECTORY","SYNTAX_ONLY") $ DEFINE TIFFSHR 'LIB_DIR'TIFFSHR $ CONF_LIBRARY="USE_VARARGS=0,USE_PROTOTYPES=1,USE_CONST=1,"+ - "BSDTYPES,MMAP_SUPPORT" $ IF ARCH.EQS."ALPHA" $ THEN $ CONF_FP="HAVE_IEEEFP=1" $ ALPHA_OPT="/PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES/FLOAT=IEEE_FLOAT" $ ELSE $ CONF_FP="HAVE_IEEEFP=0" $ ALPHA_OPT="" $ ENDIF $ DEFINES="/DEFINE=("+CONF_LIBRARY+","+CONF_FP+")" $ INCLUDES="/INCLUDE="+LIB_DIR $ IF P1.EQS."DEBUG" $ THEN $ DEBUG_OPTIONS="/DEBUG/NOOPTIMIZE" $ LINK_OPTIONS="/DEBUG" $ ELSE $ DEBUG_OPTIONS="" $ LINK_OPTIONS="" $ ENDIF $ C_COMPILE="CC"+DEBUG_OPTIONS+DEFINES+INCLUDES+ALPHA_OPT $! $ SOURCES="TIFFDUMP,TIFFINFO,TIFFCMP,TIFFCP,TIFFMEDIAN,"+ - "TIFF2BW,TIFFDITHER,TIFF2PS,FAX2TIFF,PAL2RGB,"+ - "GIF2TIFF,PPM2TIFF,RAS2TIFF,TIFFSPLIT,RGB2YCBCR" $! $! The other programs need GETOPT.OBJ $! $ FILE="[-.PORT]GETOPT" $ C_FILE=F$PARSE(FILE,".C",,,"SYNTAX_ONLY") $ C_FILE=F$SEARCH(C_FILE) $ IF C_FILE.EQS."" $ THEN $ WRITE SYS$OUTPUT "Source file "+FILE+" not found" $ GOTO EXIT $ ENDIF $ C_DATE=F$CVTIME(F$FILE_ATTRIBUTES(C_FILE,"RDT")) $ OBJ_FILE=F$PARSE("",".OBJ",C_FILE,,"SYNTAX_ONLY") $ OBJ_FILE=F$EXTRACT(0,F$LOCATE(";",OBJ_FILE),OBJ_FILE) $ FOUND_OBJ_FILE=F$SEARCH(OBJ_FILE) $ IF FOUND_OBJ_FILE.EQS."" $ THEN $ OBJ_DATE="" $ ELSE $ OBJ_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_OBJ_FILE,"CDT")) $ ENDIF $ IF OBJ_DATE.LTS.C_DATE $ THEN $ WRITE SYS$OUTPUT "Compiling "+FILE $ C_COMPILE/OBJECT='OBJ_FILE' 'FILE' $ PURGE 'OBJ_FILE' $ ENDIF $! $! Loop over programs $! $ NUMBER=0 $COMPILE_LOOP: $ FILE=F$ELEMENT(NUMBER,",",SOURCES) $ IF FILE.EQS."," THEN GOTO END_COMPILE $ C_FILE=F$PARSE(FILE,".C",,,"SYNTAX_ONLY") $ C_FILE=F$SEARCH(C_FILE) $ IF C_FILE.EQS."" $ THEN $ WRITE SYS$OUTPUT "Source file "+FILE+" not found" $ GOTO EXIT $ ENDIF $ C_DATE=F$CVTIME(F$FILE_ATTRIBUTES(C_FILE,"RDT")) $ EXE_FILE=F$PARSE("",".EXE",C_FILE,,"SYNTAX_ONLY") $ EXE_FILE=F$EXTRACT(0,F$LOCATE(";",EXE_FILE),EXE_FILE) $ FOUND_EXE_FILE=F$SEARCH(EXE_FILE) $ IF FOUND_EXE_FILE.EQS."" $ THEN $ EXE_DATE="" $ ELSE $ EXE_DATE=F$CVTIME(F$FILE_ATTRIBUTES(FOUND_EXE_FILE,"CDT")) $ ENDIF $ IF EXE_DATE.LTS.C_DATE $ THEN $ WRITE SYS$OUTPUT "Compiling "+FILE $ C_COMPILE 'FILE' $ IF ARCH.EQS."ALPHA" $ THEN $ LINK'LINK_OPTIONS' 'FILE',[-.PORT]GETOPT,'LIB_DIR'TIFF/OPTIONS $ ELSE $ LINK'LINK_OPTIONS' 'FILE',[-.PORT]GETOPT, - 'LIB_DIR'TIFF/OPTIONS,SYS$INPUT:/OPTIONS SYS$SHARE:VAXCRTL/SHAREABLE $ ENDIF $ DELETE 'FILE'.OBJ;* $ PURGE 'EXE_FILE' $ ENDIF $ NUMBER=NUMBER+1 $ GOTO COMPILE_LOOP $END_COMPILE: $EXIT: $ SET DEFAULT 'CURRENT_DIR' $ EXIT C_COMPILE 'FILE' $ IF ARCH.EQS."ALPHA" $ THEN $ LINK'LINK_OPTIONS' 'FILE',[-.PORT]GETOPT,'LIB_DIR'TIFF/OPTIONS $ ELSE $ LINK'LINK_OPTIONS' 'FILE',[-.PORT]GETOPT, - 'LIB_DIR'TIFF/OPTIONS,SYS$INPUT:/OPTIONS SYS$SHARE:VAXCRTL/SHAREABLE $ ENDIF $ DELETE 'FILE'.OBJ;* $ PURGE 'EXE_FILE' $ ENDIF $ NUMBER=NUMBER+1 $ GOTO COMPILE_LOOP $END_COMPILE: $EXIT: $ SET DEFAULT 'CURRENT_DIR' $ EXtiff-v3.4beta018/contrib/tags/000755 004341 000024 00000000000 05775025103 015755 5ustar00samuser000000 000000 tiff-v3.4beta018/contrib/tags/Makefile.gcc000644 004341 000024 00000001574 05774544432 020171 0ustar00samuser000000 000000 # Makefile for XLIBTIFF # # Written by: Niles Ritter # # This Makefile is for use with gcc (2.2.2 or later) # DESTDIR=. # AR = /usr/bin/ar AROPTS = rc RANLIB = /usr/bin/ranlib NULL= TIFFLIB=../../libtiff PORT=../.. IPATH= -I. -I${TIFFLIB} -I${PORT} CONF_LIBRARY=\ ${NULL} CC= gcc COPTS= -ansi -g CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY} # LIBS= ./libxtiff.a ${TIFFLIB}/libtiff.a OBJS= \ xtif_dir.o \ maketif.o \ listtif.o \ ${NULL} PROGS= maketif listtif LIBXTIFF= libxtiff.a ALL= ${LIBXTIFF} ${PROGS} all: ${ALL} library: ${LIBXTIFF} test: ${PROGS} ./maketif ./listtif maketif: maketif.o libxtiff.a ${CC} ${COPTS} maketif.o ${LIBS} -o maketif listtif: listtif.o libxtiff.a ${CC} ${COPTS} listtif.o ${LIBS} -o listtif libxtiff.a: xtif_dir.o ${AR} ${AROPTS} libxtiff.a xtif_dir.o ${RANLIB} libxtiff.a clean: rm -f ${ALL} ${OBJS} core a.out newtif.tif LIB}/libtiff.a OBJS= \ xtif_dir.o \ maketif.o \ listtif.o \ ${NULL} PROGS= maketif listtif LIBXTIFF= libxtiff.a ALL= ${LIBXtiff-v3.4beta018/contrib/tags/Makefile.mpw000644 004341 000024 00000002457 05774462613 020241 0ustar00samuser000000 000000 #*********************************************************************** # # MPW build file for example LIBXTIFF utilities # # written by Niles D. Ritter. # CC = c AR = lib -o RM = delete -y LN = duplicate -y #debug option #DEBUG= -sym full DEBUG= # data/code model options #MODEL= MODEL= -model far TIFFLIB = :::libtiff: LINK.c = Link {LDFLAGS} .o Ä .c {CC} {DEBUG} {CFLAGS} {CPPFLAGS} {Default}.c -o {Default}.o LDFLAGS = {DEBUG} {MODEL} -c 'MPS ' -t MPST -w CFLAGS = {MODEL} CPPFLAGS = -I {TIFFLIB} OBJS = maketif.o listtif.o xtif_dir.o CLEANOBJS = maketif.o listtif.o xtif_dir.o CLEANOTHER = newtif.tif CLEANINC = LIBS = {TIFFLIB}libtiff.o ¶ libxtiff.o ¶ "{CLibraries}"StdClib.o ¶ "{Libraries}"Stubs.o ¶ "{Libraries}"Runtime.o ¶ "{Libraries}"Interface.o PROGS= maketif listtif LIBXTIFF= libxtiff.o ALL= {LIBXTIFF} {PROGS} all Ä {ALL} library Ä {LIBXTIFF} test Ä {PROGS} maketif listtif compile Ä {OBJS} maketif Ä maketif.o libxtiff.o {LINK.c} -o maketif maketif.o {LIBS} listtif Ä listtif.o libxtiff.o {LINK.c} -o listtif listtif.o {LIBS} libxtiff.o Ä xtif_dir.o lib -o libxtiff.o xtif_dir.o clean Ä {RM} {CLEANOBJS} || set status 0 {RM} {LIBXTIFF} || set status 0 {RM} {PROGS} || set status 0 {RM} Å.tif || set status 0 terface.o PROGS= maketif listtif LIBXTIFF= libxtiff.o ALL= {LIBXTIFF} {PROGS} all Ä {ALL} library Ä {LIBXTIFF} test Ä {PROGS} maketif listtif compile Ä {OBJS} maketif Ä maketif.o libxtiff.o tiff-v3.4beta018/contrib/tags/README000644 004341 000024 00000010553 05774560246 016654 0ustar00samuser000000 000000 Client module for adding to LIBTIFF tagset ------------------------------------------- Author: Niles Ritter In the past, users of the "libtiff" package had to modify the source code of the library if they required additional private tags or codes not recognized by libtiff. Thus, whenever a new revision of libtiff came out the client would have to perform modifications to six or seven different files to re-install their tags. The latest versions of libtiff now provide client software new routines, giving them the opportunity to install private extensions at runtime, rather than compile-time. This means that the client may encapsulate all of their private tags into a separate module, which need only be recompiled when new versions of libtiff are released; no manual editing of files is required. How it works ------------ The mechanism for overriding the tag access has been enabled with a single new routine, which has the following calling sequence: TIFFExtendProc old_extender; old_extender = TIFFSetTagExtender(tag_extender); which must be called prior to opening or creating TIFF files. This routine sets a static pointer to the user-specified function , which in turn is called by TIFFDefaultDirectory(), just after the usual TIFFSetField() and TIFFGetField() methods are defined, and just before the compression tag is set. It also returns a pointer to the previously-defined value of the tag-extender, so that multiple clients may be installed. The TIFFExtendProc method that you define should be used to override the TIFF file's "vsetfield" and "vgetfield" methods, so that you can trap your new, private tags, and install their values into a private directory structure. For your convienience, a new pointer has also been added to the "TIFF" file structure: tidata_t tif_clientdir; /* client TIFF directory */ into which you may install whatever private directory structures you like. You should also override the tag-printing method from within your "vsetfield" method, to permit the symbolic printing of your new tags. Example Client Code: -------------------- An example module has been provided as a template for installing your own tags into a client tag extender. The module is called "xtif_dir.c", and defines all of the interface routines, tag field access, tag printing, etc. for most purpose. To see how the client module operates, there are three "fake" tags currently installed. If you use the existing makefile you can build them with: make all -f Makefile.gcc !or Makefile.mpw maketif listtif This will build two example programs called "maketif" and "listtif" and then run them. These programs do nothing more than create a small file called "newtif.tif", install the fake tags, and then list them out using TIFFPrintDirectory(). Installing Private Tags ----------------------- To use this module for installing your own tags, edit each of the files xtif_dir.c xtiffio.h xtiffiop.h and search for the string "XXX". At these locations the comments will direct you how to install your own tag values, define their types, etc. Three examples tags are currently installed, demonstrating how to implement multi-valued tags, single-valued tags, and ASCII tags. The examples are not valid, registered tags, so you must replace them with your own. To test the routines, also edit the test programs "maketif.c" and "listtif.c" and replace the portions of the code that set the private tag values and list them. Once you have edited these files, you may build the client module with the Makefile provided, and run the test programs. To use these files in your own code, the "xtif_dir.c" module defines replacement routines for the standard "TIFFOpen()" "TIFFFdOpen", and "TIFFClose()" routines, called XTIFFOpen, XTIFFFdOpen and XTIFFClose. You must use these routines in order to have the extended tag handlers installed. Once installed, the standard TIFFGetField() and TIFFSetField routines may be used as before. Adding Extended Tags to "tools" ------------------------------- To create an extended-tag savvy "tiffinfo" program or other utility, you may simply recompile and link the tools to your "libxtiff" library, adding -DTIFFOpen=XTIFFOpen -DTIFFClose=XTIFFClose -DTIFFFdOpen=XTIFFFdOpen to the compile statement. Bugs, Comments Etc: ------------------ Send all reports and suggestions to ndr@tazboy.jpl.nasa.gov (Niles Ritter). d, the standard TIFFGetField() and TIFFSetField routines may be used as before. Adding Extended Tags to "tools" ------------------------------- To ctiff-v3.4beta018/contrib/tags/listtif.c000644 004341 000024 00000001015 05774267476 017620 0ustar00samuser000000 000000 /* * listtif.c -- lists a tiff file. */ #include "xtiffio.h" #include void main(int argc,char *argv[]) { char *fname="newtif.tif"; int flags; TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ if (argc>1) fname=argv[1]; tif=XTIFFOpen(fname,"r"); if (!tif) goto failure; /* We want the double array listed */ flags = TIFFPRINT_MYMULTIDOUBLES; TIFFPrintDirectory(tif,stdout,flags); XTIFFClose(tif); exit (0); failure: printf("failure in listtif\n"); if (tif) XTIFFClose(tif); exit (-1); } .c -- lists a tiff file. */ #include "xtiffio.h" #include void main(int argc,char *argv[]) { char *fname="newtif.tif"; int flags; TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ if (argc>1) fname=argv[1]; tif=XTIFFOpen(fname,"r"); if (!tif) goto failure; /* We want the double array listed */ flags = TIFFPRINT_MYMULTIDOUBLES; TIFFPrintDirectory(tif,stdout,flags); XTIFFClose(tif); exit (0); failure: printf("failure in listtif\n"); if (tif) XTIFFClose(tif); etiff-v3.4beta018/contrib/tags/maketif.c000644 004341 000024 00000002737 05774271052 017557 0ustar00samuser000000 000000 /* * maketif.c -- creates a little TIFF file, with * the XTIFF extended tiff example tags. */ #include #include "xtiffio.h" void SetUpTIFFDirectory(TIFF *tif); void WriteImage(TIFF *tif); #define WIDTH 20 #define HEIGHT 20 void main() { TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ tif=XTIFFOpen("newtif.tif","w"); if (!tif) goto failure; SetUpTIFFDirectory(tif); WriteImage(tif); XTIFFClose(tif); exit (0); failure: printf("failure in maketif\n"); if (tif) XTIFFClose(tif); exit (-1); } void SetUpTIFFDirectory(TIFF *tif) { double mymulti[6]={0.0,1.0,2.0, 3.1415926, 5.0,1.0}; uint32 mysingle=3456; char *ascii="This file was produced by Steven Spielberg. NOT"; TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH); TIFFSetField(tif,TIFFTAG_IMAGELENGTH,HEIGHT); TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE); TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_MINISBLACK); TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8); TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,20); /* Install the extended TIFF tag examples */ TIFFSetField(tif,TIFFTAG_EXAMPLE_MULTI,6,mymulti); TIFFSetField(tif,TIFFTAG_EXAMPLE_SINGLE,mysingle); TIFFSetField(tif,TIFFTAG_EXAMPLE_ASCII,ascii); } void WriteImage(TIFF *tif) { int i; char buffer[WIDTH]; memset(buffer,0,sizeof(buffer)); for (i=0;i /* Tiff info structure. * * Entry format: * { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM, * OkToChange, PassDirCountOnSet, AsciiName } * * For ReadCount, WriteCount, -1 = unknown; used for mult-valued * tags and ASCII. */ static const TIFFFieldInfo xtiffFieldInfo[] = { /* XXX Replace these example tags with your own extended tags */ { TIFFTAG_EXAMPLE_MULTI, -1,-1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI, TRUE, TRUE, "MyMultivaluedTag" }, { TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE, TRUE, FALSE, "MySingleLongTag" }, { TIFFTAG_EXAMPLE_ASCII, -1,-1, TIFF_ASCII, FIELD_EXAMPLE_ASCII, TRUE, FALSE, "MyAsciiTag" }, }; #define N(a) (sizeof (a) / sizeof (a[0])) static void _XTIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) { xtiff *xt = XTIFFDIR(tif); XTIFFDirectory *xd = &xt->xtif_dir; int i,num; /* call the inherited method */ if (PARENT(xt,printdir)) (PARENT(xt,printdir))(tif,fd,flags); /* XXX Add field printing here. Replace the three example * tags implemented below with your own. */ fprintf(fd,"--My Example Tags--\n"); /* Our first example tag may have a lot of values, so we * will only print them out if the TIFFPRINT_MYMULTIDOUBLES * flag is passed into the print method. */ if (TIFFFieldSet(tif,FIELD_EXAMPLE_MULTI)) { fprintf(fd, " My Multi-Valued Doubles:"); if (flags & TIFFPRINT_MYMULTIDOUBLES) { double *value = xd->xd_example_multi; num = xd->xd_num_multi; fprintf(fd,"("); for (i=0;ixd_example_single); } if (TIFFFieldSet(tif,FIELD_EXAMPLE_ASCII)) { _TIFFprintAsciiTag(fd,"My ASCII Tag", xd->xd_example_ascii); } } static int _XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) { xtiff *xt = XTIFFDIR(tif); XTIFFDirectory* xd = &xt->xtif_dir; int status = 1; uint32 v32=0; int i=0, v=0; va_list ap1 = ap; /* va_start is called by the calling routine */ switch (tag) { /* * XXX put your extended tags here; replace the implemented * example tags with your own. */ case TIFFTAG_EXAMPLE_MULTI: /* multi-valued tags need to store the count as well */ xd->xd_num_multi = (uint16) va_arg(ap, int); _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*), (long) xd->xd_num_multi); break; case TIFFTAG_EXAMPLE_SINGLE: xd->xd_example_single = va_arg(ap, uint32); break; case TIFFTAG_EXAMPLE_ASCII: _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*)); break; default: /* call the inherited method */ return (PARENT(xt,vsetfield))(tif,tag,ap); break; } if (status) { /* we have to override the print method here, * after the compression tags have gotten to it. * This makes sense because the only time we would * need the extended print method is if an extended * tag is set by the reader. */ if (!(xt->xtif_flags & XTIFFP_PRINT)) { PARENT(xt,printdir) = TIFFMEMBER(tif,printdir); TIFFMEMBER(tif,printdir) = _XTIFFPrintDirectory; xt->xtif_flags |= XTIFFP_PRINT; } TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); tif->tif_flags |= TIFF_DIRTYDIRECT; } va_end(ap); return (status); badvalue: TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v, _TIFFFieldWithTag(tif, tag)->field_name); va_end(ap); return (0); badvalue32: TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32, _TIFFFieldWithTag(tif, tag)->field_name); va_end(ap); return (0); } static int _XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) { xtiff *xt = XTIFFDIR(tif); XTIFFDirectory* xd = &xt->xtif_dir; switch (tag) { /* * XXX put your extended tags here; replace the implemented * example tags with your own. */ case TIFFTAG_EXAMPLE_MULTI: *va_arg(ap, uint16*) = xd->xd_num_multi; *va_arg(ap, double**) = xd->xd_example_multi; break; case TIFFTAG_EXAMPLE_ASCII: *va_arg(ap, char**) = xd->xd_example_ascii; break; case TIFFTAG_EXAMPLE_SINGLE: *va_arg(ap, uint32*) = xd->xd_example_single; break; default: /* return inherited method */ return (PARENT(xt,vgetfield))(tif,tag,ap); break; } return (1); } #define CleanupField(member) { \ if (xd->member) { \ _TIFFfree(xd->member); \ xd->member = 0; \ } \ } /* * Release storage associated with a directory. */ static void _XTIFFFreeDirectory(xtiff* xt) { XTIFFDirectory* xd = &xt->xtif_dir; /* * XXX - Purge all Your allocated memory except * for the xtiff directory itself. This includes * all fields that require a _TIFFsetXXX call in * _XTIFFVSetField(). */ CleanupField(xd_example_multi); CleanupField(xd_example_ascii); } #undef CleanupField static void _XTIFFLocalDefaultDirectory(TIFF *tif) { xtiff *xt = XTIFFDIR(tif); XTIFFDirectory* xd = &xt->xtif_dir; /* Install the extended Tag field info */ _TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); /* * free up any dynamically allocated arrays * before the new directory is read in. */ _XTIFFFreeDirectory(xt); _TIFFmemset(xt,0,sizeof(xtiff)); /* Override the tag access methods */ PARENT(xt,vsetfield) = TIFFMEMBER(tif,vsetfield); TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField; PARENT(xt,vgetfield) = TIFFMEMBER(tif,vgetfield); TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField; /* * XXX Set up any default values here. */ xd->xd_example_single = 234; } /********************************************************************** * Nothing below this line should need to be changed. **********************************************************************/ static TIFFExtendProc _ParentExtender; /* * This is the callback procedure, and is * called by the DefaultDirectory method * every time a new TIFF directory is opened. */ static void _XTIFFDefaultDirectory(TIFF *tif) { xtiff *xt; /* Allocate Directory Structure if first time, and install it */ if (!(tif->tif_flags & XTIFF_INITIALIZED)) { xt = _TIFFmalloc(sizeof(xtiff)); if (!xt) { /* handle memory allocation failure here ! */ return; } _TIFFmemset(xt,0,sizeof(xtiff)); /* * Install into TIFF structure. */ TIFFMEMBER(tif,clientdir) = (tidata_t)xt; tif->tif_flags |= XTIFF_INITIALIZED; /* dont do this again! */ } /* set up our own defaults */ _XTIFFLocalDefaultDirectory(tif); /* Since an XTIFF client module may have overridden * the default directory method, we call it now to * allow it to set up the rest of its own methods. */ if (_ParentExtender) (*_ParentExtender)(tif); } /* * XTIFF Initializer -- sets up the callback * procedure for the TIFF module. */ static void _XTIFFInitialize(void) { static first_time=1; if (! first_time) return; /* Been there. Done that. */ first_time = 0; /* Grab the inherited method and install */ _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); } /* * Public File I/O Routines. */ TIFF* XTIFFOpen(const char* name, const char* mode) { /* Set up the callback */ _XTIFFInitialize(); /* Open the file; the callback will set everything up */ return TIFFOpen(name, mode); } TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode) { /* Set up the callback */ _XTIFFInitialize(); /* Open the file; the callback will set everything up */ return TIFFFdOpen(fd, name, mode); } void XTIFFClose(TIFF *tif) { xtiff *xt = XTIFFDIR(tif); /* call inherited function first */ TIFFClose(tif); /* Free up extended allocated memory */ _XTIFFFreeDirectory(xt); _TIFFfree(xt); } ; /* Open the file; the callback will set everything up */ return TIFFOpen(name, mode); } TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode) { /* Set up the callback */ _XTIFFInitialize(); /* Open the file; the callback will set everything up */ return TIFFFdOpen(fd, name, mode); } void XTIFFClose(TIFF *tif) { xtiff *xt = XTIFFDIR(tif); /* call inherited function first */ TIFFClose(tif); /* Free up extended tiff-v3.4beta018/contrib/tags/xtiffio.h000644 004341 000024 00000002616 05774560632 017615 0ustar00samuser000000 000000 /* * xtiffio.h -- Public interface to Extended TIFF tags * * This is a template for defining a client module * which supports tag extensions to the standard libtiff * set. Only portions of the code marked "XXX" need to * be changed to support your tag set. * * written by: Niles D. Ritter */ #ifndef __xtiffio_h #define __xtiffio_h #include "tiffio.h" /* * XXX Define your private Tag names and values here */ /* These tags are not valid, but are provided for example */ #define TIFFTAG_EXAMPLE_MULTI 61234 #define TIFFTAG_EXAMPLE_SINGLE 61235 #define TIFFTAG_EXAMPLE_ASCII 61236 /* * XXX Define Printing method flags. These * flags may be passed in to TIFFPrintDirectory() to * indicate that those particular field values should * be printed out in full, rather than just an indicator * of whether they are present or not. */ #define TIFFPRINT_MYMULTIDOUBLES 0x80000000 /********************************************************************** * Nothing below this line should need to be changed by the user. **********************************************************************/ #if defined(__cplusplus) extern "C" { #endif extern TIFF* XTIFFOpen(const char* name, const char* mode); extern TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode); extern void XTIFFClose(TIFF *tif); #if defined(__cplusplus) } #endif #endif /* __xtiffio_h */ LTIDOUBLES 0x80000000 /********************************************************************** * Nothing belowtiff-v3.4beta018/contrib/tags/xtiffiop.h000644 004341 000024 00000003661 05774261565 020001 0ustar00samuser000000 000000 /* * Private Extended TIFF library interface. * * uses private LIBTIFF interface. * * The portions of this module marked "XXX" should be * modified to support your tags instead. * * written by: Niles D. Ritter * */ #ifndef __xtiffiop_h #define __xtiffiop_h #include "tiffiop.h" #include "xtiffio.h" /********************************************************************** * User Configuration **********************************************************************/ /* XXX - Define number of your extended tags here */ #define NUM_XFIELD 3 #define XFIELD_BASE (FIELD_LAST-NUM_XFIELD) /* XXX - Define your Tag Fields here */ #define FIELD_EXAMPLE_MULTI (XFIELD_BASE+0) #define FIELD_EXAMPLE_SINGLE (XFIELD_BASE+1) #define FIELD_EXAMPLE_ASCII (XFIELD_BASE+2) /* XXX - Define Private directory tag structure here */ struct XTIFFDirectory { uint16 xd_num_multi; /* dir-count for the multi tag */ double* xd_example_multi; uint32 xd_example_single; char* xd_example_ascii; }; typedef struct XTIFFDirectory XTIFFDirectory; /********************************************************************** * Nothing below this line should need to be changed by the user. **********************************************************************/ struct xtiff { TIFF *xtif_tif; /* parent TIFF pointer */ uint32 xtif_flags; #define XTIFFP_PRINT 0x00000001 XTIFFDirectory xtif_dir; /* internal rep of current directory */ TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */ TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */ TIFFPrintMethod xtif_printdir; /* inherited dir print method */ }; typedef struct xtiff xtiff; #define PARENT(xt,pmember) ((xt)->xtif_ ## pmember) #define TIFFMEMBER(tf,pmember) ((tf)->tif_ ## pmember) #define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif,clientdir)) /* Extended TIFF flags */ #define XTIFF_INITIALIZED 0x80000000 #endif /* __xtiffiop_h */ of current directory */ TIFFVSetMethod xtif_vsetfield; /* inherited tag set rotiff-v3.4beta018/contrib/mac-mpw/000755 004341 000024 00000000000 05777306402 016366 5ustar00samuser000000 000000 tiff-v3.4beta018/contrib/mac-mpw/BUILD.mpw000644 004341 000024 00000003231 05777116121 017746 0ustar00samuser000000 000000 # BUILD.mpw: # # Full build for Apple Macintosh Programmer's Workshop (MPW). # # This is an executable MPW script which creates various # utilities, sets up the MPW makefiles and runs the builds. # This script should be run at the top level TIFF directory with: # # directory ::: # :contrib:mac-mpw:BUILD.mpw # # NOTE: The full build requires that MPW have at least 6 MB # allocated to it to compile the CCITT Fax codec tables. To # deactivate CCITT compression edit the file :contrib:mac:libtiff.make # first and follow the directions for disabling Fax decoding. # # All TIFF tools are built as MPW tools, executable from the # MPW shell or other compatible tool server. # # Written by: Niles Ritter (ndr@tazboy.jpl.nasa.gov). # echo "############# Full Scratch Build for MPW #############" # Create the ascii->mpw translation tool; this is used to # convert standard ASCII files into ones using the special # MPW characters, which don't live comfortably in unix tar files. # echo "######## Creating ASCII->MPW translator ########" set contrib ':contrib:mac-mpw:' directory {contrib} createmake -tool mactrans mactrans.c > dev:null make -f mactrans.make | streamedit -e "/CSANELib/||/Math/||/ToolLibs/ del" > mactrans.bld execute mactrans.bld > dev:null delete -y mactrans.make mactrans.bld mactrans.c.o || set status 0 directory ::: #An mpw trick for going up two levels # Create the top-level Makefile and run it echo "######## Creating Makefile ########" catenate {contrib}top.make | {contrib}mactrans > Makefile echo "######## Running Makefile ########" make > build.mpw execute build.mpw echo "############# MPW Build Complete #############" exit 0 make | streamedit -e "/CSANELib/||/Math/||/ToolLibs/ del" > mactrans.bld execute mactrans.bld > dev:null delete -y mactrans.make mactrans.bld mactrans.c.o || set status 0 directory ::: #An mpw trick for going up two levels # Create the top-level Makefile and run it echo "######## Creating Makefile ########" catenate {contrib}top.make | {contrib}mactranstiff-v3.4beta018/contrib/mac-mpw/README000644 004341 000024 00000001300 05777116114 017237 0ustar00samuser000000 000000 ###################### About contrib:mac-mpw: ###################### This directory contains all of the utilities and makefile source to build the LIBTIFF library and tools from the MPW Shell. The file BUILD.mpw in this directory is an executable script which uses all of these files to create the MPW makefiles and run them. The .make files are not MPW makefiles as such, but are when run through the "mactrans" program, which turns the ascii "%nn" metacharacters into the standard weird MPW make characters. This translation trick is necessary to protect the files when they are put into unix tarfiles, which tend to mangle the special characters. --Niles Ritter (ndr@tazboy.jpl.nasa.gov) . The file BUILD.mpw in this directory is an executable script which uses all of these files to create the MPW makefiles and run them. The .make files are not MPW makefiles as such, but are when run through the "mactrans" program, which turns the ascii "%nn" metacharacters into the standard weird MPW make chartiff-v3.4beta018/contrib/mac-mpw/libtiff.make000644 004341 000024 00000012372 05777116114 020650 0ustar00samuser000000 000000 # # Tag Image File Format Library # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler # Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. # # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. # # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # # # Makefile for Mac using MPW 3.3.1 and MPW C 3.2.4 # # Note: This file must be run through "mactrans" before it can # be recognized by MPW as a valid makefile. The problem is that MPW # uses special non-ASCII characters, which tend to get mangled when stored # in unix tar files, etc. "mactrans" is built as part of the TIFF MPW build. # # DEPTH = :: # FAX Options: If you do not wish to include the FAX options, uncomment # the first four definitions and comment out the next four # definitions. Note that to build programs with the FAX libraries you # have to include "-model far" in your compile and link statements. # # Also, to build the fax code (including the tif_fax3sm.c file, which is # created by the MPW tool "mkg3states", also built below), you will # need to size the MPW program up to about 6 megabytes or so. #FAX_OPTIONS = #FAX_OBJECTS = #FAX_SOURCES = tif_fax3.c #FAX_CONFIG = FAX_OPTIONS = -model far FAX_OBJECTS = tif_fax3.c.o tif_fax3sm.c.o FAX_SOURCES = tif_fax3.c tif_fax3sm.c FAX_CONFIG = -d CCITT_SUPPORT NULL= RM = delete -y -i COPTS = LIBPORT=::port:libport.o # .c.o %c4 .c {C} -model far {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o CONF_LIBRARY= %b6 -d HAVE_IEEEFP=1 %b6 -d BSDTYPES CONF_COMPRESSION= %b6 {FAX_CONFIG} %b6 -d COMPRESSION_SUPPORT %b6 -d PACKBITS_SUPPORT %b6 -d LZW_SUPPORT %b6 -d THUNDER_SUPPORT %b6 -d NEXT_SUPPORT CFLAGS= {FAX_OPTIONS} {IPATH} {CONF_LIBRARY} {CONF_COMPRESSION} INCS= tiff.h tiffio.h SRCS= %b6 {FAX_SOURCES} %b6 tif_apple.c %b6 tif_aux.c %b6 tif_close.c %b6 tif_codec.c %b6 tif_compress.c %b6 tif_dir.c %b6 tif_dirinfo.c %b6 tif_dirread.c %b6 tif_dirwrite.c %b6 tif_dumpmode.c %b6 tif_error.c %b6 tif_getimage.c %b6 tif_jpeg.c %b6 tif_flush.c %b6 tif_lzw.c %b6 tif_next.c %b6 tif_open.c %b6 tif_packbits.c %b6 tif_predict.c %b6 tif_print.c %b6 tif_read.c %b6 tif_swab.c %b6 tif_strip.c %b6 tif_thunder.c %b6 tif_tile.c %b6 tif_version.c %b6 tif_warning.c %b6 tif_write.c %b6 tif_zip.c %b6 {NULL} OBJS= %b6 {FAX_OBJECTS} %b6 tif_apple.c.o %b6 tif_aux.c.o %b6 tif_close.c.o %b6 tif_codec.c.o %b6 tif_compress.c.o %b6 tif_dir.c.o %b6 tif_dirinfo.c.o %b6 tif_dirread.c.o %b6 tif_dirwrite.c.o %b6 tif_dumpmode.c.o %b6 tif_error.c.o %b6 tif_getimage.c.o %b6 tif_jpeg.c.o %b6 tif_flush.c.o %b6 tif_lzw.c.o %b6 tif_next.c.o %b6 tif_open.c.o %b6 tif_packbits.c.o %b6 tif_predict.c.o %b6 tif_print.c.o %b6 tif_read.c.o %b6 tif_swab.c.o %b6 tif_strip.c.o %b6 tif_thunder.c.o %b6 tif_tile.c.o %b6 tif_version.c.o %b6 tif_warning.c.o %b6 tif_write.c.o %b6 tif_zip.c.o %b6 {NULL} ALL=libtiff.o all %c4 {ALL} libtiff.o %c4 {OBJS} Lib {OBJS} -o libtiff.o {OBJS} %c4 tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h # # The finite state machine tables used by the G3/G4 decoders # are generated by the mkg3states program. On systems without # make these rules have to be manually carried out. # tif_fax3sm.c %c4 mkg3states tif_fax3.h {RM} tif_fax3sm.c || set status 0 :mkg3states -c const tif_fax3sm.c mkg3states.c.o %c4 mkg3states.c C -model far mkg3states.c -o mkg3states.c.o mkg3states %c4%c4 mkg3states.c.o Link -model far -d -c 'MPS ' -t MPST %b6 mkg3states.c.o %b6 {LIBPORT} %b6 "{CLibraries}"StdClib.o %b6 "{Libraries}"Stubs.o %b6 "{Libraries}"Runtime.o %b6 "{Libraries}"Interface.o %b6 -o mkg3states ALPHA = "{DEPTH}dist:tiff.alpha" VERSION = "{DEPTH}VERSION" version.h %c4 {VERSION} {ALPHA} Set VERSION1 `catenate {VERSION}` Set VERSION2 "{VERSION1}`streamedit -e "1 rep /%a5%c5 %c5 (%c5)%a81/ %a81" {ALPHA}`" delete -y -i version.h || set status 0 echo '#define VERSION "LIBTIFF, Version' {VERSION2} '\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."' >version.h tif_version.c.o %c4 version.h clean %c4 {RM} {ALL} || set status 0 {RM} {OBJS} || set status 0 {RM} mkg3states || set status 0 {RM} mkg3states.c.o || set status 0 {RM} tif_fax3sm.c%c5 || set status 0 {RM} version.h || set status 0 ERSION1}`streamedit -e "1 rep /%a5%c5 %c5 (%c5)%a81/ %a81" {ALPHA}`" delete -y -i version.h || set status 0 echo '#define VERSION "LIBTIFF, Version' {VERSION2} '\nCopyright (c) 1988-1995 Sam Leffler\nCopyright (c) 1991-1995 Silicon Graphics, Inc."' >vetiff-v3.4beta018/contrib/mac-mpw/mactrans.c000644 004341 000024 00000001675 05776005764 020361 0ustar00samuser000000 000000 /* * mactrans.c -- Hack filter used to generate MPW files * with special characters from pure ASCII, denoted "%nn" * where nn is hex. (except for "%%", which is literal '%'). * * calling sequence: * * catenate file | mactrans [-toascii | -fromascii] > output * * Written by: Niles Ritter. */ #include #include #include void to_ascii(void); void from_ascii(void); main(int argc, char *argv[]) { if (argc<2 || argv[1][1]=='f') from_ascii(); else to_ascii(); exit (0); } void from_ascii(void) { char c; int d; while ((c=getchar())!=EOF) { if (c!='%' || (c=getchar())=='%') putchar(c); else { ungetc(c,stdin); scanf("%2x",&d); *((unsigned char *)&c) = d; putchar(c); } } } void to_ascii(void) { char c; int d; while ((c=getchar())!=EOF) { if (isascii(c)) putchar (c); else { d = *((unsigned char *)&c); printf("%%%2x",d); } } } rgv[]) { if (argc<2 || argv[1][1]=='f') from_ascii(); else to_asctiff-v3.4beta018/contrib/mac-mpw/port.make000644 004341 000024 00000003201 05776005765 020214 0ustar00samuser000000 000000 # # Tag Image File Format Library # # Copyright (c) 1995 Sam Leffler # Copyright (c) 1995 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. # DEPTH= :: SRCDIR= : NULL = CC = C AR = Lib AROPTS = RM= delete -y IPATH = -I {DEPTH} -I {SRCDIR} COPTS = OPTIMIZER= CFLAGS = {COPTS} {OPTIMIZER} {IPATH} CFILES = OBJECTS = getopt.c.o TARGETS = libport.o .c.o %c4 .c {CC} -model far {COptions} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o all %c4 {TARGETS} libport.o %c4 {OBJECTS} {AR} {OBJECTS} -o libport.o clean %c4 {RM} {TARGETS} {OBJECTS} || set status 0 CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # DEPTH= :: SRCDIR= : NULL = CC = C AR = Lib AROPTS = RM= delete -y IPATH = -I {DEPTH} -I {SRCDIR} COPTS = OPTIMIZER= CFLAGS = {COPTS} {OPTIMIZER} {IPATH} CFILES = OBJECTS = getopt.c.o TARGETS = libport.o .c.o %c4 .c {CC} -model far {COptions} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o tiff-v3.4beta018/contrib/mac-mpw/tools.make000644 004341 000024 00000007035 05776005765 020401 0ustar00samuser000000 000000 # # Tag Image File Format Library # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler # Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Stanford 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. # # # Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4 # COPTS = -model far .c.o %c4 .c {C} {COPTS} {CFLAGS} -s {Default} {DepDir}{Default}.c -o {TargDir}{Default}.c.o RM = delete -y -i CONF_LIBRARY= %b6 -d USE_CONST=0 %b6 -d BSDTYPES NULL= IPATH= -I ::libtiff CFLAGS= -w -m {IPATH} {CONF_LIBRARY} LIBPORT= ::port:libport.o LOptions= -model far -w -srt -d -c 'MPS ' -t MPST LIBTIFF= ::libtiff:libtiff.o LIBS= {LIBTIFF} %b6 {LIBPORT} %b6 "{CLibraries}"CSANELib.o %b6 "{CLibraries}"Math.o %b6 "{CLibraries}"StdClib.o %b6 "{Libraries}"Stubs.o %b6 "{Libraries}"Runtime.o %b6 "{Libraries}"Interface.o %b6 "{Libraries}"ToolLibs.o %b6 {NULL} SRCS= %b6 pal2rgb.c %b6 ras2tiff.c %b6 thumbnail.c %b6 tiff2bw.c %b6 tiff2ps.c %b6 tiffcmp.c %b6 tiffcp.c %b6 tiffdither.c %b6 tiffdump.c %b6 tiffinfo.c %b6 tiffmedian.c %b6 {NULL} MACHALL=ras2tiff ALL= %b6 tiffinfo %b6 tiffcmp %b6 tiffcp %b6 tiffdump %b6 tiffmedian %b6 tiff2bw %b6 tiffdither %b6 tiff2ps %b6 pal2rgb %b6 gif2tiff %b6 {MACHALL} all %c4 {ALL} tiffinfo %c4 tiffinfo.c.o {LIBTIFF} Link {LOptions} tiffinfo.c.o {LIBS} -o tiffinfo tiffcmp %c4 tiffcmp.c.o {LIBTIFF} Link {LOptions} tiffcmp.c.o {LIBS} -o tiffcmp tiffcp %c4 tiffcp.c.o {LIBTIFF} Link {LOptions} tiffcp.c.o {LIBS} -o tiffcp tiffdump %c4 tiffdump.c.o {LIBTIFF} Link {LOptions} tiffdump.c.o {LIBS} -o tiffdump tiffmedian %c4 tiffmedian.c.o {LIBTIFF} Link {LOptions} tiffmedian.c.o {LIBS} -o tiffmedian tiff2ps %c4 tiff2ps.c.o {LIBTIFF} Link {LOptions} tiff2ps.c.o {LIBS} -o tiff2ps # junky stuff... # convert RGB image to B&W tiff2bw %c4 tiff2bw.c.o {LIBTIFF} Link {LOptions} tiff2bw.c.o {LIBS} -o tiff2bw # convert B&W image to bilevel w/ FS dithering tiffdither %c4 tiffdither.c.o {LIBTIFF} Link {LOptions} tiffdither.c.o {LIBS} -o tiffdither # GIF converter gif2tiff %c4 gif2tiff.c.o {LIBTIFF} Link {LOptions} gif2tiff.c.o {LIBS} -o gif2tiff # convert Palette image to RGB pal2rgb %c4 pal2rgb.c.o {LIBTIFF} Link {LOptions} pal2rgb.c.o {LIBS} -o pal2rgb # Sun rasterfile converter ras2tiff %c4 ras2tiff.c.o {LIBTIFF} Link {LOptions} ras2tiff.c.o {LIBS} -o ras2tiff # generate thumbnail images from fax thumbnail %c4 thumbnail.c.o {LIBTIFF} Link {LOptions} thumbnail.c.o {LIBS} -o thumbnail clean %c4 {RM} {ALL} %c5.c.o ycbcr ffdither # GIF converter gif2tiff %c4 gif2tiff.c.o {LIBTIFF} Link {LOptions} gif2tiff.c.o {LIBS} -o gif2tiff # convert Palette image to RGB pal2rgb %c4 pal2rgb.c.o {LIBTIFF} Link {LOptions} pal2rgb.c.o {LIBS} -o pal2rgb # Sun rasterfile converter ras2tiff %c4 ras2tiff.c.o {LIBTIFF} Link {LOptions} ras2tiff.c.o {LIBS} -o ras2tiff # generate thumbnail images from fax thumbnail %c4 thumbnail.c.o {LIBTIFF} Link {LOptions} thumbnail.c.o {LIBS} -o thumbnail clean %tiff-v3.4beta018/contrib/mac-mpw/top.make000644 004341 000024 00000006422 05777116115 020033 0ustar00samuser000000 000000 # # Tag Image File Format Library # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Sam Leffler # Copyright (c) 1991, 1992, 1993, 1994 Silicon Graphics, Inc. # # Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Stanford 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. # # # Makefile for Mac using MPW 3.2.3 and MPW C 3.2.4 # # # Written by: Niles D. Ritter # RM= delete -y -i PORT=:port: LIBTIFF=:libtiff: TOOLS=:tools: CONTRIB=:contrib:mac-mpw: MACTRANS="{CONTRIB}mactrans" NULL= MAKEFILES = %b6 {PORT}Makefile %b6 {LIBTIFF}Makefile %b6 {TOOLS}Makefile %b6 {NULL} all %c4 PORT LIBTIFF TOOLS MAKEFILES %c4 {MAKEFILES} TOOLS %c4 LIBTIFF LIBTIFF %c4 PORT # Create the port routines PORT %c4 {PORT}Makefile directory {PORT} (make || set status 0) > build.mpw set echo 1 execute build.mpw set echo 0 {RM} build.mpw || set status 0 directory :: # Create the port routines LIBTIFF %c4 {LIBTIFF}Makefile directory {LIBTIFF} (make || set status 0) > build.mpw set echo 1 execute build.mpw set echo 0 {RM} build.mpw || set status 0 directory :: # Create the tools TOOLS %c4 {TOOLS}Makefile directory {TOOLS} (make || set status 0) > build.mpw set echo 1 execute build.mpw set echo 0 {RM} build.mpw || set status 0 directory :: # Makefile dependencies {PORT}Makefile %c4 {CONTRIB}port.make catenate {CONTRIB}port.make | {MACTRANS} > {PORT}Makefile {LIBTIFF}Makefile %c4 {CONTRIB}libtiff.make catenate {CONTRIB}libtiff.make | {MACTRANS} > {LIBTIFF}Makefile {TOOLS}Makefile %c4 {CONTRIB}tools.make catenate {CONTRIB}tools.make | {MACTRANS} > {TOOLS}Makefile clean %c4 clean.port clean.contrib clean.libtiff clean.tools clean.make clean.port %c4 directory {PORT} (make clean || set status 0) > purge purge {RM} purge || set status 0 {RM} Makefile || set status 0 {RM} build.mpw || set status 0 cd :: clean.contrib %c4 {RM} {MACTRANS} || set status 0 clean.libtiff %c4 directory {LIBTIFF} (make clean || set status 0) > purge purge {RM} purge || set status 0 {RM} Makefile || set status 0 {RM} build.mpw || set status 0 cd :: clean.tools %c4 directory {TOOLS} (make clean || set status 0) > purge purge {RM} purge || set status 0 {RM} Makefile || set status 0 {RM} build.mpw || set status 0 cd :: clean.make %c4 {RM} {MAKEFILES} || set status 0 {RM} build.mpw || set status 0 us 0 cd :: clean.contrib %c4 {RM} {MACTRANS} || set status 0 clean.libtiff %c4 directory {LIBTIFF} (make clean || set status 0) > purge purge {RM} purge || set status 0 {RM} Makefile || set status 0 {RM} build.mpw || set statu