v3.5.2 release

This commit is contained in:
Mike Welles
1999-09-28 17:22:20 +01:00
committed by Roger Leigh
parent 00c28dda69
commit 4e500fc403
259 changed files with 3830 additions and 2193 deletions

View File

@@ -1,22 +0,0 @@
/COPYRIGHT/1.1.1.1/Tue Jul 27 21:50:26 1999//
/Makefile/1.1.1.1/Tue Jul 27 21:50:26 1999//
/Makefile.in/1.1.1.1/Tue Jul 27 21:50:26 1999//
/README/1.1.1.1/Tue Jul 27 21:50:26 1999//
/README-IPTC/1.1.1.1/Tue Jul 27 21:50:26 1999//
/TODO/1.1.1.1/Tue Jul 27 21:50:26 1999//
/VERSION/1.1.1.1/Tue Jul 27 21:50:26 1999//
/config.guess/1.1.1.1/Tue Jul 27 21:50:26 1999//
/config.site/1.1.1.1/Tue Jul 27 21:50:26 1999//
/config.sub/1.1.1.1/Tue Jul 27 21:50:26 1999//
/configure/1.1.1.1/Tue Jul 27 21:50:26 1999//
/tiff.h/1.1.1.1/Tue Jul 27 21:50:26 1999//
D/contrib////
D/dist////
D/html////
D/libtiff////
D/man////
D/port////
D/tools////
/README-v3.5/-1.1.1.1/Tue Jul 27 21:50:26 1999//
/README-v3.5.1/1.1/Mon Aug 9 18:45:44 1999//
/1/-1.1.1.1/Tue Jul 27 21:50:26 1999//

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,5 +1,5 @@
#! smake
# $Header: /usr/local/cvs/internal/libtiff/Makefile.in,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
# $Header: /cvsroot/osrs/libtiff/Makefile.in,v 1.5 1999/09/28 17:22:20 mwelles Exp $
#
# @WARNING@
#
@@ -120,11 +120,13 @@ TIFFFILES=\
VERSION \
COPYRIGHT \
TODO \
test_pics.sh \
dist/tiff.spec \
dist/newalpha \
dist/newversion \
libtiff/Makefile.in \
libtiff/Makefile.lcc \
libtiff/makefile.vc \
libtiff/t4.h \
libtiff/tiff.h \
libtiff/tiffcomp.h \
@@ -184,6 +186,7 @@ TIFFFILES=\
port/strcasecmp.c \
port/strtoul.c \
tools/Makefile.in \
tools/Makefile.vc \
tools/Makefile.lcc \
tools/fax2tiff.c \
tools/fax2ps.c \
@@ -198,6 +201,7 @@ TIFFFILES=\
tools/sgisv.c \
tools/thumbnail.c \
tools/tiff2bw.c \
tools/tiff2rgba.c \
tools/tiff2ps.c \
tools/tiffcmp.c \
tools/tiffcp.c \
@@ -238,6 +242,8 @@ TIFFFILES=\
man/TIFFReadEncodedStrip.3t \
man/TIFFReadEncodedTile.3t \
man/TIFFReadRGBAImage.3t \
man/TIFFReadRGBAStrip.3t \
man/TIFFReadRGBATile.3t \
man/TIFFReadRawStrip.3t \
man/TIFFReadRawTile.3t \
man/TIFFReadScanline.3t \
@@ -380,6 +386,13 @@ CONTRIBFILES=\
contrib/pds/tif_imageiter.h \
contrib/pds/tif_pdsdirread.c \
contrib/pds/tif_pdsdirwrite.c \
contrib/addtiffo/README \
contrib/addtiffo/Makefile \
contrib/addtiffo/Makefile.vc \
contrib/addtiffo/addtiffo.c \
contrib/addtiffo/tif_overview.cpp \
contrib/addtiffo/rawblockedimage.cpp \
contrib/addtiffo/rawblockedimage.h \
${NULL}
DISTFILES=\
${TIFFFILES} \
@@ -401,64 +414,23 @@ CONFIG=\
rcsclean:
rcsclean ${TIFFFILES} && co ${TIFFFILES}
alpha:
(cd ${SRCDIR}/dist; 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="Alpha@DIST_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 'BEGIN { \
for (i=1; i<=@DIST_ALPHA@; i++) printf " -nAlpha%03d",i;\
exit \
}'`; \
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="@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;
release:
(cd ${SRCDIR}/dist; sh newversion)
-${MAKE} clean
${MAKE} release.stamp
${SRCDIR}/configure ${CONFIG}
${MAKE} product
# ${MAKE} product
${MAKE} release.tar
# stamp relevant files according to current alpha
release.stamp:
NOW=`date`; \
for i in ${TIFFFILES}; do \
REV=`rlog -h -d"$$NOW" ${SRCDIR}/$$i|fgrep 'head:'|awk '{print $$2}'`;\
rcs "-NRelease@DIST_MAJOR@_@DIST_MINOR@_@DIST_TYPE@:$$REV" "-sRel:$$REV" ${SRCDIR}/$$i && co -sRel ${SRCDIR}/$$i; \
cvs tag -R "Release"
date "+%m/%d/%Y" > RELEASE-DATE
#diffs since last release
releasediff:
-@for i in ${TIFFFILES}; do \
cvs diff -D`cat RELEASE-DATE` ${SRCDIR}/$$i; \
done
# create release distribution archive
@@ -474,6 +446,13 @@ release.tar:
cat $$VERSION-tar | ${COMPRESS} >tiff-$$VERSION-tar.${ZIPSUF}; \
rm -f tiff-$$VERSION $$VERSION $$VERSION-tar;
#
# Simple rule to run test suite assuming that pics directory is
# just below this one, and that .rpt files are available.
#
test:
test_pics.sh pics/*.tif
#
# Create a package of the test images.
#

3
README
View File

@@ -1,4 +1,5 @@
$Header: /usr/local/cvs/internal/libtiff/README,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
$Header: /cvsroot/osrs/libtiff/README,v 1.2 1999/08/16 17:09:27 warmerda Exp $
TIFF Software Distribution
--------------------------

View File

@@ -1,41 +0,0 @@
To: sam@engr.sgi.com
cc: adam@onshore.com
cc: billr@corbis.com
cc: magick@wizards.dupont.com
Subject: libtiff fork
X-Mailer: VM 6.63 under Emacs 20.3.2
--text follows this line--
I've finished merging a forked libtiff that was being shipped with
ImageMagick (that added IPTC newsphoto support) with the last libtiff
release (tiff-v3.4beta037). I'm going to make this available at
ftp://ftp.onshore.com/pub/libtiff (as tiff-v3.4beta037-IPTC).
I'm very reluctant to fork code, and I woud refrain, but for the following:
1. Repeated mail to you about the patches has gone unanswered.
2. I keep getting mail from people strugging to get IPTC newphoto support
to work properly with ImageMagick.
3. The NT source distibution was already shipping with a forked version.
In order for the situation to be less confusing, I'm going to make an
archive of the forked version available.
I very much would like for there not to be a fork. Are you still
maintaining libtiff? If not, is there a current maintainer?
I'm willing to adopt it if there isn't. I'd hate to see such an
important library fragment. It's extremely likely that onShore
(http://onshore.com/), will donate web space, bandwidth, and listserv
services if so.
------------------------------------------------------
M. L. Welles mike@onShore.com
http://fifth.net/
-------------------------------------------------------

View File

@@ -1,8 +0,0 @@
Release 3.5.1 is merely a renaming of v3.4-beta037-IPTC to bump the
version number so that the maintainer switch is clear and folks will
know which problems I caused. See README-IPTC forchages between v3.5
and the last version that Sam released.
--Mike Welles (mike@onshore.com)

2
TODO
View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/TODO,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
# $Header: /cvsroot/osrs/libtiff/TODO,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
o tiffcmp read data by strip/tile instead of scanline
o YCbCr sampling support

View File

@@ -1 +1 @@
3.5.1
3.5.2

3
config.guess vendored
View File

@@ -264,6 +264,9 @@ EOF
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
i[345]86:CYGWIN*:*:*)
echo ${UNAME_MACHINE}-unknown-Cygwin${UNAME_RELEASE}
exit 0 ;;
i[34]86:BSD/386:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;

View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/config.site,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
# $Header: /cvsroot/osrs/libtiff/config.site,v 1.2 1999/09/26 22:03:46 mwelles Exp $
#
# TIFF Software
#
@@ -94,8 +94,8 @@
# JPEG support requires release 5 or later of the IJG code,
# which you can find on the Internet at ftp.uu.net:/graphics/jpeg/.
#
#DIRS_LIBINC="$DIRS_LIBINC ../src/jpeg-5a" # directory for jpeg include files
#DIR_JPEGLIB=../src/jpeg-5a # directory for libjpeg
#DIRS_LIBINC="$DIRS_LIBINC ../src/jpeg-6b" # directory for jpeg include files
#DIR_JPEGLIB=../src/jpeg-6b # directory for libjpeg
#
# Deflate-specific parameters; used when Deflate support is enabled (see above).

14
configure vendored
View File

@@ -1,5 +1,5 @@
#!/bin/sh
# $Header: /usr/local/cvs/internal/libtiff/configure,v 1.1.1.1 1999/07/27 21:50:26 mike Exp $
# $Header: /cvsroot/osrs/libtiff/configure,v 1.2 1999/09/08 12:32:18 warmerda Exp $
#
# Tag Image File Format (TIFF) Software
#
@@ -147,7 +147,7 @@ do
-target|--target) ac_prev=TARGET;;
-target=*|--target=*) TARGET="$ac_optarg" ;;
-version|--version)
echo "This is TIFF configure $Revision: 1.1.1.1 $"
echo "This is TIFF configure $Revision: 1.2 $"
exit 0
;;
-help|--help) usage; exit 0;;
@@ -1100,7 +1100,13 @@ if [ "$DSO" = auto ]; then
if (findApp rld /lib:/usr/lib:$PATH) >/dev/null 2>&1; then
DSOSUF=so
DSOLD="${CCOMPILER} ${ENVOPTS}"
DSOOPTS='-shared -rdata_shared -check_registry ${SRCDIR}/port/irix/so_locations -quickstart_info'
if [ $ISGCC = yes ]; then
LIBCOPTS="-fpic"
DSOOPTS='-shared -rdata_shared'
else
LIBCOPTS="-KPIC"
DSOOPTS='-shared -rdata_shared -check_registry ${SRCDIR}/port/irix/so_locations -quickstart_info'
fi
DSO=IRIX
TIFFLIBREF='-L${DEPTH}/libtiff -rpath '${DIR_LIB}' -ltiff'
fi
@@ -1158,7 +1164,7 @@ if [ "$DSO" = auto ]; then
DSO=LINUX
fi
;;
*-osf3*)
*-osf3*|*-osf4*)
DSOSUF=so
DSOOPTS='-shared'
DSO=OSF

View File

@@ -1,13 +0,0 @@
D/acorn////
D/dbs////
D/dosdjgpp////
D/iptcutil////
D/mac-cw////
D/mac-mpw////
D/mfs////
D/pds////
D/ras////
D/vms////
D/win32////
D/win95////
D/winnt////

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,7 +0,0 @@
/Makefile/1.1.1.1/Tue Jul 27 21:50:26 1999//
/ReadMe/1.1.1.1/Tue Jul 27 21:50:26 1999//
/SetVars/1.1.1.1/Tue Jul 27 21:50:26 1999//
/cleanlib/1.1.1.1/Tue Jul 27 21:50:26 1999//
/convert/1.1.1.1/Tue Jul 27 21:50:26 1999//
/install/1.1.1.1/Tue Jul 27 21:50:26 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/acorn

View File

@@ -1 +0,0 @@
/usr/local/cvs

27
contrib/addtiffo/Makefile Normal file
View File

@@ -0,0 +1,27 @@
#
# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
#
LIBTIFF_DIR = ../../libtiff
#
CC = gcc
CXX = gcc
CFLAGS = -O -I$(LIBTIFF_DIR)
LIBS = $(LIBTIFF_DIR)/libtiff.a -lm
addtiffo: addtiffo.o tif_overview.o rawblockedimage.o
$(CXX) $(CFLAGS) addtiffo.o tif_overview.o rawblockedimage.o \
$(LIBS) -o addtiffo
addtiffo.o: addtiffo.c
$(CC) -c $(CFLAGS) addtiffo.c
tif_overview.o: tif_overview.cpp
$(CXX) -c $(CFLAGS) tif_overview.cpp
rawblockedimage.o: rawblockedimage.cpp
$(CXX) -c $(CFLAGS) rawblockedimage.cpp
clean:
rm *.o addtiffo

27
contrib/addtiffo/Makefile.vc Executable file
View File

@@ -0,0 +1,27 @@
#
# If libtiff.a is installed in /usr/lib or /usr/local/lib just point
# LIBTIFF_DIR there. It doesn't need a full libtiff tree.
#
LIBTIFF_DIR = ..\..\libtiff
#
CC = cl.exe
CPPC = cl.exe
CFLAGS = -O -I$(LIBTIFF_DIR)
LIBS = $(LIBTIFF_DIR)\tiff.lib
addtiffo: addtiffo.obj tif_overview.obj rawblockedimage.obj
$(CC) $(CFLAGS) addtiffo.obj tif_overview.obj rawblockedimage.obj \
$(LIBS) /Feaddtiffo.exe
addtiffo.obj: addtiffo.c
$(CC) -c $(CFLAGS) addtiffo.c
tif_overview.obj: tif_overview.cpp
$(CPPC) -c $(CFLAGS) tif_overview.cpp
rawblockedimage.obj: rawblockedimage.cpp
$(CPPC) -c $(CFLAGS) rawblockedimage.cpp
clean:
del *.obj addtiffo.exe

145
contrib/addtiffo/README Normal file
View File

@@ -0,0 +1,145 @@
addtiffo 1.0
============
The addtiffo utility is used to add overview pyramids to an existing
TIFF or GeoTIFF file. Some applications can take advantage of these
overviews to accelerate overview display performance of large rasters.
This release of addtiffo is primarily intended for compatibility testing
with applications, and to see if there is interest in a cleaner release
of the capability ... perhaps incorporation into the libtiff tools
distribution.
Please feel free to contact me with questions, or problems.
warmerda@home.com
http://members.home.com/warmerda
Usage
-----
Usage: addtiffo [-subifd] tiff_filename [resolution_reductions]
Example:
% addtiffo abc.tif 2 4 8 16
The numeric arguments are the list of reduction factors to
generate. In this example a 1/2, 1/4 1/8 and 1/16
Limitations
-----------
See tif_overview.cpp for up to date details.
o RawBlockedImage will create temporary files in the current directory
to cache the overviews so it doesn't have to hold them all in memory.
If the application crashes these will not be deleted (*.rbi).
o Currently only images with bits_per_sample of a multiple of eight
will work.
o The downsampler currently just takes the top left pixel from the
source rectangle. Eventually sampling options of averaging, mode, and
``center pixel'' should be offered.
o The code will attempt to use the same kind of compression,
photometric interpretation, and organization as the source image, but
it doesn't copy geotiff tags to the reduced resolution images.
o Reduced resolution overviews for multi-sample files will currently
always be generated as PLANARCONFIG_SEPARATE. This could be fixed
reasonable easily if needed to improve compatibility with other
packages. Many don't properly support PLANARCONFIG_SEPARATE.
o Overviews are always written as appended IFDs, rather than using the
``tree of tree's'' approach using the SUBIFD tag. I wanted to implement
both, but it isn't currently easy to add a SUBIFD tag to an existing
main tiff IFD with libtiff. I hope to try this again later.
TIFF File Tags
--------------
The results of running addtiffo on a 1024x1024 tiled greyscale file
with the arguments ``2 4 8 16'' is to add four additional TIFF directories
appended on the file with the SUBFILETYPE flag to 0x1 indicating the extra
items are reduced resolution images.
The tiffinfo output of such a file might look like this:
TIFF Directory at offset 0x118008
Image Width: 1024 Image Length: 1024
Tile Width: 256 Tile Length: 112
Bits/Sample: 8
Compression Scheme: none
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Planar Configuration: single image plane
TIFF Directory at offset 0x15e1d2
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 512 Image Length: 512
Tile Width: 256 Tile Length: 112
Bits/Sample: 8
Compression Scheme: none
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Planar Configuration: separate image planes
TIFF Directory at offset 0x1732b8
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 256 Image Length: 256
Tile Width: 256 Tile Length: 112
Bits/Sample: 8
Compression Scheme: none
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Planar Configuration: separate image planes
TIFF Directory at offset 0x17a366
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 128 Image Length: 128
Tile Width: 128 Tile Length: 112
Bits/Sample: 8
Compression Scheme: none
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Planar Configuration: separate image planes
TIFF Directory at offset 0x17b40c
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 64 Image Length: 64
Tile Width: 64 Tile Length: 64
Bits/Sample: 8
Compression Scheme: none
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Planar Configuration: separate image planes
Building
--------
You will need a C, and C++ compiler. You will need to have libtiff already
built and installed. The provided Makefile should work on most Unix systems.
A similar file will be needed for Windows, but is not provided.
The CFLAGS and LIBS macros in the Makefile will have to be updated to
point to the correct location of the libtiff include files, and library.
Credits
-------
o Intergraph Corporation for partially funding the work.
o Global Geomatics for partially funding reorganization of the overview
building ability as a separate utility.
o Orrin Long, and Ed Grissom of Intergraph for explaining what needed to
be done.
o Max Martinez of Erdas for his discussion of external overviews.
o Frank Warmerdam for writing the bulk of the code.
o Sam Leffler since this only exists because of his libtiff.

115
contrib/addtiffo/addtiffo.c Normal file
View File

@@ -0,0 +1,115 @@
/******************************************************************************
* $Id: addtiffo.c,v 1.1 1999/08/17 01:47:59 warmerda Exp $
*
* Project: GeoTIFF Overview Builder
* Purpose: Mainline for building overviews in a TIFF file.
* Author: Frank Warmerdam, warmerda@home.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: addtiffo.c,v $
* Revision 1.1 1999/08/17 01:47:59 warmerda
* New
*
* Revision 1.1 1999/03/12 17:46:32 warmerda
* New
*
* Revision 1.2 1999/02/11 22:27:12 warmerda
* Added multi-sample support
*
* Revision 1.1 1999/02/11 18:12:30 warmerda
* New
*/
#include <stdio.h>
#include <stdlib.h>
#include "tiffio.h"
void TIFFBuildOverviews( const char *, int, int *, int );
/************************************************************************/
/* main() */
/************************************************************************/
int main( int argc, char ** argv )
{
int anOverviews[100];
int nOverviewCount = 0;
int bUseSubIFD = 0;
/* -------------------------------------------------------------------- */
/* Usage: */
/* -------------------------------------------------------------------- */
if( argc < 2 )
{
printf( "Usage: addtiffo tiff_filename [resolution_reductions]\n" );
printf( "\n" );
printf( "Example:\n" );
printf( " %% addtifo abc.tif 2 4 8 16\n" );
exit( 1 );
}
if( strcmp(argv[1],"-subifd") == 0 )
{
bUseSubIFD = 1;
argv++;
}
/* -------------------------------------------------------------------- */
/* Collect the user requested reduction factors. */
/* -------------------------------------------------------------------- */
while( nOverviewCount < argc - 2 && nOverviewCount < 100 )
{
anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]);
nOverviewCount++;
}
/* -------------------------------------------------------------------- */
/* Default to four overview levels. It would be nicer if it */
/* defaulted based on the size of the source image. */
/* -------------------------------------------------------------------- */
if( nOverviewCount == 0 )
{
nOverviewCount = 4;
anOverviews[0] = 2;
anOverviews[1] = 4;
anOverviews[2] = 8;
anOverviews[3] = 16;
}
/* -------------------------------------------------------------------- */
/* Build the overview. */
/* -------------------------------------------------------------------- */
TIFFBuildOverviews( argv[1], nOverviewCount, anOverviews, bUseSubIFD );
/* -------------------------------------------------------------------- */
/* Optionally test for memory leaks. */
/* -------------------------------------------------------------------- */
#ifdef DBMALLOC
malloc_dump(1);
#endif
exit( 0 );
}

