int main( int argc, char ** argv ) { int anOverviews[100]; int nOverviewCount = 0; int bUseSubIFD = 0; TIFF *hTIFF; const char *pszResampling = "nearest"; /* -------------------------------------------------------------------- */ /* Usage: */ /* -------------------------------------------------------------------- */ if( argc < 2 ) { printf( "Usage: addtiffo [-r {nearest,average,mode}]\n" " tiff_filename [resolution_reductions]\n" "\n" "Example:\n" " %% addtifo abc.tif 2 4 8 16\n" ); exit( 1 ); } while( argv[1][0] == '-' ) { if( strcmp(argv[1],"-subifd") == 0 ) { bUseSubIFD = 1; argv++; argc--; } else if( strcmp(argv[1],"-r") == 0 ) { argv += 2; argc -= 2; pszResampling = *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, pszResampling, NULL, NULL ); TIFFClose( hTIFF ); /* -------------------------------------------------------------------- */ /* Optionally test for memory leaks. */ /* -------------------------------------------------------------------- */ #ifdef DBMALLOC malloc_dump(1); #endif exit( 0 ); }
int main( int argc, char ** argv ) { int anOverviews[100]; /* TODO: un-hardwire array length, flexible allocate */ int nOverviewCount = 0; int bUseSubIFD = 0; TIFF *hTIFF; const char *pszResampling = "nearest"; /* -------------------------------------------------------------------- */ /* Usage: */ /* -------------------------------------------------------------------- */ if( argc < 2 ) { printf( "Usage: addtiffo [-r {nearest,average,mode}]\n" " tiff_filename [resolution_reductions]\n" "\n" "Example:\n" " %% addtiffo abc.tif 2 4 8 16\n" ); return( 1 ); } #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while( argv[1][0] == '-' ) { if( strcmp(argv[1],"-subifd") == 0 ) { bUseSubIFD = 1; argv++; argc--; } else if( strcmp(argv[1],"-r") == 0 ) { argv += 2; argc -= 2; pszResampling = *argv; } else { fprintf( stderr, "Incorrect parameters\n" ); return( 1 ); } } /* TODO: resampling mode parameter needs to be encoded in an integer from this point on */ /* -------------------------------------------------------------------- */ /* Collect the user requested reduction factors. */ /* -------------------------------------------------------------------- */ #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while( nOverviewCount < argc - 2 && nOverviewCount < 100 ) { anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]); if( anOverviews[nOverviewCount] <= 0) { fprintf( stderr, "Incorrect parameters\n" ); return(1); } nOverviewCount++; } /* -------------------------------------------------------------------- */ /* Default to four overview levels. It would be nicer if it */ /* defaulted based on the size of the source image. */ /* -------------------------------------------------------------------- */ /* TODO: make it default 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] ); return( 1 ); } TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD, pszResampling, NULL, NULL ); TIFFClose( hTIFF ); /* -------------------------------------------------------------------- */ /* Optionally test for memory leaks. */ /* -------------------------------------------------------------------- */ #ifdef DBMALLOC malloc_dump(1); #endif return( 0 ); }
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 ); }