1.1 --- a/tumble.c Fri Mar 14 07:08:52 2003 +0000 1.2 +++ b/tumble.c Fri Mar 14 08:24:37 2003 +0000 1.3 @@ -2,7 +2,7 @@ 1.4 * tumble: build a PDF file from image files 1.5 * 1.6 * Main program 1.7 - * $Id: tumble.c,v 1.33 2003/03/13 03:42:46 eric Exp $ 1.8 + * $Id: tumble.c,v 1.34 2003/03/14 00:24:37 eric Exp $ 1.9 * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 1.10 * 1.11 * This program is free software; you can redistribute it and/or modify 1.12 @@ -227,14 +227,6 @@ 1.13 } 1.14 1.15 1.16 -void process_page_numbers (int page_index, 1.17 - int count, 1.18 - int base, 1.19 - page_label_t *page_label) 1.20 -{ 1.21 -} 1.22 - 1.23 - 1.24 /* frees original! */ 1.25 static Bitmap *resize_bitmap (Bitmap *src, 1.26 double x_resolution, 1.27 @@ -287,12 +279,9 @@ 1.28 } 1.29 1.30 1.31 -bool process_tiff_page (int image, /* range 1 .. n */ 1.32 - input_attributes_t input_attributes, 1.33 - bookmark_t *bookmarks) 1.34 +static pdf_page_handle process_tiff_page (int image, /* range 1 .. n */ 1.35 + input_attributes_t input_attributes) 1.36 { 1.37 - int result = 0; 1.38 - 1.39 uint32_t image_length, image_width; 1.40 uint32_t dest_image_length, dest_image_width; 1.41 #ifdef CHECK_DEPTH 1.42 @@ -315,7 +304,7 @@ 1.43 1.44 int row; 1.45 1.46 - pdf_page_handle page; 1.47 + pdf_page_handle page = NULL; 1.48 1.49 if (! TIFFSetDirectory (in, image - 1)) 1.50 { 1.51 @@ -473,29 +462,22 @@ 1.52 0); /* BlackIs1 */ 1.53 #endif 1.54 1.55 - while (bookmarks) 1.56 - { 1.57 - /* $$$ need to handle level here */ 1.58 - pdf_new_bookmark (NULL, bookmarks->name, 0, page); 1.59 - bookmarks = bookmarks->next; 1.60 - } 1.61 - 1.62 - result = 1; 1.63 + if (bitmap) 1.64 + free_bitmap (bitmap); 1.65 + return (page); 1.66 1.67 fail: 1.68 if (bitmap) 1.69 free_bitmap (bitmap); 1.70 1.71 - return (result); 1.72 + return (NULL); 1.73 } 1.74 1.75 1.76 #if 0 1.77 -bool process_jpeg_page (int image, /* range 1 .. n */ 1.78 - input_attributes_t input_attributes, 1.79 - bookmark_t *bookmarks) 1.80 +pdf_page_handle process_jpeg_page (int image, /* range 1 .. n */ 1.81 + input_attributes_t input_attributes) 1.82 { 1.83 - int result = 0; 1.84 FILE *f; 1.85 pdf_page_handle page; 1.86 1.87 @@ -510,20 +492,36 @@ 1.88 width_points, height_points, 1.89 f); 1.90 1.91 - return (result); 1.92 + return (page); 1.93 } 1.94 #endif 1.95 1.96 1.97 bool process_page (int image, /* range 1 .. n */ 1.98 input_attributes_t input_attributes, 1.99 - bookmark_t *bookmarks) 1.100 + bookmark_t *bookmarks, 1.101 + page_label_t *page_label) 1.102 { 1.103 - int result = 0; 1.104 + pdf_page_handle page; 1.105 + 1.106 + page = process_tiff_page (image, input_attributes); 1.107 1.108 - result = process_tiff_page (image, input_attributes, bookmarks); 1.109 + while (bookmarks) 1.110 + { 1.111 + /* $$$ need to handle level here */ 1.112 + pdf_new_bookmark (NULL, bookmarks->name, 0, page); 1.113 + bookmarks = bookmarks->next; 1.114 + } 1.115 1.116 - return (result); 1.117 + if (page_label) 1.118 + pdf_new_page_label (out->pdf, 1.119 + page_label->page_index, 1.120 + page_label->base, 1.121 + page_label->count, 1.122 + page_label->style, 1.123 + page_label->prefix); 1.124 + 1.125 + return (page != NULL); 1.126 } 1.127 1.128 1.129 @@ -625,7 +623,8 @@ 1.130 in_fn [i], 1.131 ip); 1.132 if (! process_page (ip, input_attributes, 1.133 - bookmark_fmt ? & bookmark : NULL)) 1.134 + bookmark_fmt ? & bookmark : NULL, 1.135 + NULL)) 1.136 fatal (3, "error processing page %d of input file \"%s\"\n", ip, in_fn [i]); 1.137 if (last_tiff_page ()) 1.138 break;