View File

@@ -0,0 +1,403 @@
/******************************************************************************
* $Id: rawblockedimage.cpp,v 1.1 1999/08/17 01:47:59 warmerda Exp $
*
* Project: GeoTIFF Overview Builder
* Purpose: Implement the RawBlockedImage class, for holding ``under
* construction'' overviews in a temporary file.
* Author: Frank Warmerdam, warmerda@home.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: rawblockedimage.cpp,v $
* Revision 1.1 1999/08/17 01:47:59 warmerda
* New
*
* Revision 1.2 1999/03/12 17:29:34 warmerda
* Use _WIN32 rather than WIN32.
*
*/
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#ifndef _WIN32
# include <unistd.h>
#endif
#include "rawblockedimage.h"
#ifndef FALSE
# define FALSE 0
# define TRUE 1
#endif
#ifndef MAX
# define MIN(a,b) ((a<b) ? a : b)
# define MAX(a,b) ((a>b) ? a : b)
#endif
/************************************************************************/
/* RawBlockedImage() */
/************************************************************************/
RawBlockedImage::RawBlockedImage( int nXSizeIn, int nYSizeIn,
int nBlockXSizeIn, int nBlockYSizeIn,
int nBitsPerPixelIn )
{
static int nTempCounter = 0;
char szFilename[128];
/* -------------------------------------------------------------------- */
/* Initialize stuff. */
/* -------------------------------------------------------------------- */
nXSize = nXSizeIn;
nYSize = nYSizeIn;
nBlockXSize = nBlockXSizeIn;
nBlockYSize = nBlockYSizeIn;
nBitsPerPixel = nBitsPerPixelIn;
/* -------------------------------------------------------------------- */
/* Create the raw temporary file, trying to verify first that */
/* it doesn't already exist. */
/* -------------------------------------------------------------------- */
fp = NULL;
while( fp == NULL )
{
sprintf( szFilename, "temp_%d.rbi", nTempCounter++ );
fp = fopen( szFilename, "r" );
if( fp != NULL )
fclose( fp );
else
fp = fopen( szFilename, "w+b" );
}
pszFilename = strdup( szFilename );
nCurFileSize = 0;
/* -------------------------------------------------------------------- */
/* Initialize other stuff. */
/* -------------------------------------------------------------------- */
nBlocksPerRow = (nXSize + nBlockXSize - 1) / nBlockXSize;
nBlocksPerColumn = (nYSize + nBlockYSize - 1) / nBlockYSize;
nBytesPerBlock = (nBlockXSize*nBlockYSize*nBitsPerPixel + 7) / 8;
nBlocks = nBlocksPerRow * nBlocksPerColumn;
nBlocksInCache = 0;
nMaxBlocksInCache = MIN(nBlocks, 2*nBlocksPerRow);
papoBlocks = (RawBlock **) calloc(sizeof(RawBlock*),nBlocks);
poLRUHead = NULL;
poLRUTail = NULL;
}
/************************************************************************/
/* ~RawBlockedImage() */
/************************************************************************/
RawBlockedImage::~RawBlockedImage()
{
int i;
for( i = 0; i < nBlocks; i++ )
{
if( papoBlocks[i] != NULL )
{
if( papoBlocks[i]->pabyData != NULL )
free( papoBlocks[i]->pabyData );
delete papoBlocks[i];
}
}
if( papoBlocks != NULL)
free( papoBlocks );
fclose( fp );
unlink( pszFilename ); /* wrap this? */
free( pszFilename );
}
/************************************************************************/
/* InsertInLRUList() */
/* */
/* Insert this link at the beginning of the LRU list. First */
/* removed from it's current position if it is in the list. */
/************************************************************************/
void RawBlockedImage::InsertInLRUList( RawBlock * poBlock )
{
/* -------------------------------------------------------------------- */
/* Remove from list, if it is currently in it. */
/* -------------------------------------------------------------------- */
if( poBlock->poPrevLRU != NULL || poLRUHead == poBlock )
RemoveFromLRUList( poBlock );
/* -------------------------------------------------------------------- */
/* Add at the head. */
/* -------------------------------------------------------------------- */
if( poLRUHead != NULL )
{
poLRUHead->poPrevLRU = poBlock;
}
poBlock->poNextLRU = poLRUHead;
poLRUHead = poBlock;
if( poLRUTail == NULL )
poLRUTail = poBlock;
}
/************************************************************************/
/* RemoveFromLRUList() */
/* */
/* Remove this block from the LRU list, if present. */
/************************************************************************/
void RawBlockedImage::RemoveFromLRUList( RawBlock * poBlock )
{
/* -------------------------------------------------------------------- */
/* Is it even in the list? */
/* -------------------------------------------------------------------- */
if( poBlock->poPrevLRU == NULL && poLRUHead != poBlock )
return;
/* -------------------------------------------------------------------- */
/* Fix the link before this in the list (or head pointer). */
/* -------------------------------------------------------------------- */
if( poBlock->poPrevLRU == NULL )
{
poLRUHead = poBlock->poNextLRU;
}
else
{
poBlock->poPrevLRU->poNextLRU = poBlock->poNextLRU;
}
/* -------------------------------------------------------------------- */
/* Fix the link after this one, or the tail pointer. */
/* -------------------------------------------------------------------- */
if( poBlock->poNextLRU == NULL )
{
poLRUTail = poBlock->poPrevLRU;
}
else
{
poBlock->poNextLRU->poPrevLRU = poBlock->poPrevLRU;
}
/* -------------------------------------------------------------------- */
/* Update this link to indicate it isn't in the list now. */
/* -------------------------------------------------------------------- */
poBlock->poPrevLRU = poBlock->poNextLRU = NULL;
}
/************************************************************************/
/* FlushBlock() */
/************************************************************************/
void RawBlockedImage::FlushBlock( RawBlock * poBlock )
{
/* -------------------------------------------------------------------- */
/* If we aren't given a particular block to flush, then select */
/* the lest recently used one from the LRU list. */
/* -------------------------------------------------------------------- */
if( poBlock == NULL )
{
if( poLRUTail == NULL )
return;
poBlock = poLRUTail;
}
/* -------------------------------------------------------------------- */
/* Remove from the LRU list. */
/* -------------------------------------------------------------------- */
RemoveFromLRUList( poBlock );
/* -------------------------------------------------------------------- */
/* If the block has no data, then it doesn't really need to be */
/* flushed. */
/* -------------------------------------------------------------------- */
if( poBlock->pabyData == NULL )
return;
/* -------------------------------------------------------------------- */
/* Is this block dirty? If so we will have to try and save it. */
/* -------------------------------------------------------------------- */
if( poBlock->nDirty )
{
if( poBlock->nPositionInFile == -1 )
poBlock->nPositionInFile = nCurFileSize;
nCurFileSize += nBytesPerBlock;
if( fseek( fp, poBlock->nPositionInFile, SEEK_SET ) != 0 )
{
fprintf( stderr,
"Seek to %d in overview spill file %s failed.\n",
poBlock->nPositionInFile, pszFilename );
exit( 1 );
}
if( fwrite( poBlock->pabyData, 1, nBytesPerBlock, fp )
!= (size_t) nBytesPerBlock )
{
fprintf( stderr,
"Write of %d bytes at %d in overview spill file %s.\n"
"Is the disk full?\n",
nBytesPerBlock, poBlock->nPositionInFile, pszFilename );
exit( 1 );
}
poBlock->nDirty = FALSE;
}
/* -------------------------------------------------------------------- */
/* Free the data block, and decrement used count. */
/* -------------------------------------------------------------------- */
nBlocksInCache--;
if( poBlock->pabyData != NULL )
free( poBlock->pabyData );
poBlock->pabyData = NULL;
}
/************************************************************************/
/* GetRawBlock() */
/************************************************************************/
RawBlock *RawBlockedImage::GetRawBlock( int nXOff, int nYOff )
{
int nBlock = nXOff + nYOff * nBlocksPerRow;
RawBlock *poBlock;
assert( nBlock >= 0 && nBlock < nBlocks );
/* -------------------------------------------------------------------- */
/* Is this the first request? If so, create the block object, */
/* initialize the data memory, and return it. */
/* -------------------------------------------------------------------- */
poBlock = papoBlocks[nBlock];
if( poBlock == NULL )
{
poBlock = papoBlocks[nBlock] = new RawBlock;
poBlock->nDirty = FALSE;
poBlock->poPrevLRU = poBlock->poNextLRU = NULL;
poBlock->nPositionInFile = -1;
poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
nBlocksInCache++;
if( poBlock->pabyData == NULL )
{
fprintf( stderr,
"RawBlockedImage::GetRawBlock() - out of memory\n" );
exit( 1 );
}
}
/* -------------------------------------------------------------------- */
/* Does this block need to be read off disk? */
/* -------------------------------------------------------------------- */
else if( poBlock->nPositionInFile >= 0 && poBlock->pabyData == NULL )
{
nBlocksInCache++;
poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
fseek( fp, poBlock->nPositionInFile, SEEK_SET );
fread( poBlock->pabyData, nBytesPerBlock, 1, fp );
}
/* -------------------------------------------------------------------- */
/* Does the data need to be allocated? */
/* -------------------------------------------------------------------- */
else if( poBlock->pabyData == NULL )
{
poBlock->pabyData = (unsigned char *) calloc(1,nBytesPerBlock);
if( poBlock->pabyData == NULL )
{
fprintf( stderr,
"RawBlockedImage::GetRawBlock() - out of memory\n" );
exit( 1 );
}
}
/* -------------------------------------------------------------------- */
/* Push on the LRU stack, or pop it back to the top. */
/* -------------------------------------------------------------------- */
InsertInLRUList( poBlock );
/* -------------------------------------------------------------------- */
/* If we have exceeded our self imposed caching limit, flush */
/* one block. */
/* -------------------------------------------------------------------- */
if( nBlocksInCache > nMaxBlocksInCache )
FlushBlock( NULL );
return( poBlock );
}
/************************************************************************/
/* GetTile() */
/************************************************************************/
unsigned char *RawBlockedImage::GetTile( int nXOff, int nYOff )
{
RawBlock *poBlock;
poBlock = GetRawBlock(nXOff,nYOff);
if( poBlock != NULL )
return poBlock->pabyData;
else
return NULL;
}
/************************************************************************/
/* GetTileForUpdate() */
/************************************************************************/
unsigned char *RawBlockedImage::GetTileForUpdate( int nXOff, int nYOff )
{
RawBlock *poBlock;
poBlock = GetRawBlock(nXOff,nYOff);
if( poBlock != NULL )
{
poBlock->nDirty = TRUE;
return poBlock->pabyData;
}
else
return NULL;
}

