36 #define MAX(i,j) ( (i) > (j) ? (i) : (j) )
37 #define MIN(i,j) ( (i) < (j) ? (i) : (j) )
52 #define SUBTRACT_OP 10
54 #define IN_WINDOW(y,wind) ((y >= wind.ymin) && (y <= wind.ymax))
71 FILE *outfile = stdout;
73 char *out_fname = NULL;
85 int oflag = 0, op_code;
86 char *Afilename = NULL, *Bfilename = NULL, *op_name = NULL;
113 if (
scanargs(argc
, argv
, "% o%-outfile!s Afile!s op!s Bfile!s",
114 &oflag
, &out_fname
, &Afilename
, &op_name
, &Bfilename
) == 0)
121 if (strcmp(op_name, comp_ops[i]) == 0) op_code = i;
125 fprintf(stderr,
"%s: Invalid compositor operation\n", op_name);
136 fprintf(stderr,
"Can't read both inputs from stdin!\n");
141 for ( rle_cnt = 0; ; rle_cnt++ )
145 err_fname = Afilename;
150 err_fname = Bfilename;
205 bzero( Ascanline[i], out_hdr
.xmax + 1 );
206 bzero( Bscanline[i], out_hdr
.xmax + 1 );
237 for ( j = out_hdr
.ymin; j <= out_hdr
.ymax ; j++)
313 Ascan = &Ascanline[k][out_hdr
.xmin];
314 Bscan = &Bscanline[k][out_hdr
.xmin];
315 scan = &scanout[k][out_hdr
.xmin];
318 i++, Ascan++, Bscan++, scan++)
329 else if (Aalph == 255)
332 int_result = ( *Ascan * 255 +
333 *Bscan * (255 - Aalph))/255;
337 int_result = ( *Ascan * Balph ) /255;
341 int_result = ( *Ascan * (255 - Balph) ) /255;
345 int_result = ( *Ascan * Balph +
346 *Bscan * (255 - Aalph) )/255;
350 int_result = (*Ascan * (255 - Balph) + *Bscan *
355 int_result = ((temp = ((
int)*Ascan + (
int)*Bscan))
366 int_result = ((temp = ((
int)*Ascan - (
int)*Bscan))
371 int_result = ((temp = ((
int)*Ascan + (
int)*Bscan))
372 > 255) ? temp - 256: temp;
375 int_result = ((temp = ((
int)*Ascan - (
int)*Bscan))
376 < 0) ? 256 + temp : temp;
379 int_result = abs((
int)*Ascan - (
int)*Bscan);
383 *scan = (
rle_pixel) ((int_result > 255) ? 255 :
384 ((int_result < 0) ? 0 : int_result));
391 rows[i] = &scanout[i-1][out_hdr
.xmin];
434 bzero( scanline[i], the_hdr
->xmax );
456 for( j = 0; j < the_hdr
->ncolors && no_backgr == 0; j++)
457 no_backgr = no_backgr ||
474 rle_hdr * in_hdr, * out_hdr;
483 int chan, fakeruns, xlen, xmin;
510 if (*num_skip == 32768)
539 for (chan = 0; chan < in_hdr
->ncolors; chan++ )
542 for (i = 0; i < out_nraw[chan]; i++)
544 register rle_op *rp = &out_raw[chan][i];
547 if ( rp->u.run_val != bgc)
562 if ( rp->u.pixels[j] != bgc )
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
#define RLE_SET_BIT(glob, bit)
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
void rle_freeraw(rle_hdr *the_hdr, scanraw, nraw)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
int rle_raw_alloc(rle_hdr *the_hdr, rle_op ***scanp, int **nrawp)
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
rle_pixel * non_zero_pixels
void rle_putraw(rle_op **scanraw, int *nraw, rle_hdr *the_hdr)
int rle_getrow(rle_hdr *the_hdr, scanline)
int rle_get_error(int code, const char *pgmname, const char *fname)
void rle_rawtorow(rle_hdr *the_hdr, rle_op **raw, int *nraw, rle_pixel **outrows)
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
#define IN_WINDOW(y, wind)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
void copy_scanline(int ypos, int copy_flag)
void rle_skiprow(rle_hdr *the_hdr, int nrow)
void rle_put_setup(rle_hdr *the_hdr)
void get_scanline(rle_hdr *the_hdr, rle_pixel **scanline, int *num_skip, rle_op **tmp_raw, int *tmp_nraw)
void rle_raw_free(rle_hdr *the_hdr, rle_op **scanp, nrawp)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
unsigned int rle_getraw(rle_hdr *the_hdr, scanraw, nraw)
#define RLE_CHECK_ALLOC(pgm, ptr, name)