--- ray/src/px/x11image.c 1992/10/12 12:59:22 2.13 +++ ray/src/px/x11image.c 1992/10/22 17:51:05 2.16 @@ -109,10 +109,9 @@ extern long ftell(); extern char *malloc(), *calloc(); -extern double pow(), log(); - Display *thedisplay; + main(argc, argv) int argc; char *argv[]; @@ -308,20 +307,6 @@ char *err; } -eputs(s) -char *s; -{ - fputs(s, stderr); -} - - -quit(code) -int code; -{ - exit(code); -} - - static int viscmp(v1,v2) /* compare visual to see which is better, descending */ register XVisualInfo *v1, *v2; @@ -740,7 +725,7 @@ COLOR clr; return(-1); if (left == ll && right == lr && top == lt && bottom == lb) { copycolor(clr, lc); - return; + return(0); } for (y = top; y < bottom; y++) { if (getscan(y) == -1) @@ -769,10 +754,9 @@ getmono() /* get monochrome data */ quiterr("out of memory in getmono"); dp = ourdata - 1; for (y = 0; y < ymax; y++) { - if (getscan(y) < 0) - quiterr("seek error in getmono"); - normcolrs(scanline, xmax, scale); + getscan(y); add2icon(y, scanline); + normcolrs(scanline, xmax, scale); err = 0; for (x = 0; x < xmax; x++) { if (!(x&7)) @@ -798,6 +782,8 @@ COLR *scan; static short cerr[ICONSIZ]; static int ynext; static char *dp; + double sf; + COLOR col; register int err; register int x, ti; int errp; @@ -822,13 +808,17 @@ COLR *scan; } if (y < ynext*ymax/iconheight) /* skip this one */ return; + sf = pow(2.0, (double)(scale+8)); err = 0; for (x = 0; x < iconwidth; x++) { if (!(x&7)) *++dp = 0; errp = err; ti = x*xmax/iconwidth; - err += normbright(scan[ti]) + cerr[x]; + colr_color(col, scan[ti]); + ti = sf*bright(col); + if (ti > 255) ti = 255; + err += ti + cerr[x]; if (err > 127) err -= 255; else @@ -850,12 +840,11 @@ getfull() /* get full (24-bit) data */ /* read and convert file */ dp = (unsigned long *)ourdata; for (y = 0; y < ymax; y++) { - if (getscan(y) < 0) - quiterr("seek error in getfull"); + getscan(y); + add2icon(y, scanline); if (scale) shiftcolrs(scanline, xmax, scale); colrs_gambs(scanline, xmax); - add2icon(y, scanline); if (ourras->image->blue_mask & 1) for (x = 0; x < xmax; x++) *dp++ = scanline[x][RED] << 16 | @@ -880,12 +869,11 @@ getgrey() /* get greyscale data */ /* read and convert file */ dp = ourdata; for (y = 0; y < ymax; y++) { - if (getscan(y) < 0) - quiterr("seek error in getgrey"); + getscan(y); + add2icon(y, scanline); if (scale) shiftcolrs(scanline, xmax, scale); colrs_gambs(scanline, xmax); - add2icon(y, scanline); if (maxcolors < 256) for (x = 0; x < xmax; x++) *dp++ = ((long)normbright(scanline[x]) * @@ -896,7 +884,7 @@ getgrey() /* get greyscale data */ } for (x = 0; x < maxcolors; x++) clrtab[x][RED] = clrtab[x][GRN] = - clrtab[x][BLU] = (x*256+maxcolors/2)/maxcolors; + clrtab[x][BLU] = ((long)x*256+maxcolors/2)/maxcolors; } @@ -910,10 +898,10 @@ getmapped() /* get color-mapped data */ for (y = 0; y < ymax; y++) { if (getscan(y) < 0) quiterr("seek error in getmapped"); + add2icon(y, scanline); if (scale) shiftcolrs(scanline, xmax, scale); colrs_gambs(scanline, xmax); - add2icon(y, scanline); cnt_colrs(scanline, xmax); } /* map pixels */