View File

@@ -0,0 +1,108 @@
/******************************************************************************
* $Id: rawblockedimage.h,v 1.1 1999/08/17 01:47:59 warmerda Exp $
*
* Project: GeoTIFF Overview Builder
* Purpose: Implement the RawBlockedImage class, for holding ``under
* construction'' overviews in a temporary file.
* Author: Frank Warmerdam, warmerda@home.com
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log:
*/
#ifndef RAWBLOCKEDIMAGE_H_INCLUDED
#define RAWBLOCKEDIMAGE_H_INCLUDED
#include <stdio.h>
/************************************************************************/
/* ==================================================================== */
/* RawBlockedImage */
/* */
/* The RawBlockedImage class is used to maintain a single band */
/* raster tiled image on disk. */
/* ==================================================================== */
/************************************************************************/
class RawBlock
{
public:
RawBlock *poNextLRU;
RawBlock *poPrevLRU;
int nDirty;
int nPositionInFile;
unsigned char *pabyData;
};
class RawBlockedImage
{
int nXSize;
int nYSize;
int nBlockXSize;
int nBlockYSize;
int nBitsPerPixel;
int nBytesPerBlock;
int nBlocksPerRow;
int nBlocksPerColumn;
int nBlocks;
RawBlock **papoBlocks;
int nBlocksInCache;
int nMaxBlocksInCache;
FILE *fp;
int nCurFileSize;
char *pszFilename;
RawBlock *GetRawBlock( int, int );
void FlushBlock( RawBlock * );
void InsertInLRUList( RawBlock * );
void RemoveFromLRUList( RawBlock * );
RawBlock *poLRUHead;
RawBlock *poLRUTail;
public:
RawBlockedImage( int nXSize, int nYSize,
int nBlockXSize, int nBlockYSize,
int nBitsPerPixel );
~RawBlockedImage();
unsigned char*GetTile( int, int );
unsigned char*GetTileForUpdate( int, int );
int GetBlockXSize() { return nBlockXSize; }
int GetBlockYSize() { return nBlockYSize; }
int GetXSize() { return nXSize; }
int GetYSize() { return nYSize; }
int GetBitsPerPixel() { return nBitsPerPixel; }
};
#endif /* ndef RAWBLOCKEDIMAGE_H_INCLUDED */

