45 char *infname1 = NULL,
51 int i, ni, n, nbimage=1;
53 int iflag1 = 0 , iflag2 = 0,
oflag = 0,
fd ;
57 rle_pixel **rows1, ** rows2, **rowsout, *point1, *point2, *pointout, *tab0;
63 #define ARG_FORMAT "% n%-nimage!d o%-outfile!s infile1%s infile2%s\n(\
64 \tInterpolate between two images or between one image and black.\n\
65 \t-n\tSpecify number of images to produce as output.\n\
66 \tIf neither input is specified, infile1 defaults to standard input.\n\
67 \tIf infile2 is not specified, fade from infile1 to black.\n\
68 \tTo fade from black to an image, specify infile1 as \"\" (empty string).\n\
69 \tBoth inputs cannot be standard input (-).)"
72 &nbimage, &nbimage, &
oflag, &outfname,
73 &infname1, &infname2 ) == 0 )
76 iflag1 = (infname1 && *infname1);
77 iflag2 = (infname2 && *infname2);
83 if ( ( infname1 && ! strcmp(infname1,
"-") ) &&
84 ( infname2 && ! strcmp(infname2,
"-") ) )
86 fprintf(stderr,
"%s : At most one input can be standard input\n",
92 if ( infname1 && *infname1 && ! outfname ) outfname = infname1 ;
93 else if ( infname2 && *infname2 && ! outfname ) outfname = infname2 ;
100 if ( !outfname || ! strcmp(outfname,
"-") )
102 outfname = (
char *)
malloc(80*
sizeof(
char)) ;
103 sprintf(outfname,
"i%-d.rle",getpid()) ;
112 fprintf(stderr,
"%s : Number of images too big\n",argv[0] ) ;
135 if ( iflag1 && iflag2 )
139 fprintf(stderr,
"%s : Input files not compatibles\n",argv[0]) ;
143 else if ( iflag1 )
rle_hdr_cp( &in1_hdr, &in2_hdr );
144 else if ( iflag2 )
rle_hdr_cp( &in2_hdr, &in1_hdr );
159 width = in1_hdr.
xmax + 1;
179 fprintf( stderr,
"%s : Memory allocation error.\n",argv[0] );
194 basenom = (rep=strrchr(outfname,
'/'))==NULL?outfname:rep+1 ;
198 if ( (rep=strrchr(basenom,
'.')) == NULL )
202 #ifdef FILE_NAME_14_CHARS
203 strncpy(extension,rep,4);
206 strcpy(extension, rep);
211 #ifdef FILE_NAME_14_CHARS
212 if ( ( strlen(basenom) - (i=strlen(extension)) ) > 10 )
213 *(basenom+10-
i) =
'\0' ;
216 for ( y = in1_hdr.
ymin; y <= in1_hdr.
ymax; y++ )
226 for ( i = 0 ; i < nbimage ; i++ )
228 if ( y == in1_hdr.
ymin )
230 sprintf(nom_sortie ,
"%s_%03d%s",outfname,i,extension) ;
232 if ( (
fd = open(nom_sortie, O_RDONLY ) ) != -1 )
235 fprintf(stderr,
"%s : File %s exists\n",
236 in1_hdr.
cmd, nom_sortie ) ;
241 fprintf(stderr,
"Create image %s\n",nom_sortie) ;
268 beta = (i+1) * 1.0/(nbimage + 1) ;
271 for ( (n = in1_hdr.
alpha?-1:0) ; n < in1_hdr.
ncolors ; n++ )
275 pointout = rowsout[n] ;
277 for ( x = in1_hdr.
xmin ; x <= in1_hdr.
xmax ; x++ )
279 *pointout++ = (
int) ( (*point1++) * alpha + beta * (*point2++) + 0.5 ) ;
285 if ( y == in1_hdr.
ymax )
289 fclose(out_hdr[i].rle_file) ;
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
int scanargs(int argc, char **argv, const char *format,...)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_puteof(rle_hdr *the_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
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)
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
#define RLE_CHECK_ALLOC(pgm, ptr, name)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)