1.1 diff -r ba8313d18bd3 -r c904ffd6a1cf t2p.c 1.2 --- a/t2p.c Tue Jan 01 05:02:44 2002 +0000 1.3 +++ b/t2p.c Tue Jan 01 05:41:03 2002 +0000 1.4 @@ -1,7 +1,11 @@ 1.5 /* 1.6 - * tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4 1.7 + * tiff2pdf: Create a PDF file from the contents of one or more 1.8 + * TIFF bilevel image files. The images in the resulting 1.9 + * PDF file will be compressed using ITU-T T.6 (G4) fax 1.10 + * encoding. 1.11 + * 1.12 * Main program 1.13 - * $Id: t2p.c,v 1.9 2001/12/31 21:02:44 eric Exp $ 1.14 + * $Id: t2p.c,v 1.10 2001/12/31 21:41:03 eric Exp $ 1.15 * Copyright 2001 Eric Smith <eric@brouhaha.com> 1.16 * 1.17 * This program is free software; you can redistribute it and/or modify 1.18 @@ -123,7 +127,7 @@ 1.19 return (1); 1.20 } 1.21 o = calloc (1, sizeof (output_file_t)); 1.22 - if (! 0) 1.23 + if (! o) 1.24 { 1.25 fprintf (stderr, "can't calloc output file struct for '%s'\n", name); 1.26 return (0); 1.27 @@ -167,10 +171,14 @@ 1.28 input_attributes_t input_attributes, 1.29 bookmark_t *bookmarks) 1.30 { 1.31 + int result = 0; 1.32 + 1.33 u32 image_length, image_width; 1.34 #ifdef CHECK_DEPTH 1.35 u32 image_depth; 1.36 #endif 1.37 + 1.38 + u16 samples_per_pixel; 1.39 u16 bits_per_sample; 1.40 u16 planar_config; 1.41 u16 resolution_unit; 1.42 @@ -207,6 +215,13 @@ 1.43 fprintf (stderr, "can't get image width\n"); 1.44 goto fail; 1.45 } 1.46 + 1.47 + if (1 != TIFFGetField (in, TIFFTAG_SAMPLESPERPIXEL, & samples_per_pixel)) 1.48 + { 1.49 + fprintf (stderr, "can't get samples per pixel\n"); 1.50 + goto fail; 1.51 + } 1.52 + 1.53 #ifdef CHECK_DEPTH 1.54 if (1 != TIFFGetField (in, TIFFTAG_IMAGEDEPTH, & image_depth)) 1.55 { 1.56 @@ -245,6 +260,12 @@ 1.57 printf ("resolution unit %u, x resolution %f, y resolution %f\n", 1.58 resolution_unit, x_resolution, y_resolution); 1.59 1.60 + if (samples_per_pixel != 1) 1.61 + { 1.62 + fprintf (stderr, "samples per pixel %u, must be 1\n", samples_per_pixel); 1.63 + goto fail; 1.64 + } 1.65 + 1.66 #ifdef CHECK_DEPTH 1.67 if (image_depth != 1) 1.68 { 1.69 @@ -289,6 +310,7 @@ 1.70 TIFFSetField (tiff_temp, TIFFTAG_XRESOLUTION, x_resolution); 1.71 TIFFSetField (tiff_temp, TIFFTAG_YRESOLUTION, y_resolution); 1.72 1.73 + TIFFSetField (tiff_temp, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel); 1.74 TIFFSetField (tiff_temp, TIFFTAG_BITSPERSAMPLE, bits_per_sample); 1.75 TIFFSetField (tiff_temp, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); 1.76 TIFFSetField (tiff_temp, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); 1.77 @@ -309,8 +331,8 @@ 1.78 _TIFFfree (buffer); 1.79 TIFFClose (tiff_temp); 1.80 1.81 - height_points = (image_width / x_resolution) * POINTS_PER_INCH; 1.82 - width_points = (image_length / y_resolution) * POINTS_PER_INCH; 1.83 + width_points = (image_width / x_resolution) * POINTS_PER_INCH; 1.84 + height_points = (image_length / y_resolution) * POINTS_PER_INCH; 1.85 1.86 if ((height_points > PAGE_MAX_POINTS) || (width_points > PAGE_MAX_POINTS)) 1.87 { 1.88 @@ -332,12 +354,12 @@ 1.89 tiff_temp_fn, 1.90 panda_image_tiff); 1.91 1.92 - unlink (tiff_temp_fn); 1.93 - 1.94 - return (1); 1.95 + result = 1; 1.96 1.97 fail: 1.98 - return (0); 1.99 + if (tiff_temp_fd) 1.100 + unlink (tiff_temp_fn); 1.101 + return (result); 1.102 } 1.103 1.104