View File

@@ -0,0 +1,559 @@
/******************************************************************************
* $Id: tif_overview.cpp,v 1.1 1999/08/17 01:47:59 warmerda Exp $
*
* Project: TIFF Overview Builder
* Purpose: Library function for building overviews in a TIFF file.
* Author: Frank Warmerdam, warmerda@home.com
*
* Notes:
* o This module uses the RawBlockedImage class to hold the overviews as
* they are being built since we can't easily be reading from one directory
* in a TIFF file, and writing to a bunch of others.
*
* o RawBlockedImage will create temporary files in the current directory
* to cache the overviews so it doesn't have to hold them all in memory.
* If the application crashes these will not be deleted (*.rbi).
*
* o Currently only images with bits_per_sample of a multiple of eight
* will work.
*
* o The downsampler currently just takes the top left pixel from the
* source rectangle. Eventually sampling options of averaging, mode, and
* ``center pixel'' should be offered.
*
* o The code will attempt to use the same kind of compression,
* photometric interpretation, and organization as the source image, but
* it doesn't copy geotiff tags to the reduced resolution images.
*
* o Reduced resolution overviews for multi-sample files will currently
* always be generated as PLANARCONFIG_SEPARATE. This could be fixed
* reasonable easily if needed to improve compatibility with other
* packages. Many don't properly support PLANARCONFIG_SEPARATE.
*
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
******************************************************************************
*
* $Log: tif_overview.cpp,v $
* Revision 1.1 1999/08/17 01:47:59 warmerda
* New
*
* Revision 1.7 1999/03/12 17:47:26 warmerda
* made independent of CPL
*
* Revision 1.6 1999/02/24 16:24:00 warmerda
* Don't include cpl_string.h
*
* Revision 1.5 1999/02/11 22:27:12 warmerda
* Added multi-sample support
*
* Revision 1.4 1999/02/11 19:23:39 warmerda
* Only fix on multiples of 16 in block size if it is a tiled file.
*
* Revision 1.3 1999/02/11 19:21:14 warmerda
* Limit tile sizes to multiples of 16
*
* Revision 1.2 1999/02/11 18:37:43 warmerda
* Removed debugging malloc stuff.
*
* Revision 1.1 1999/02/11 18:12:30 warmerda
* New
*
*/
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "tiffio.h"
#include "rawblockedimage.h"
#ifndef FALSE
# define FALSE 0
# define TRUE 1
#endif
#ifndef MAX
# define MIN(a,b) ((a<b) ? a : b)
# define MAX(a,b) ((a>b) ? a : b)
#endif
extern "C" {
void TIFFBuildOverviews( const char *, int, int *, int );
}
/************************************************************************/
/* TIFF_WriteOverview() */
/************************************************************************/
static
void TIFF_WriteOverview( TIFF *hTIFF, int nSamples, RawBlockedImage **papoRBI,
int bTiled, int nCompressFlag, int nPhotometric,
unsigned short *panRed,
unsigned short *panGreen,
unsigned short *panBlue,
int bUseSubIFDs )
{
int iSample;
RawBlockedImage *poRBI = papoRBI[0];
/* -------------------------------------------------------------------- */
/* Setup TIFF fields. */
/* -------------------------------------------------------------------- */
TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, poRBI->GetXSize() );
TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, poRBI->GetYSize() );
TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG,
PLANARCONFIG_SEPARATE );
TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, poRBI->GetBitsPerPixel() );
TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples );
TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompressFlag );
TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometric );
if( bTiled )
{
TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, poRBI->GetBlockXSize() );
TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, poRBI->GetBlockYSize() );
}
else
TIFFSetField( hTIFF, TIFFTAG_ROWSPERSTRIP, poRBI->GetBlockYSize() );
TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE );
/* -------------------------------------------------------------------- */
/* Write color table if one is present. */
/* -------------------------------------------------------------------- */
if( panRed != NULL )
{
TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panRed, panGreen, panBlue );
}
/* -------------------------------------------------------------------- */
/* Write blocks to TIFF file. */
/* -------------------------------------------------------------------- */
for( iSample = 0; iSample < nSamples; iSample++ )
{
int iTileX, iTileY;
poRBI = papoRBI[iSample];
for( iTileY = 0;
iTileY*poRBI->GetBlockYSize() < poRBI->GetYSize();
iTileY++ )
{
for( iTileX = 0;
iTileX*poRBI->GetBlockXSize() < poRBI->GetXSize();
iTileX++ )
{
unsigned char *pabyData = poRBI->GetTile( iTileX, iTileY );
int nTileID;
if( bTiled )
{
nTileID =
TIFFComputeTile(hTIFF,
iTileX * poRBI->GetBlockXSize(),
iTileY * poRBI->GetBlockYSize(),
0, iSample );
TIFFWriteEncodedTile( hTIFF, nTileID,
pabyData, TIFFTileSize(hTIFF) );
}
else
{
nTileID =
TIFFComputeStrip(hTIFF, iTileY*poRBI->GetBlockYSize(),
iSample);
TIFFWriteEncodedStrip( hTIFF, nTileID,
pabyData, TIFFStripSize( hTIFF ) );
}
}
}
}
TIFFWriteDirectory( hTIFF );
}
/************************************************************************/
/* TIFF_DownSample() */
/* */
/* Down sample a tile of full res data into a window of a tile */
/* of downsampled data. */
/************************************************************************/
static
void TIFF_DownSample( unsigned char *pabySrcTile,
int nBlockXSize, int nBlockYSize,
int nPixelSkewBits, int nBitsPerPixel,
unsigned char * pabyOTile,
int nOBlockXSize, int nOBlockYSize,
int nTXOff, int nTYOff, int nOMult )
{
int i, j, k, nPixelBytes = (nBitsPerPixel) / 8;
int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8;
unsigned char *pabySrc, *pabyDst;
assert( nBitsPerPixel >= 8 );
/* -------------------------------------------------------------------- */
/* Handle case of one or more whole bytes per sample. */
/* -------------------------------------------------------------------- */
for( j = 0; j*nOMult < nBlockYSize; j++ )
{
if( j + nTYOff >= nOBlockYSize )
break;
pabySrc = pabySrcTile + j*nOMult*nBlockXSize * nPixelGroupBytes;
pabyDst = pabyOTile
+ ((j+nTYOff)*nOBlockXSize + nTXOff) * nPixelBytes;
for( i = 0; i*nOMult < nBlockXSize; i++ )
{
if( i + nTXOff >= nOBlockXSize )
break;
/*
* For now use simple subsampling, from the top left corner
* of the source block of pixels.
*/
for( k = 0; k < nPixelBytes; k++ )
{
*(pabyDst++) = pabySrc[k];
}
pabySrc += nOMult * nPixelGroupBytes;
}
}
}
/************************************************************************/
/* TIFF_ProcessFullResBlock() */
/* */
/* Process one block of full res data, downsampling into each */
/* of the overviews. */
/************************************************************************/
void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig,
int nOverviews, int * panOvList,
int nBitsPerPixel,
int nSamples, RawBlockedImage ** papoRawBIs,
int nSXOff, int nSYOff,
unsigned char *pabySrcTile,
int nBlockXSize, int nBlockYSize )
{
int iOverview, iSample;
for( iSample = 0; iSample < nSamples; iSample++ )
{
/*
* We have to read a tile/strip for each sample for
* PLANARCONFIG_SEPARATE. Otherwise, we just read all the samples
* at once when handling the first sample.
*/
if( nPlanarConfig == PLANARCONFIG_SEPARATE || iSample == 0 )
{
if( TIFFIsTiled(hTIFF) )
{
TIFFReadEncodedTile( hTIFF,
TIFFComputeTile(hTIFF, nSXOff, nSYOff,
0, iSample ),
pabySrcTile,
TIFFTileSize(hTIFF));
}
else
{
TIFFReadEncodedStrip( hTIFF,
TIFFComputeStrip(hTIFF, nSYOff, iSample),
pabySrcTile,
TIFFStripSize(hTIFF) );
}
}
/*
* Loop over destination overview layers
*/
for( iOverview = 0; iOverview < nOverviews; iOverview++ )
{
RawBlockedImage *poRBI = papoRawBIs[iOverview*nSamples + iSample];
unsigned char *pabyOTile;
int nTXOff, nTYOff, nOXOff, nOYOff, nOMult;
int nOBlockXSize = poRBI->GetBlockXSize();
int nOBlockYSize = poRBI->GetBlockYSize();
int nSkewBits, nSampleByteOffset;
/*
* Fetch the destination overview tile
*/
nOMult = panOvList[iOverview];
nOXOff = (nSXOff/nOMult) / nOBlockXSize;
nOYOff = (nSYOff/nOMult) / nOBlockYSize;
pabyOTile = poRBI->GetTileForUpdate( nOXOff, nOYOff );
/*
* Establish the offset into this tile at which we should
* start placing data.
*/
nTXOff = (nSXOff - nOXOff*nOMult*nOBlockXSize) / nOMult;
nTYOff = (nSYOff - nOYOff*nOMult*nOBlockYSize) / nOMult;
/*
* Figure out the skew (extra space between ``our samples'') and
* the byte offset to the first sample.
*/
assert( (nBitsPerPixel % 8) == 0 );
if( nPlanarConfig == PLANARCONFIG_SEPARATE )
{
nSkewBits = 0;
nSampleByteOffset = 0;
}
else
{
nSkewBits = nBitsPerPixel * (nSamples-1);
nSampleByteOffset = (nBitsPerPixel/8) * iSample;
}
/*
* Perform the downsampling.
*/
#ifdef DBMALLOC
malloc_chain_check( 1 );
#endif
TIFF_DownSample( pabySrcTile + nSampleByteOffset,
nBlockXSize, nBlockYSize,
nSkewBits, nBitsPerPixel, pabyOTile,
poRBI->GetBlockXSize(),
poRBI->GetBlockYSize(),
nTXOff, nTYOff,
nOMult );
#ifdef DBMALLOC
malloc_chain_check( 1 );
#endif
}
}
}
/************************************************************************/
/* TIFF_BuildOverviews() */
/* */
/* Build the requested list of overviews. Overviews are */
/* maintained in a bunch of temporary files and then these are */
/* written back to the TIFF file. Only one pass through the */
/* source TIFF file is made for any number of output */
/* overviews. */
/************************************************************************/
void TIFFBuildOverviews( const char * pszTIFFFilename,
int nOverviews, int * panOvList,
int bUseSubIFDs )
{
RawBlockedImage **papoRawBIs;
uint32 nXSize, nYSize, nBlockXSize, nBlockYSize;
uint16 nBitsPerPixel, nPhotometric, nCompressFlag, nSamples,
nPlanarConfig;
int bTiled, nSXOff, nSYOff, i, iSample;
unsigned char *pabySrcTile;
TIFF *hTIFF;
uint16 *panRedMap, *panGreenMap, *panBlueMap;
/* -------------------------------------------------------------------- */
/* Get the base raster size. */
/* -------------------------------------------------------------------- */
hTIFF = TIFFOpen( pszTIFFFilename, "r" );
if( hTIFF == NULL )
{
fprintf( stderr, "TIFFOpen(%s) failed.\n", pszTIFFFilename );
exit( 1 );
}
TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize );
TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize );
TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &nBitsPerPixel );
TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &nSamples );
TIFFGetField( hTIFF, TIFFTAG_PLANARCONFIG, &nPlanarConfig );
TIFFGetField( hTIFF, TIFFTAG_PHOTOMETRIC, &nPhotometric );
TIFFGetField( hTIFF, TIFFTAG_COMPRESSION, &nCompressFlag );
if( nBitsPerPixel < 8 )
{
TIFFError( "TIFFBuildOverviews",
"File `%s' has samples of %d bits per sample. Sample\n"
"sizes of less than 8 bits per sample are not supported.\n",
pszTIFFFilename, nBitsPerPixel );
return;
}
/* -------------------------------------------------------------------- */
/* Get the base raster block size. */
/* -------------------------------------------------------------------- */
if( TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(nBlockYSize) ) )
{
nBlockXSize = nXSize;
bTiled = FALSE;
}
else
{
TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &nBlockXSize );
TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &nBlockYSize );
bTiled = TRUE;
}
/* -------------------------------------------------------------------- */
/* Capture the pallette if there is one. */
/* -------------------------------------------------------------------- */
if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP,
&panRedMap, &panGreenMap, &panBlueMap ) )
{
uint16 *panRed2, *panGreen2, *panBlue2;
panRed2 = (uint16 *) calloc(2,256);
panGreen2 = (uint16 *) calloc(2,256);
panBlue2 = (uint16 *) calloc(2,256);
memcpy( panRed2, panRedMap, 512 );
memcpy( panGreen2, panGreenMap, 512 );
memcpy( panBlue2, panBlueMap, 512 );
panRedMap = panRed2;
panGreenMap = panGreen2;
panBlueMap = panBlue2;
}
else
{
panRedMap = panGreenMap = panBlueMap = NULL;
}
/* -------------------------------------------------------------------- */
/* Initialize the overview raw layers */
/* -------------------------------------------------------------------- */
papoRawBIs = (RawBlockedImage **)
calloc(nOverviews*nSamples,sizeof(void*));
for( i = 0; i < nOverviews; i++ )
{
int nOXSize, nOYSize, nOBlockXSize, nOBlockYSize;
nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i];
nOYSize = (nYSize + panOvList[i] - 1) / panOvList[i];
nOBlockXSize = MIN((int)nBlockXSize,nOXSize);
nOBlockYSize = MIN((int)nBlockYSize,nOYSize);
if( bTiled )
{
if( (nOBlockXSize % 16) != 0 )
nOBlockXSize = nOBlockXSize + 16 - (nOBlockXSize % 16);
if( (nOBlockYSize % 16) != 0 )
nOBlockYSize = nOBlockYSize + 16 - (nOBlockYSize % 16);
}
for( iSample = 0; iSample < nSamples; iSample++ )
{
papoRawBIs[i*nSamples + iSample] =
new RawBlockedImage( nOXSize, nOYSize,
nOBlockXSize, nOBlockYSize,
nBitsPerPixel );
}
}
/* -------------------------------------------------------------------- */
/* Allocate a buffer to hold a source block. */
/* -------------------------------------------------------------------- */
if( bTiled )
pabySrcTile = (unsigned char *) malloc(TIFFTileSize(hTIFF));
else
pabySrcTile = (unsigned char *) malloc(TIFFStripSize(hTIFF));
/* -------------------------------------------------------------------- */
/* Loop over the source raster, applying data to the */
/* destination raster. */
/* -------------------------------------------------------------------- */
for( nSYOff = 0; nSYOff < (int) nYSize; nSYOff += nBlockYSize )
{
for( nSXOff = 0; nSXOff < (int) nXSize; nSXOff += nBlockXSize )
{
/*
* Read and resample into the various overview images.
*/
TIFF_ProcessFullResBlock( hTIFF, nPlanarConfig,
nOverviews, panOvList,
nBitsPerPixel, nSamples, papoRawBIs,
nSXOff, nSYOff, pabySrcTile,
nBlockXSize, nBlockYSize );
}
}
free( pabySrcTile );
TIFFClose( hTIFF );
/* ==================================================================== */
/* We now have the overview rasters built, and held as */
/* RawBlockedImage's. Now we need to write them to new TIFF */
/* layers. */
/* ==================================================================== */
hTIFF = TIFFOpen( pszTIFFFilename, "a" );
if( hTIFF == NULL )
{
fprintf( stderr,
"TIFFOpen(%s,\"a\") failed. No overviews written.\n"
"Do you have write permissions on that file?\n",
pszTIFFFilename );
}
else
{
for( i = 0; i < nOverviews; i++ )
{
TIFF_WriteOverview( hTIFF, nSamples, papoRawBIs + i*nSamples,
bTiled, nCompressFlag, nPhotometric,
panRedMap, panGreenMap, panBlueMap,
bUseSubIFDs );
}
TIFFClose( hTIFF );
}
/* -------------------------------------------------------------------- */
/* Cleanup the rawblockedimage files. */
/* -------------------------------------------------------------------- */
for( i = 0; i < nOverviews*nSamples; i++ )
{
delete papoRawBIs[i];
}
if( papoRawBIs != NULL )
free( papoRawBIs );
if( panRedMap != NULL )
{
free( panRedMap );
free( panGreenMap );
free( panBlueMap );
}
}

