Tue, 01 Jan 2002 05:41:03 +0000
fix bugs. copy samples per pixel tag.
t2p.c | file | annotate | diff | revisions | |
tumble.c | file | annotate | diff | revisions |
1.1 --- a/t2p.c Tue Jan 01 05:02:44 2002 +0000 1.2 +++ b/t2p.c Tue Jan 01 05:41:03 2002 +0000 1.3 @@ -1,7 +1,11 @@ 1.4 /* 1.5 - * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 1.6 + * tiff2pdf: Create a PDF file from the contents of one or more 1.7 + * TIFF bilevel image files. The images in the resulting 1.8 + * PDF file will be compressed using ITU-T T.6 (G4) fax 1.9 + * encoding. 1.10 + * 1.11 * Main program 1.12 - * $Id: t2p.c,v 1.9 2001/12/31 21:02:44 eric Exp $ 1.13 + * $Id: t2p.c,v 1.10 2001/12/31 21:41:03 eric Exp $ 1.14 * Copyright 2001 Eric Smith <eric@brouhaha.com> 1.15 * 1.16 * This program is free software; you can redistribute it and/or modify 1.17 @@ -123,7 +127,7 @@ 1.18 return (1); 1.19 } 1.20 o = calloc (1, sizeof (output_file_t)); 1.21 - if (! 0) 1.22 + if (! o) 1.23 { 1.24 fprintf (stderr, "can't calloc output file struct for '%s'\n", name); 1.25 return (0); 1.26 @@ -167,10 +171,14 @@ 1.27 input_attributes_t input_attributes, 1.28 bookmark_t *bookmarks) 1.29 { 1.30 + int result = 0; 1.31 + 1.32 u32 image_length, image_width; 1.33 #ifdef CHECK_DEPTH 1.34 u32 image_depth; 1.35 #endif 1.36 + 1.37 + u16 samples_per_pixel; 1.38 u16 bits_per_sample; 1.39 u16 planar_config; 1.40 u16 resolution_unit; 1.41 @@ -207,6 +215,13 @@ 1.42 fprintf (stderr, "can't get image width\n"); 1.43 goto fail; 1.44 } 1.45 + 1.46 + if (1 != TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, & samples_per_pixel)) 1.47 + { 1.48 + fprintf (stderr, "can't get samples per pixel\n"); 1.49 + goto fail; 1.50 + } 1.51 + 1.52 #ifdef CHECK_DEPTH 1.53 if (1 != TIFFGetField (in, TIFFTAG_IMAGEDEPTH, & image_depth)) 1.54 { 1.55 @@ -245,6 +260,12 @@ 1.56 printf ("resolution unit %u, x resolution %f, y resolution %f\n", 1.57 resolution_unit, x_resolution, y_resolution); 1.58 1.59 + if (samples_per_pixel != 1) 1.60 + { 1.61 + fprintf (stderr, "samples per pixel %u, must be 1\n", samples_per_pixel); 1.62 + goto fail; 1.63 + } 1.64 + 1.65 #ifdef CHECK_DEPTH 1.66 if (image_depth != 1) 1.67 { 1.68 @@ -289,6 +310,7 @@ 1.69 TIFFSetField (tiff_temp, TIFFTAG_XRESOLUTION, x_resolution); 1.70 TIFFSetField (tiff_temp, TIFFTAG_YRESOLUTION, y_resolution); 1.71 1.72 + TIFFSetField (tiff_temp, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); 1.73 TIFFSetField (tiff_temp, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 1.74 TIFFSetField (tiff_temp, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); 1.75 TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); 1.76 @@ -309,8 +331,8 @@ 1.77 _TIFFfree (buffer); 1.78 TIFFClose (tiff_temp); 1.79 1.80 - height_points = (image_width / x_resolution) * POINTS_PER_INCH; 1.81 - width_points = (image_length / y_resolution) * POINTS_PER_INCH; 1.82 + width_points = (image_width / x_resolution) * POINTS_PER_INCH; 1.83 + height_points = (image_length / y_resolution) * POINTS_PER_INCH; 1.84 1.85 if ((height_points > PAGE_MAX_POINTS) || (width_points > PAGE_MAX_POINTS)) 1.86 { 1.87 @@ -332,12 +354,12 @@ 1.88 tiff_temp_fn, 1.89 panda_image_tiff); 1.90 1.91 - unlink (tiff_temp_fn); 1.92 - 1.93 - return (1); 1.94 + result = 1; 1.95 1.96 fail: 1.97 - return (0); 1.98 + if (tiff_temp_fd) 1.99 + unlink (tiff_temp_fn); 1.100 + return (result); 1.101 } 1.102 1.103
2.1 --- a/tumble.c Tue Jan 01 05:02:44 2002 +0000 2.2 +++ b/tumble.c Tue Jan 01 05:41:03 2002 +0000 2.3 @@ -1,7 +1,11 @@ 2.4 /* 2.5 - * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 2.6 + * tiff2pdf: Create a PDF file from the contents of one or more 2.7 + * TIFF bilevel image files. The images in the resulting 2.8 + * PDF file will be compressed using ITU-T T.6 (G4) fax 2.9 + * encoding. 2.10 + * 2.11 * Main program 2.12 - * $Id: tumble.c,v 1.9 2001/12/31 21:02:44 eric Exp $ 2.13 + * $Id: tumble.c,v 1.10 2001/12/31 21:41:03 eric Exp $ 2.14 * Copyright 2001 Eric Smith <eric@brouhaha.com> 2.15 * 2.16 * This program is free software; you can redistribute it and/or modify 2.17 @@ -123,7 +127,7 @@ 2.18 return (1); 2.19 } 2.20 o = calloc (1, sizeof (output_file_t)); 2.21 - if (! 0) 2.22 + if (! o) 2.23 { 2.24 fprintf (stderr, "can't calloc output file struct for '%s'\n", name); 2.25 return (0); 2.26 @@ -167,10 +171,14 @@ 2.27 input_attributes_t input_attributes, 2.28 bookmark_t *bookmarks) 2.29 { 2.30 + int result = 0; 2.31 + 2.32 u32 image_length, image_width; 2.33 #ifdef CHECK_DEPTH 2.34 u32 image_depth; 2.35 #endif 2.36 + 2.37 + u16 samples_per_pixel; 2.38 u16 bits_per_sample; 2.39 u16 planar_config; 2.40 u16 resolution_unit; 2.41 @@ -207,6 +215,13 @@ 2.42 fprintf (stderr, "can't get image width\n"); 2.43 goto fail; 2.44 } 2.45 + 2.46 + if (1 != TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, & samples_per_pixel)) 2.47 + { 2.48 + fprintf (stderr, "can't get samples per pixel\n"); 2.49 + goto fail; 2.50 + } 2.51 + 2.52 #ifdef CHECK_DEPTH 2.53 if (1 != TIFFGetField (in, TIFFTAG_IMAGEDEPTH, & image_depth)) 2.54 { 2.55 @@ -245,6 +260,12 @@ 2.56 printf ("resolution unit %u, x resolution %f, y resolution %f\n", 2.57 resolution_unit, x_resolution, y_resolution); 2.58 2.59 + if (samples_per_pixel != 1) 2.60 + { 2.61 + fprintf (stderr, "samples per pixel %u, must be 1\n", samples_per_pixel); 2.62 + goto fail; 2.63 + } 2.64 + 2.65 #ifdef CHECK_DEPTH 2.66 if (image_depth != 1) 2.67 { 2.68 @@ -289,6 +310,7 @@ 2.69 TIFFSetField (tiff_temp, TIFFTAG_XRESOLUTION, x_resolution); 2.70 TIFFSetField (tiff_temp, TIFFTAG_YRESOLUTION, y_resolution); 2.71 2.72 + TIFFSetField (tiff_temp, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); 2.73 TIFFSetField (tiff_temp, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 2.74 TIFFSetField (tiff_temp, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); 2.75 TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); 2.76 @@ -309,8 +331,8 @@ 2.77 _TIFFfree (buffer); 2.78 TIFFClose (tiff_temp); 2.79 2.80 - height_points = (image_width / x_resolution) * POINTS_PER_INCH; 2.81 - width_points = (image_length / y_resolution) * POINTS_PER_INCH; 2.82 + width_points = (image_width / x_resolution) * POINTS_PER_INCH; 2.83 + height_points = (image_length / y_resolution) * POINTS_PER_INCH; 2.84 2.85 if ((height_points > PAGE_MAX_POINTS) || (width_points > PAGE_MAX_POINTS)) 2.86 { 2.87 @@ -332,12 +354,12 @@ 2.88 tiff_temp_fn, 2.89 panda_image_tiff); 2.90 2.91 - unlink (tiff_temp_fn); 2.92 - 2.93 - return (1); 2.94 + result = 1; 2.95 2.96 fail: 2.97 - return (0); 2.98 + if (tiff_temp_fd) 2.99 + unlink (tiff_temp_fn); 2.100 + return (result); 2.101 } 2.102 2.103