--- ray/src/px/vgaimage.c 1992/11/02 16:01:17 2.4 +++ ray/src/px/vgaimage.c 2003/02/22 02:07:28 2.10 @@ -1,9 +1,6 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: vgaimage.c,v 2.10 2003/02/22 02:07:28 greg Exp $"; #endif - /* * vgaimage.c - driver for VGA board under DOS */ @@ -86,7 +83,7 @@ char *argv[]; int i; progname = argv[0] = fixargv0(argv[0]); - if ((gv = getenv("GAMMA")) != NULL) + if ((gv = getenv("DISPLAY_GAMMA")) != NULL) gamcor = atof(gv); for (i = 1; i < argc; i++) @@ -147,6 +144,7 @@ userr: } +int headline(s) /* get relevant info from header */ char *s; { @@ -158,6 +156,7 @@ char *s; formatval(fmt, s); wrongformat = strcmp(fmt, COLRFMT); } + return(0); } @@ -168,10 +167,10 @@ init() /* initialize and load display */ short xsiz, ysiz; } video[] = { {_MRES256COLOR, 320, 200}, - {_VRES256COLOR, 640, 400}, + {_VRES256COLOR, 640, 480}, {_SVRES256COLOR, 800, 600}, {_XRES256COLOR, 1024, 768}, - -1 + {-1, 0, 0} }; struct videoconfig config; register int i; @@ -186,12 +185,13 @@ init() /* initialize and load display */ ms_init(); initialized = 1; _getvideoconfig(&config); - if (maxcolors == 0) - maxcolors = config.numcolors; - if (maxcolors > 4) { - maxcolors -= minpix = 2; - _settextcolor(ourwhite); - } + if (maxcolors == 0 | maxcolors > config.numcolors) + maxcolors = config.numcolors-2; + if (maxcolors <= config.numcolors-2) + minpix = 2; + else + ourwhite = maxcolors-1; + _settextcolor(ourwhite); cheight = config.numypixels/config.numtextrows; cwidth = config.numxpixels/config.numtextcols; /* clear scan position array */ @@ -375,11 +375,10 @@ setpalette() /* set our palette using clrtab */ long cvals[256]; register int i; - if (minpix >= 2) { - cvals[ourblack] = _BLACK; cvals[ourwhite] = _BRIGHTWHITE; - } + cvals[ourblack] = _BLACK; + cvals[ourwhite] = _BRIGHTWHITE; for (i = 0; i < maxcolors; i++) - cvals[i+minpix] = clrtab[i][BLU]<<14 & 0x3f0000L | + cvals[i+minpix] = (long)clrtab[i][BLU]<<14 & 0x3f0000L | clrtab[i][GRN]<<6 & 0x3f00 | clrtab[i][RED]>>2; _remapallpalette(cvals); @@ -395,8 +394,8 @@ greyimage() /* display greyscale image */ setcolrgam(gamcor); /* set up color map */ for (x = 0; x < maxcolors; x++) - clrtab[x][RED] = clrtab[x][GRN] = - clrtab[x][BLU] = ((long)x*256+maxcolors/2)/maxcolors; + clrtab[x][RED] = clrtab[x][GRN] = clrtab[x][BLU] = + ((long)x*256 + 128)/maxcolors; setpalette(); _setplotaction(_GPSET); /* read and display file */ @@ -404,18 +403,20 @@ greyimage() /* display greyscale image */ getscan(y); if (scale) shiftcolrs(scanline, xmax, scale); + for (x = 0; x < xmax; x++) + scanline[x][GRN] = normbright(scanline[x]); colrs_gambs(scanline, xmax); if (maxcolors < 256) for (x = 0; x < xmax; x++) { - thiscolor = ((long)normbright(scanline[x]) * - maxcolors + 128) >> 8; + thiscolor = ((long)scanline[x][GRN] * + maxcolors + maxcolors/2) / 256; if (thiscolor != lastcolor) _setcolor((lastcolor=thiscolor)+minpix); _setpixel(x, y); } else for (x = 0; x < xmax; x++) { - thiscolor = normbright(scanline[x]); + thiscolor = scanline[x][GRN]; if (thiscolor != lastcolor) _setcolor((lastcolor=thiscolor)+minpix); _setpixel(x, y); @@ -476,7 +477,7 @@ int y; if (fseek(fin, scanpos[y], 0) == -1) quiterr("fseek error"); cury = y; - } else if (scanpos != NULL && scanpos[y] == -1) + } else if (fin != stdin && scanpos[y] == -1) scanpos[y] = ftell(fin); if (freadcolrs(scanline, xmax, fin) < 0) @@ -597,4 +598,3 @@ ms_done() inregs.w.ax = 0; int386 (0x33, &inregs, &outregs); } -