View File

@@ -1,7 +0,0 @@
/Imakefile/1.1.1.1/Tue Jul 27 21:50:26 1999//
/README/1.1.1.1/Tue Jul 27 21:50:26 1999//
/tiff-bi.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff-grayscale.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff-palette.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff-rgb.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
D/xtiff////

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/dbs

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,6 +0,0 @@
/Imakefile/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/patchlevel.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
/xtiff.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/xtifficon.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/dbs/xtiff

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,7 +0,0 @@
/Makefile.lib/1.1.1.1/Tue Jul 27 21:50:27 1999//
/Makefile.tools/1.1.1.1/Tue Jul 27 21:50:27 1999//
/Makefile.top/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/conf.bat/1.1.1.1/Tue Jul 27 21:50:27 1999//
/port.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/dosdjgpp

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.lib,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.lib,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#

View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.tools,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.tools,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in for DJGPP v2.x (GNU C for DOS/386).
#

View File

@@ -1,5 +1,5 @@
#! smake
# $Header: /usr/local/cvs/internal/libtiff/contrib/dosdjgpp/Makefile.top,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/contrib/dosdjgpp/Makefile.top,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# manually derived from Makefile.in (though basically nothing remains)
# for DJGPP v2.x (GNU C for DOS/386).

View File

