Initial import
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/libtiff@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# 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
|
||||
CFLAGS = -O -I$(LIBTIFF_DIR)
|
||||
LIBS = $(LIBTIFF_DIR)/libtiff.a -lm
|
||||
|
||||
addtiffo: addtiffo.o tif_overview.o tif_ovrcache.o
|
||||
$(CXX) $(CFLAGS) addtiffo.o tif_overview.o tif_ovrcache.o \
|
||||
$(LIBS) -o addtiffo
|
||||
|
||||
|
||||
addtiffo.o: addtiffo.c
|
||||
$(CC) -c $(CFLAGS) addtiffo.c
|
||||
|
||||
tif_overview.o: tif_overview.c
|
||||
$(CC) -c $(CFLAGS) tif_overview.c
|
||||
|
||||
tif_ovrcache.o: tif_ovrcache.c
|
||||
$(CC) -c $(CFLAGS) tif_ovrcache.c
|
||||
|
||||
clean:
|
||||
rm *.o addtiffo
|
||||
Executable
+27
@@ -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)\libtiff.lib
|
||||
|
||||
addtiffo: addtiffo.obj tif_overview.obj tif_ovrcache.obj
|
||||
$(CC) $(CFLAGS) addtiffo.obj tif_overview.obj tif_ovrcache.obj \
|
||||
$(LIBS) /Feaddtiffo.exe
|
||||
|
||||
|
||||
addtiffo.obj: addtiffo.c
|
||||
$(CC) -c $(CFLAGS) addtiffo.c
|
||||
|
||||
tif_overview.obj: tif_overview.c
|
||||
$(CPPC) -c $(CFLAGS) tif_overview.c
|
||||
|
||||
tif_ovrcache.obj: tif_ovrcache.c
|
||||
$(CPPC) -c $(CFLAGS) tif_ovrcache.c
|
||||
|
||||
clean:
|
||||
del *.obj addtiffo.exe
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
/******************************************************************************
|
||||
* $Id: addtiffo.c,v 1.1.1.1 2000/06/24 19:10:17 tshead 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.1.1 2000/06/24 19:10:17 tshead
|
||||
* * Initial import of libtiff-3.5.5
|
||||
*
|
||||
* Revision 1.2 2000/01/28 15:36:38 warmerda
|
||||
* pass TIFF handle instead of filename to overview builder
|
||||
*
|
||||
* 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( TIFF *, int, int *, int );
|
||||
|
||||
/************************************************************************/
|
||||
/* main() */
|
||||
/************************************************************************/
|
||||
|
||||
int main( int argc, char ** argv )
|
||||
|
||||
{
|
||||
int anOverviews[100];
|
||||
int nOverviewCount = 0;
|
||||
int bUseSubIFD = 0;
|
||||
TIFF *hTIFF;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* 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. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
hTIFF = TIFFOpen( argv[1], "r+" );
|
||||
if( hTIFF == NULL )
|
||||
{
|
||||
fprintf( stderr, "TIFFOpen(%s) failed.\n", argv[1] );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD );
|
||||
|
||||
TIFFClose( hTIFF );
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Optionally test for memory leaks. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
#ifdef DBMALLOC
|
||||
malloc_dump(1);
|
||||
#endif
|
||||
|
||||
exit( 0 );
|
||||
}
|
||||
Executable
+145
@@ -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.
|
||||
Reference in New Issue
Block a user