--- ray/src/px/x11image.c 1990/03/12 15:14:53 1.6 +++ ray/src/px/x11image.c 1990/10/21 10:48:17 1.10 @@ -308,7 +308,9 @@ getras() /* get raster file */ if (ourras == NULL) goto fail; getmono(); - } else if (XMatchVisualInfo(thedisplay,ourscreen,24,TrueColor,&vinfo)) { + } else if (XMatchVisualInfo(thedisplay,ourscreen,24,TrueColor,&vinfo) + /* kludge for DirectColor */ + || XMatchVisualInfo(thedisplay,ourscreen,24,DirectColor,&vinfo)) { ourdata = (unsigned char *)malloc(xmax*ymax*3); if (ourdata == NULL) goto fail; @@ -334,7 +336,7 @@ getras() /* get raster file */ } return; fail: - quit("could not create raster image"); + quiterr("could not create raster image"); } @@ -443,9 +445,10 @@ XKeyPressedEvent *ekey; XBell(thedisplay, 0); return(-1); } - viewray(rorg, rdir, &ourview, + if (viewray(rorg, rdir, &ourview, (ekey->x-xoff+.5)/xmax, - (ymax-1-ekey->y+yoff+.5)/ymax); + (ymax-1-ekey->y+yoff+.5)/ymax) < 0) + return(-1); printf("%e %e %e ", rorg[0], rorg[1], rorg[2]); printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]); fflush(stdout); @@ -601,20 +604,20 @@ getmono() /* get monochrome data */ register unsigned char *dp; register int x, err; int y; - rgbpixel *inl; short *cerr; - if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL - || (cerr = (short *)calloc(xmax,sizeof(short))) == NULL) - quit("out of memory in getmono"); + if ((cerr = (short *)calloc(xmax,sizeof(short))) == NULL) + quiterr("out of memory in getmono"); dp = ourdata - 1; for (y = 0; y < ymax; y++) { - picreadline3(y, inl); + if (getscan(y) < 0) + quiterr("seek error in getmono"); + normcolrs(scanline, xmax, scale); err = 0; for (x = 0; x < xmax; x++) { if (!(x&7)) *++dp = 0; - err += rgb_bright(&inl[x]) + cerr[x]; + err += normbright(scanline[x]) + cerr[x]; if (err > 127) err -= 255; else @@ -622,7 +625,6 @@ getmono() /* get monochrome data */ cerr[x] = err >>= 1; } } - free((char *)inl); free((char *)cerr); } @@ -630,9 +632,24 @@ getmono() /* get monochrome data */ getfull() /* get full (24-bit) data */ { int y; - - for (y = 0; y < ymax; y++) - picreadline3(y, (rgbpixel *)(ourdata+y*xmax*3)); + register unsigned char *dp; + register int x; + /* set gamma correction */ + setcolrgam(gamcor); + /* read and convert file */ + dp = ourdata; + for (y = 0; y < ymax; y++) { + if (getscan(y) < 0) + quiterr("seek error in getfull"); + if (scale) + shiftcolrs(scanline, xmax, scale); + colrs_gambs(scanline, xmax); + for (x = 0; x < xmax; x++) { + *dp++ = scanline[x][RED]; + *dp++ = scanline[x][GRN]; + *dp++ = scanline[x][BLU]; + } + } } @@ -671,7 +688,7 @@ int y; if (scanpos == NULL || scanpos[y] == -1) return(-1); if (fseek(fin, scanpos[y], 0) == -1) - quit("fseek error"); + quiterr("fseek error"); cury = y; } else if (scanpos != NULL) scanpos[y] = ftell(fin);