@@ -1,5 +0,0 @@
/Makefile/1.1.1.1/Tue Jul 27 21:50:27 1999//
/iptcutil.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/test.iptc/1.1.1.1/Tue Jul 27 21:50:27 1999//
/test.txt/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/iptcutil

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,12 +0,0 @@
CC=gcc
CFLAGS=
iptcutil: iptcutil.c
$(CC) $(CFLAGS) -o iptcutil iptcutil.c
clean:
rm iptcutil *~
all: iptcutil

View File

@@ -1,920 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef WIN32
#include <io.h>
#endif
#include <string.h>
#include <memory.h>
#include <ctype.h>
#ifdef WIN32
#define STRNICMP strnicmp
#else
#define STRNICMP strncasecmp
#endif
typedef struct _tag_spec
{
short
id;
char
*name;
} tag_spec;
static tag_spec tags[] = {
5,"Image Name",
7,"Edit Status",
10,"Priority",
15,"Category",
20,"Supplemental Category",
22,"Fixture Identifier",
25,"Keyword",
30,"Release Date",
35,"Release Time",
40,"Special Instructions",
45,"Reference Service",
47,"Reference Date",
50,"Reference Number",
55,"Created Date",
60,"Created Time",
65,"Originating Program",
70,"Program Version",
75,"Object Cycle",
80,"Byline",
85,"Byline Title",
90,"City",
95,"Province State",
100,"Country Code",
101,"Country",
103,"Original Transmission Reference",
105,"Headline",
110,"Credit",
115,"Source",
116,"Copyright String",
120,"Caption",
121,"Local Caption",
122,"Caption Writer",
200,"Custom Field 1",
201,"Custom Field 2",
202,"Custom Field 3",
203,"Custom Field 4",
204,"Custom Field 5",
205,"Custom Field 6",
206,"Custom Field 7",
207,"Custom Field 8",
208,"Custom Field 9",
209,"Custom Field 10",
210,"Custom Field 11",
211,"Custom Field 12",
212,"Custom Field 13",
213,"Custom Field 14",
214,"Custom Field 15",
215,"Custom Field 16",
216,"Custom Field 17",
217,"Custom Field 18",
218,"Custom Field 19",
219,"Custom Field 20"
};
/*
* We format the output using HTML conventions
* to preserve control characters and such.
*/
void formatString(FILE *ofile, const char *s, int len)
{
putc('"', ofile);
for (; len > 0; --len, ++s) {
char c = *s;
switch (c) {
case '&':
fputs("&amp;", ofile);
break;
#ifdef HANDLE_GT_LT
case '<':
fputs("&lt;", ofile);
break;
case '>':
fputs("&gt;", ofile);
break;
#endif
case '"':
fputs("&quot;", ofile);
break;
default:
if (iscntrl(c))
fprintf(ofile, "&#%d;", c);
else
putc(*s, ofile);
break;
}
}
fputs("\"\n", ofile);
}
typedef struct _html_code
{
short
len;
const char
*code,
val;
} html_code;
static html_code html_codes[] = {
#ifdef HANDLE_GT_LT
4,"&lt;",'<',
4,"&gt;",'>',
#endif
5,"&amp;",'&',
6,"&quot;",'"'
};
/*
* This routine converts HTML escape sequence
* back to the original ASCII representation.
* - returns the number of characters dropped.
*/
int convertHTMLcodes(char *s, int len)
{
if (len <=0 || s==(char*)NULL || *s=='\0')
return 0;
if (s[1] == '#')
{
int val, o;
if (sscanf(s,"&#%d;",&val) == 1)
{
o = 3;
while (s[o] != ';')
{
o++;
if (o > 5)
break;
}
if (o < 5)
strcpy(s+1, s+1+o);
*s = val;
return o;
}
}
else
{
int
i,
codes = sizeof(html_codes) / sizeof(html_code);
for (i=0; i < codes; i++)
{
if (html_codes[i].len <= len)
if (STRNICMP(s, html_codes[i].code, html_codes[i].len) == 0)
{
strcpy(s+1, s+html_codes[i].len);
*s = html_codes[i].val;
return html_codes[i].len-1;
}
}
}
}
int formatIPTC(FILE *ifile, FILE *ofile)
{
unsigned int
foundiptc,
tagsfound;
unsigned char
recnum,
dataset;
unsigned char
*readable,
*str;
long
tagindx,
taglen;
int
i,
tagcount = sizeof(tags) / sizeof(tag_spec);
char
c;
foundiptc = 0; /* found the IPTC-Header */
tagsfound = 0; /* number of tags found */
c = getc(ifile);
while (c != EOF)
{
if (c == 0x1c)
foundiptc = 1;
else
{
if (foundiptc)
return -1;
else
continue;
}
/* we found the 0x1c tag and now grab the dataset and record number tags */
dataset = getc(ifile);
if ((char) dataset == EOF)
return -1;
recnum = getc(ifile);
if ((char) recnum == EOF)
return -1;
/* try to match this record to one of the ones in our named table */
for (i=0; i< tagcount; i++)
{
if (tags[i].id == recnum)
break;
}
if (i < tagcount)
readable = tags[i].name;
else
readable = "";
/* then we decode the length of the block that follows - long or short fmt */
c = getc(ifile);
if (c == EOF)
return 0;
if (c & (unsigned char) 0x80)
{
unsigned char
buffer[4];
for (i=0; i<4; i++)
{
c = buffer[i] = getc(ifile);
if (c == EOF)
return -1;
}
taglen = (((long) buffer[ 0 ]) << 24) |
(((long) buffer[ 1 ]) << 16) |
(((long) buffer[ 2 ]) << 8) |
(((long) buffer[ 3 ]));
}
else
{
unsigned char
x = c;
taglen = ((long) x) << 8;
x = getc(ifile);
if ((char)x == EOF)
return -1;
taglen |= (long) x;
}
/* make a buffer to hold the tag data and snag it from the input stream */
str=(unsigned char *) malloc((unsigned int) (taglen+1));
if (str == (unsigned char *) NULL)
{
printf("Memory allocation failed");
return 0;
}
for (tagindx=0; tagindx<taglen; tagindx++)
{
c = str[tagindx] = getc(ifile);
if (c == EOF)
return -1;
}
str[ taglen ] = 0;
/* now finish up by formatting this binary data into ASCII equivalent */
if (strlen(readable) > 0)
fprintf(ofile, "%d#%d#%s=",(unsigned int)dataset, (unsigned int) recnum, readable);
else
fprintf(ofile, "%d#%d=",(unsigned int)dataset, (unsigned int) recnum);
formatString( ofile, str, taglen );
free(str);
tagsfound++;
c = getc(ifile);
}
return tagsfound;
}
int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
char *white,char *brkchar,char *quote,char eschar,char *brkused,
int *next,char *quoted);
char *super_fgets(char *b, int *blen, FILE *file)
{
int
c,
len;
unsigned char
*q;
len=*blen;
for (q=b; ; q++)
{
c=fgetc(file);
if (c == EOF || c == '\n')
break;
if (((int)q - (int)b + 1 ) >= (int) len)
{
int
tlen;
tlen=(int)q-(int)b;
len<<=1;
b=(unsigned char *) realloc((char *) b,(len+2));
if ((unsigned char *) b == (unsigned char *) NULL)
break;
q=b+tlen;
}
*q=(unsigned char) c;
}
*blen=0;
if ((unsigned char *)b != (unsigned char *) NULL)
{
int
tlen;
tlen=(int)q - (int)b;
if (tlen == 0)
return (char *) NULL;
b[tlen] = '\0';
*blen=++tlen;
}
return b;
}
#define BUFFER_SZ 4096
int main(int argc, char *argv[])
{
unsigned int
length;
unsigned char
*buffer;
int
i,
mode; /* iptc binary, or iptc text */
FILE
*ifile = stdin,
*ofile = stdout;
char
c,
*usage = "usage: iptcutil -t | -b [-i file] [-o file] <input >output";
if( argc < 2 )
{
printf(usage);
return 1;
}
mode = 0;
length = -1;
buffer = (unsigned char *)NULL;
for (i=1; i<argc; i++)
{
c = argv[i][0];
if (c == '-' || c == '/')
{
c = argv[i][1];
switch( c )
{
case 't':
mode = 1;
#ifdef WIN32
/* Set "stdout" to binary mode: */
_setmode( _fileno( ofile ), _O_BINARY );
#endif
break;
case 'b':
mode = 0;
#ifdef WIN32
/* Set "stdin" to binary mode: */
_setmode( _fileno( ifile ), _O_BINARY );
#endif
break;
case 'i':
if (mode == 0)
ifile = fopen(argv[++i], "rb");
else
ifile = fopen(argv[++i], "rt");
if (ifile == (FILE *)NULL)
{
printf("Unable to open: %s\n", argv[i]);
return 1;
}
break;
case 'o':
if (mode == 0)
ofile = fopen(argv[++i], "wt");
else
ofile = fopen(argv[++i], "wb");
if (ofile == (FILE *)NULL)
{
printf("Unable to open: %s\n", argv[i]);
return 1;
}
break;
default:
printf("Unknown option: %s\n", argv[i]);
return 1;
}
}
else
{
printf(usage);
return 1;
}
}
if (mode == 0) /* handle binary iptc info */
formatIPTC(ifile, ofile);
if (mode == 1) /* handle text form of iptc info */
{
char
brkused,
quoted,
*line,
*token,
*newstr;
int
state,
next;
unsigned char
recnum,
dataset;
int
inputlen = BUFFER_SZ;
line = (char *) malloc(inputlen);
token = (char *)NULL;
while((line = super_fgets(line,&inputlen,ifile))!=NULL)
{
state=0;
next=0;
token = (char *) malloc(inputlen);
newstr = (char *) malloc(inputlen);
while(tokenizer(0, token, inputlen, line, "", "=", "\"", 0,
&brkused,&next,&quoted)==0)
{
if (state == 0)
{
int
state,
next;
char
brkused,
quoted;
state=0;
next=0;
while(tokenizer(0, newstr, inputlen, token, "", "#", "", 0,
&brkused, &next, &quoted)==0)
{
if (state == 0)
dataset = (unsigned char) atoi(newstr);
else
if (state == 1)
recnum = (unsigned char) atoi(newstr);
state++;
}
}
else
if (state == 1)
{
int
next;
unsigned long
len;
char
brkused,
quoted;
next=0;
len = strlen(token);
while(tokenizer(0, newstr, inputlen, token, "", "&", "", 0,
&brkused, &next, &quoted)==0)
{
if (brkused && next > 0)
{
char
*s = &token[next-1];
len -= convertHTMLcodes(s, strlen(s));
}
}
fputc(0x1c, ofile);
fputc(dataset, ofile);
fputc(recnum, ofile);
if (len < 0x10000)
{
fputc((len >> 8) & 255, ofile);
fputc(len & 255, ofile);
}
else
{
fputc(((len >> 24) & 255) | 0x80, ofile);
fputc((len >> 16) & 255, ofile);
fputc((len >> 8) & 255, ofile);
fputc(len & 255, ofile);
}
next=0;
while (len--)
fputc(token[next++], ofile);
}
state++;
}
free(token);
token = (char *)NULL;
free(newstr);
newstr = (char *)NULL;
}
free(line);
fclose( ifile );
fclose( ofile );
}
return 0;
}
/*
This routine is a generalized, finite state token parser. It allows
you extract tokens one at a time from a string of characters. The
characters used for white space, for break characters, and for quotes
can be specified. Also, characters in the string can be preceded by
a specifiable escape character which removes any special meaning the
character may have.
There are a lot of formal parameters in this subroutine call, but
once you get familiar with them, this routine is fairly easy to use.
"#define" macros can be used to generate simpler looking calls for
commonly used applications of this routine.
First, some terminology:
token: used here, a single unit of information in
the form of a group of characters.
white space: space that gets ignored (except within quotes
or when escaped), like blanks and tabs. in
addition, white space terminates a non-quoted
token.
break character: a character that separates non-quoted tokens.
commas are a common break character. the
usage of break characters to signal the end
of a token is the same as that of white space,
except multiple break characters with nothing
or only white space between generate a null
token for each two break characters together.
for example, if blank is set to be the white
space and comma is set to be the break
character, the line ...
A, B, C , , DEF
... consists of 5 tokens:
1) "A"
2) "B"
3) "C"
4) "" (the null string)
5) "DEF"
quote character: a character that, when surrounding a group
of other characters, causes the group of
characters to be treated as a single token,
no matter how many white spaces or break
characters exist in the group. also, a
token always terminates after the closing
quote. for example, if ' is the quote
character, blank is white space, and comma
is the break character, the following
string ...
A, ' B, CD'EF GHI
... consists of 4 tokens:
1) "A"
2) " B, CD" (note the blanks & comma)
3) "EF"
4) "GHI"
the quote characters themselves do
not appear in the resultant tokens. the
double quotes are delimiters i use here for
documentation purposes only.
escape character: a character which itself is ignored but
which causes the next character to be
used as is. ^ and \ are often used as
escape characters. an escape in the last
position of the string gets treated as a
"normal" (i.e., non-quote, non-white,
non-break, and non-escape) character.
for example, assume white space, break
character, and quote are the same as in the
above examples, and further, assume that
^ is the escape character. then, in the
string ...
ABC, ' DEF ^' GH' I ^ J K^ L ^
... there are 7 tokens:
1) "ABC"
2) " DEF ' GH"
3) "I"
4) " " (a lone blank)
5) "J"
6) "K L"
7) "^" (passed as is at end of line)
OK, now that you have this background, here's how to call "tokenizer":
result=tokenizer(flag,token,maxtok,string,white,break,quote,escape,
brkused,next,quoted)
result: 0 if we haven't reached EOS (end of string), and
1 if we have (this is an "int").
flag: right now, only the low order 3 bits are used.
1 => convert non-quoted tokens to upper case
2 => convert non-quoted tokens to lower case
0 => do not convert non-quoted tokens
(this is a "char").
token: a character string containing the returned next token
(this is a "char[]").
maxtok: the maximum size of "token". characters beyond
"maxtok" are truncated (this is an "int").
string: the string to be parsed (this is a "char[]").
white: a string of the valid white spaces. example:
char whitesp[]={" \t"};
blank and tab will be valid white space (this is
a "char[]").
break: a string of the valid break characters. example:
char breakch[]={";,"};
semicolon and comma will be valid break characters
(this is a "char[]").
IMPORTANT: do not use the name "break" as a C
variable, as this is a reserved word in C.
quote: a string of the valid quote characters. an example
would be
char whitesp[]={"'\"");
(this causes single and double quotes to be valid)
note that a token starting with one of these characters
needs the same quote character to terminate it.
for example,
"ABC '
is unterminated, but
"DEF" and 'GHI'
are properly terminated. note that different quote
characters can appear on the same line; only for
a given token do the quote characters have to be
the same (this is a "char[]").
escape: the escape character (NOT a string ... only one
allowed). use zero if none is desired (this is
a "char").
brkused: the break character used to terminate the current
token. if the token was quoted, this will be the
quote used. if the token is the last one on the
line, this will be zero (this is a pointer to a
"char").
next: this variable points to the first character of the
next token. it gets reset by "tokenizer" as it steps
through the string. set it to 0 upon initialization,
and leave it alone after that. you can change it
if you want to jump around in the string or re-parse
from the beginning, but be careful (this is a
pointer to an "int").
quoted: set to 1 (true) if the token was quoted and 0 (false)
if not. you may need this information (for example:
in C, a string with quotes around it is a character
string, while one without is an identifier).
(this is a pointer to a "char").
*/
/* states */
#define IN_WHITE 0
#define IN_TOKEN 1
#define IN_QUOTE 2
#define IN_OZONE 3
int _p_state; /* current state */
unsigned _p_flag; /* option flag */
char _p_curquote; /* current quote char */
int _p_tokpos; /* current token pos */
/* routine to find character in string ... used only by "tokenizer" */
int sindex(char ch,char *string)
{
char *cp;
for(cp=string;*cp;++cp)
if(ch==*cp)
return (int)(cp-string); /* return postion of character */
return -1; /* eol ... no match found */
}
/* routine to store a character in a string ... used only by "tokenizer" */
void chstore(char *string,int max,char ch)
{
char c;
if(_p_tokpos>=0&&_p_tokpos<max-1)
{
if(_p_state==IN_QUOTE)
c=ch;
else
switch(_p_flag&3)
{
case 1: /* convert to upper */
c=toupper(ch);
break;
case 2: /* convert to lower */
c=tolower(ch);
break;
default: /* use as is */
c=ch;
break;
}
string[_p_tokpos++]=c;
}
return;
}
int tokenizer(unsigned inflag,char *token,int tokmax,char *line,
char *white,char *brkchar,char *quote,char eschar,char *brkused,
int *next,char *quoted)
{
int qp;
char c,nc;
*brkused=0; /* initialize to null */
*quoted=0; /* assume not quoted */
if(!line[*next]) /* if we're at end of line, indicate such */
return 1;
_p_state=IN_WHITE; /* initialize state */
_p_curquote=0; /* initialize previous quote char */
_p_flag=inflag; /* set option flag */
for(_p_tokpos=0;c=line[*next];++(*next)) /* main loop */
{
if((qp=sindex(c,brkchar))>=0) /* break */
{
switch(_p_state)
{
case IN_WHITE: /* these are the same here ... */
case IN_TOKEN: /* ... just get out */
case IN_OZONE: /* ditto */
++(*next);
*brkused=brkchar[qp];
goto byebye;
case IN_QUOTE: /* just keep going */
chstore(token,tokmax,c);
break;
}
}
else if((qp=sindex(c,quote))>=0) /* quote */
{
switch(_p_state)
{
case IN_WHITE: /* these are identical, */
_p_state=IN_QUOTE; /* change states */
_p_curquote=quote[qp]; /* save quote char */
*quoted=1; /* set to true as long as something is in quotes */
break;
case IN_QUOTE:
if(quote[qp]==_p_curquote) /* same as the beginning quote? */
{
_p_state=IN_OZONE;
_p_curquote=0;
}
else
chstore(token,tokmax,c); /* treat as regular char */
break;
case IN_TOKEN:
case IN_OZONE:
*brkused=c; /* uses quote as break char */
goto byebye;
}
}
else if((qp=sindex(c,white))>=0) /* white */
{
switch(_p_state)
{
case IN_WHITE:
case IN_OZONE:
break; /* keep going */
case IN_TOKEN:
_p_state=IN_OZONE;
break;
case IN_QUOTE:
chstore(token,tokmax,c); /* it's valid here */
break;
}
}
else if(c==eschar) /* escape */
{
nc=line[(*next)+1];
if(nc==0) /* end of line */
{
*brkused=0;
chstore(token,tokmax,c);
++(*next);
goto byebye;
}
switch(_p_state)
{
case IN_WHITE:
--(*next);
_p_state=IN_TOKEN;
break;
case IN_TOKEN:
case IN_QUOTE:
++(*next);
chstore(token,tokmax,nc);
break;
case IN_OZONE:
goto byebye;
}
}
else /* anything else is just a real character */
{
switch(_p_state)
{
case IN_WHITE:
_p_state=IN_TOKEN; /* switch states */
case IN_TOKEN: /* these 2 are */
case IN_QUOTE: /* identical here */
chstore(token,tokmax,c);
break;
case IN_OZONE:
goto byebye;
}
}
} /* end of main loop */
byebye:
token[_p_tokpos]=0; /* make sure token ends with EOS */
return 0;
}

