tumble.c

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