--- ray/src/px/x11image.c 1992/10/12 16:24:02 2.14 +++ ray/src/px/x11image.c 1993/02/04 21:00:32 2.19 @@ -614,6 +614,13 @@ XKeyPressedEvent *ekey; make_rpixmap(ourras, wind); redraw(0, 0, width, height); return(0); + case '0': /* recenter origin */ + if (xoff == 0 & yoff == 0) + return(0); + xoff = yoff = 0; + XClearWindow(thedisplay, wind); + redraw(0, 0, width, height); + return(0); case ' ': /* clear */ redraw(box.xmin, box.ymin, box.xsiz, box.ysiz); return(0); @@ -725,7 +732,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) @@ -754,10 +761,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)) @@ -783,6 +789,7 @@ COLR *scan; static short cerr[ICONSIZ]; static int ynext; static char *dp; + COLR clr; register int err; register int x, ti; int errp; @@ -813,7 +820,9 @@ COLR *scan; *++dp = 0; errp = err; ti = x*xmax/iconwidth; - err += normbright(scan[ti]) + cerr[x]; + copycolr(clr, scan[ti]); + normcolrs(clr, 1, scale); + err += normbright(clr) + cerr[x]; if (err > 127) err -= 255; else @@ -835,12 +844,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 | @@ -865,23 +873,24 @@ 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); + for (x = 0; x < xmax; x++) + scanline[x][GRN] = normbright(scanline[x]); colrs_gambs(scanline, xmax); - add2icon(y, scanline); if (maxcolors < 256) for (x = 0; x < xmax; x++) - *dp++ = ((long)normbright(scanline[x]) * - maxcolors + 128) >> 8; + *dp++ = ((long)scanline[x][GRN] * + maxcolors + maxcolors/2) >> 8; else for (x = 0; x < xmax; x++) - *dp++ = normbright(scanline[x]); + *dp++ = scanline[x][GRN]; } for (x = 0; x < maxcolors; x++) clrtab[x][RED] = clrtab[x][GRN] = - clrtab[x][BLU] = ((long)x*256+maxcolors/2)/maxcolors; + clrtab[x][BLU] = ((long)x*256 + 128)/maxcolors; } @@ -895,10 +904,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 */