Binary file not shown.

View File

@@ -1,32 +0,0 @@
2#0="&#0;&#2;"
2#120#Caption="Chairman of the US House Judiciary Committee, Henry Hyde,R-IL, makes his opening statement during impeachment hearings 11 December on Capitol Hill in Washington, DC. The committee is debating the articles of impechment and my take a vote on the impeachment of US President BIll Clinton on charges that he obstucted justice, lied and abused the power of his office as early as today. AFP PHOTO Paul J. RICHARDS&#13;"
2#122#Caption Writer="kb/lt"
2#100#Country Code="USA"
2#105#Headline="Old fart squeezing two fingers."
2#30#Release Date="19981211"
2#35#Release Time="000000+0000"
2#40#Special Instructions="This is a test. This is only a test. ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890"
2#80#Byline="PAUL J. RICHARDS"
2#85#Byline Title="STF"
2#110#Credit="AFP"
2#65#Originating Program="MacDesk Reporter"
2#115#Source="AFP"
2#5#Image Name="US-HYDE"
2#55#Created Date="19981211"
2#90#City="WASHINGTON"
2#95#Province State="DC"
2#101#Country="UNITED STATES"
2#103#Original Transmission Reference="DCA03"
2#15#Category="POL"
2#20#Supplemental Category="GOVERNMENT"
2#10#Priority="5"
2#25#Keyword="fart"
2#25#Keyword="squeezing"
2#25#Keyword="old"
2#25#Keyword="fingers"
2#75#Object Cycle="a"
2#60#Created Time="000000+0000"
2#70#Program Version="2.0.3"
2#130="3S"
2#135="GB"
2#231="Kaya A. Hoffmann 12/14/98 12:00:44 PM Copy To : Selects - \\KINYANI\Selects&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;&#0;"

