diff options
Diffstat (limited to 'tiff/tools/tiffdither.c')
-rw-r--r-- | tiff/tools/tiffdither.c | 92 |
1 files changed, 50 insertions, 42 deletions
diff --git a/tiff/tools/tiffdither.c b/tiff/tools/tiffdither.c index a9d1b7c5..062fd608 100644 --- a/tiff/tools/tiffdither.c +++ b/tiff/tools/tiffdither.c @@ -23,6 +23,7 @@ */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -32,10 +33,6 @@ # include <unistd.h> #endif -#ifdef NEED_LIBPORT -# include "libport.h" -#endif - #include "tiffio.h" #include "tiffiop.h" @@ -52,8 +49,8 @@ #define CopyField(tag, v) \ if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) -uint32 imagewidth; -uint32 imagelength; +uint32_t imagewidth; +uint32_t imagelength; int threshold = 128; static void usage(int code); @@ -69,8 +66,8 @@ fsdither(TIFF* in, TIFF* out) short *thisline, *nextline, *tmpptr; register unsigned char *outptr; register short *thisptr, *nextptr; - register uint32 i, j; - uint32 imax, jmax; + register uint32_t i, j; + uint32_t imax, jmax; int lastline, lastpixel; int bit; tsize_t outlinesize; @@ -156,9 +153,9 @@ fsdither(TIFF* in, TIFF* out) return errcode; } -static uint16 compression = COMPRESSION_PACKBITS; -static uint16 predictor = 0; -static uint32 group3options = 0; +static uint16_t compression = COMPRESSION_PACKBITS; +static uint16_t predictor = 0; +static uint32_t group3options = 0; static void processG3Options(char* cp) @@ -209,11 +206,11 @@ int main(int argc, char* argv[]) { TIFF *in, *out; - uint16 samplesperpixel, bitspersample = 1, shortv; + uint16_t samplesperpixel, bitspersample = 1, shortv; float floatv; char thing[1024]; - uint32 rowsperstrip = (uint32) -1; - uint16 fillorder = 0; + uint32_t rowsperstrip = (uint32_t) -1; + uint16_t fillorder = 0; int c; #if !HAVE_DECL_OPTARG extern int optind; @@ -246,9 +243,12 @@ main(int argc, char* argv[]) break; case 'h': usage(EXIT_SUCCESS); + /*NOTREACHED*/ + break; case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + break; } if (argc - optind < 2) usage(EXIT_FAILURE); @@ -305,41 +305,49 @@ main(int argc, char* argv[]) return (EXIT_SUCCESS); } -static const char* stuff[] = { -"usage: tiffdither [options] input.tif output.tif", -"where options are:", -" -r # make each strip have no more than # rows", -" -t # set the threshold value for dithering (default 128)", -" -f lsb2msb force lsb-to-msb FillOrder for output", -" -f msb2lsb force msb-to-lsb FillOrder for output", -" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", -" -c zip[:opts] compress output with deflate encoding", -" -c packbits compress output with packbits encoding", -" -c g3[:opts] compress output with CCITT Group 3 encoding", -" -c g4 compress output with CCITT Group 4 encoding", -" -c none use no compression algorithm on output", -"", -"Group 3 options:", -" 1d use default CCITT Group 3 1D-encoding", -" 2d use optional CCITT Group 3 2D-encoding", -" fill byte-align EOL codes", -"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", -"", -"LZW and deflate options:", -" # set predictor value", -"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", -NULL -}; +static const char usage_info[] = +"Convert a greyscale image to bilevel using dithering\n\n" +"usage: tiffdither [options] input.tif output.tif\n" +"where options are:\n" +" -r # make each strip have no more than # rows\n" +" -t # set the threshold value for dithering (default 128)\n" +" -f lsb2msb force lsb-to-msb FillOrder for output\n" +" -f msb2lsb force msb-to-lsb FillOrder for output\n" +"\n" +#ifdef LZW_SUPPORT +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" +" # set predictor value\n" +" For example, -c lzw:2 for LZW-encoded data with horizontal differencing\n" +#endif +#ifdef ZIP_SUPPORT +" -c zip[:opts] compress output with deflate encoding\n" +" # set predictor value\n" +#endif +#ifdef PACKBITS_SUPPORT +" -c packbits compress output with packbits encoding\n" +#endif +#ifdef CCITT_SUPPORT +" -c g3[:opts] compress output with CCITT Group 3 encoding\n" +" Group 3 options:\n" +" 1d use default CCITT Group 3 1D-encoding\n" +" 2d use optional CCITT Group 3 2D-encoding\n" +" fill byte-align EOL codes\n" +" For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned EOLs\n" +" -c g4 compress output with CCITT Group 4 encoding\n" +#endif +#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) +" -c none use no compression algorithm on output\n" +#endif +"\n" +; static void usage(int code) { - int i; FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); + fprintf(out, "%s", usage_info); exit(code); } |