88 int *image_list = NULL;
108 "% i%-infile%s o%-outfile!s v%- image-numbers!*d\n(\
109 \tSelect images from a file.\n\
110 \t-v\tEcho list of images selected.\n\
111 \tPositive numbers (1,...) select individual images. A negative\n\
112 \tnumber indicates a range from the previous number (or from 1 if \n\
113 \tat the beginning of the list), thus 3 -8 selects images 3, 4, 5,\n\
114 \t6, 7, 8. Zero means \"through the last\", so 5 0 selects images\n\
115 \t5 through the last one in the file. Image selections may be given in\n\
116 \tany order, they will be sorted and merged by the program.)",
118 &nimage, &image_list ) == 0 )
123 fprintf( stderr,
"%s: No images selected.\n",
my_name );
131 for ( i = 0; i < nimage; i++ )
133 if ( image_list[i] < 0 )
135 image_list[
i] = abs( image_list[i] );
139 j = image_list[i-1] + 1;
140 for ( ; j <= image_list[
i]; j++ )
141 insert( &sorted_list, j, nsorted++ );
143 else if ( image_list[i] == 0 )
148 thrulast = image_list[i-1];
151 insert( &sorted_list, image_list[i], nsorted++ );
156 for ( i = nsorted - 1; i >= 0 && sorted_list[
i] >= thrulast; i-- )
163 fprintf( stderr,
"%s: Selecting images",
my_name );
164 for ( i = 0; i < nsorted; i++ )
167 fprintf( stderr,
"\n\t" );
168 fprintf( stderr,
"%d%s", sorted_list[i],
169 ((i < nsorted - 1) || thrulast >= 0) ?
", " :
"" );
172 fprintf( stderr,
"%s%d - last", i % 14 == 0 ?
"\n\t" :
"",
174 putc(
'\n', stderr );
203 while ( i < nsorted && rle_cnt > sorted_list[i] )
206 if ( thrulast < 0 && i >= nsorted )
209 if ( ! (thrulast >= 0 && rle_cnt >= thrulast) &&
210 (i >= nsorted || rle_cnt < sorted_list[i]) )
230 rle_cp( &in_hdr, &out_hdr );
int scanargs(int argc, char **argv, const char *format,...)
void rle_cp(rle_hdr *in_hdr, rle_hdr *out_hdr)
static const char * my_name
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_get_setup(rle_hdr *the_hdr)
int rle_get_error(int code, const char *pgmname, const char *fname)
unsigned int rle_getskip(rle_hdr *the_hdr)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
char * cmd_name(char **argv)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)