View File

@@ -1,8 +0,0 @@
/Makefile.script/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/mac_main.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/mac_main.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
/metrowerks.note/1.1.1.1/Tue Jul 27 21:50:27 1999//
/mkg3_main.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/version.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/mac-cw

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,8 +0,0 @@
/BUILD.mpw/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/libtiff.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
/mactrans.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/port.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tools.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
/top.make/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/mac-mpw

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,3 +0,0 @@
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/mfs_file.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/mfs

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,6 +0,0 @@
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tif_imageiter.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tif_imageiter.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tif_pdsdirread.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tif_pdsdirwrite.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/pds

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,4 +1,4 @@
/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_imageiter.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_imageiter.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/*
* Copyright (c) 1991-1996 Sam Leffler

View File

@@ -1,4 +1,4 @@
/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_pdsdirread.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_pdsdirread.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/*
* Copyright (c) 1988-1996 Sam Leffler

View File

@@ -1,4 +1,4 @@
/* $Header: /usr/local/cvs/internal/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* $Header: /cvsroot/osrs/libtiff/contrib/pds/tif_pdsdirwrite.c,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* When writing data to TIFF files, it is often useful to store application-
specific data in a private TIFF directory so that the tags don't need to

View File

@@ -1,4 +0,0 @@
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/ras2tif.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tif2ras.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/ras

View File

@@ -1 +0,0 @@
/usr/local/cvs

56
contrib/tags/Makefile.gcc Normal file
View File

@@ -0,0 +1,56 @@
# 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= -g
CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY}
#
LIBS= ./libxtiff.a ${TIFFLIB}/libtiff.a -lm
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

67
contrib/tags/Makefile.mpw Normal file
View File

@@ -0,0 +1,67 @@
#***********************************************************************
#
# 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

116
contrib/tags/README Normal file
View File

@@ -0,0 +1,116 @@
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
<tag_extender>, 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).

32
contrib/tags/listtif.c Normal file
View File

@@ -0,0 +1,32 @@
/*
* listtif.c -- lists a tiff file.
*/
#include "xtiffio.h"
#include <stdlib.h>
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);
}

70
contrib/tags/maketif.c Normal file
View File

@@ -0,0 +1,70 @@
/*
* maketif.c -- creates a little TIFF file, with
* the XTIFF extended tiff example tags.
*/
#include <stdlib.h>
#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<HEIGHT;i++)
if (!TIFFWriteScanline(tif, buffer, i, 0))
TIFFError("WriteImage","failure in WriteScanline\n");
}

343
contrib/tags/xtif_dir.c Normal file
View File

@@ -0,0 +1,343 @@
/*
* xtif_dir.c
*
* Extended TIFF Directory Tag Support.
*
* You may use this file as a template to add your own
* extended tags to the library. Only the parts of the code
* marked with "XXX" require modification. Three example tags
* are shown; you should replace them with your own.
*
* Author: Niles D. Ritter
*/
#include "xtiffiop.h"
#include <stdio.h>
/* 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;i<num;i++) fprintf(fd, " %lg", *value++);
fprintf(fd,")\n");
} else
fprintf(fd, "(present)\n");
}
if (TIFFFieldSet(tif,FIELD_EXAMPLE_SINGLE))
{
fprintf(fd, " My Single Long Tag: %lu\n", xd->xd_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);
}

52
contrib/tags/xtiffio.h Normal file
View File

@@ -0,0 +1,52 @@
/*
* 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 */

65
contrib/tags/xtiffiop.h Normal file
View File

@@ -0,0 +1,65 @@
/*
* 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 */

View File

@@ -1,2 +0,0 @@
D/libtiff////
D/tools////

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/vms

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,6 +0,0 @@
/makevms.com/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiffshraxp.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiffshrvax.opt/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiffvec.mar/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/vms/libtiff

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,2 +0,0 @@
/makevms.com/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/vms/tools

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,4 +0,0 @@
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/dllshell.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/libtiff.def/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/win32

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,4 +0,0 @@
/Makefile.w95/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff2dib.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/win95

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,8 +0,0 @@
/README/1.1.1.1/Tue Jul 27 21:50:27 1999//
/README.console/1.1.1.1/Tue Jul 27 21:50:27 1999//
/fax3sm.c/1.1.1.1/Tue Jul 27 21:50:27 1999//
/libtiff.def/1.1.1.1/Tue Jul 27 21:50:27 1999//
/libtiff.mak/1.1.1.1/Tue Jul 27 21:50:27 1999//
/libtiff.vcp/1.1.1.1/Tue Jul 27 21:50:27 1999//
/version.h/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/contrib/winnt

View File

@@ -1 +0,0 @@
/usr/local/cvs

6
dist/CVS/Entries vendored
View File

@@ -1,6 +0,0 @@
/newalpha/1.1.1.1/Tue Jul 27 21:50:27 1999//
/newversion/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff.alpha/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff.spec/1.1.1.1/Tue Jul 27 21:50:27 1999//
/tiff.version/1.1.1.1/Tue Jul 27 21:50:27 1999//
D

1
dist/CVS/Repository vendored
View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/dist

1
dist/CVS/Root vendored
View File

@@ -1 +0,0 @@
/usr/local/cvs

2
dist/newalpha vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# $Header: /usr/local/cvs/internal/libtiff/dist/newalpha,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/dist/newalpha,v 1.1.1.1 1999/07/27 21:50:27 mike 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

2
dist/newversion vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# $Header: /usr/local/cvs/internal/libtiff/dist/newversion,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/dist/newversion,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# TIFF Software
#

2
dist/tiff.alpha vendored
View File

@@ -1 +1 @@
define ALPHA 037
define ALPHA 01

2
dist/tiff.spec vendored
View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/dist/tiff.spec,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/dist/tiff.spec,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# TIFF Software
#

2
dist/tiff.version vendored
View File

@@ -1 +1 @@
define TIFF_VNUM 3.4beta
define TIFF_VNUM "3.5.2 (release)"

View File

@@ -1,27 +0,0 @@
/Makefile.in/1.1.1.1/Tue Jul 27 21:50:27 1999//
D/images////
/contrib.html/1.4/Mon Aug 9 20:21:21 1999//
/document.html/1.4/Mon Aug 9 20:21:21 1999//
/intro.html/1.4/Mon Aug 9 20:21:21 1999//
/v3.4beta007.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta016.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta018.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta024.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta028.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta029.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta031.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta032.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta033.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta034.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta035.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.4beta036.html/1.3/Mon Aug 9 20:21:21 1999//
/v3.5.1.html/1.3/Mon Aug 9 20:21:21 1999//
/bugs.html/1.5/Fri Aug 13 19:30:57 1999//
/build.html/1.5/Fri Aug 13 19:30:57 1999//
/images.html/1.5/Fri Aug 13 19:30:57 1999//
/index.html/1.9/Fri Aug 13 19:30:57 1999//
/internals.html/1.4/Fri Aug 13 19:30:57 1999//
/libtiff.html/1.4/Fri Aug 13 19:30:57 1999//
/misc.html/1.4/Fri Aug 13 19:30:57 1999//
/support.html/1.5/Fri Aug 13 19:30:57 1999//
/tools.html/1.4/Fri Aug 13 19:30:57 1999//

View File

@@ -1 +0,0 @@
/usr/local/cvs/internal/libtiff/html

View File

@@ -1 +0,0 @@
/usr/local/cvs

View File

@@ -1,4 +1,4 @@
# $Header: /usr/local/cvs/internal/libtiff/html/Makefile.in,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
# $Header: /cvsroot/osrs/libtiff/html/Makefile.in,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $
#
# @WARNING@
#

Some files were not shown because too many files have changed in this diff Show More