ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/vgaimage.c
(Generate patch)

Comparing ray/src/px/vgaimage.c (file contents):
Revision 2.3 by greg, Fri Oct 16 13:09:36 1992 UTC vs.
Revision 2.7 by greg, Fri Jun 11 16:58:35 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1993 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 168 | Line 168 | init()                 /* initialize and load display */
168                  short   xsiz, ysiz;
169          } video[] = {
170                  {_MRES256COLOR, 320, 200},
171 <                {_VRES256COLOR, 640, 400},
171 >                {_VRES256COLOR, 640, 480},
172                  {_SVRES256COLOR, 800, 600},
173                  {_XRES256COLOR, 1024, 768},
174 <                -1
174 >                {-1, 0, 0}
175          };
176          struct videoconfig      config;
177          register int    i;
# Line 183 | Line 183 | init()                 /* initialize and load display */
183                  quiterr("input picture too large");
184          if (_setvideomode(video[i].mode) == 0)
185                  quiterr("inadequate display card for picture");
186 +        ms_init();
187          initialized = 1;
188          _getvideoconfig(&config);
189 <        if (maxcolors == 0)
190 <                maxcolors = config.numcolors;
191 <        if (maxcolors > 4) {
192 <                maxcolors -= minpix = 2;
193 <                _settextcolor(ourwhite);
194 <        }
189 >        if (maxcolors == 0 | maxcolors > config.numcolors)
190 >                maxcolors = config.numcolors-2;
191 >        if (maxcolors <= config.numcolors-2)
192 >                minpix = 2;
193 >        else
194 >                ourwhite = maxcolors-1;
195 >        _settextcolor(ourwhite);
196          cheight = config.numypixels/config.numtextrows;
197          cwidth = config.numxpixels/config.numtextcols;
198                                  /* clear scan position array */
# Line 207 | Line 209 | init()                 /* initialize and load display */
209   quiterr(err)            /* print message and exit */
210   char  *err;
211   {
212 <        if (initialized)
212 >        if (initialized) {
213 >                ms_done();
214                  _setvideomode(_DEFAULTMODE);
215 +        }
216          if (err != NULL) {
217                  fprintf(stderr, "%s: %s\n", progname, err);
218                  exit(1);
# Line 267 | Line 271 | docommand()                    /* execute command */
271  
272   watch_mouse()                   /* look after mousie */
273   {
270        static int      mouse_installed = 0;
274          int     a_x, a_y, l_x, l_y;
275  
273        if (!mouse_installed) {
274                ms_init();
275                mouse_installed = 1;
276        }
276          if (mouse_event & M_MOTION)
277                  move_cursor(mouse_xpos, mouse_ypos);
278          if (!(mouse_event & M_LDOWN))
# Line 377 | Line 376 | setpalette()                   /* set our palette using clrtab */
376          long    cvals[256];
377          register int    i;
378  
379 <        if (minpix >= 2) {
380 <                cvals[ourblack] = _BLACK; cvals[ourwhite] = _BRIGHTWHITE;
382 <        }
379 >        cvals[ourblack] = _BLACK;
380 >        cvals[ourwhite] = _BRIGHTWHITE;
381          for (i = 0; i < maxcolors; i++)
382 <                cvals[i+minpix] = clrtab[i][BLU]<<14 & 0x3f0000L |
382 >                cvals[i+minpix] = (long)clrtab[i][BLU]<<14 & 0x3f0000L |
383                                    clrtab[i][GRN]<<6 & 0x3f00 |
384                                    clrtab[i][RED]>>2;
385          _remapallpalette(cvals);
# Line 397 | Line 395 | greyimage()                    /* display greyscale image */
395          setcolrgam(gamcor);
396                                          /* set up color map */
397          for (x = 0; x < maxcolors; x++)
398 <                clrtab[x][RED] = clrtab[x][GRN] =
399 <                        clrtab[x][BLU] = ((long)x*256+maxcolors/2)/maxcolors;
398 >                clrtab[x][RED] = clrtab[x][GRN] = clrtab[x][BLU] =
399 >                                ((long)x*256 + 128)/maxcolors;
400          setpalette();
401          _setplotaction(_GPSET);
402                                          /* read and display file */
# Line 406 | Line 404 | greyimage()                    /* display greyscale image */
404                  getscan(y);
405                  if (scale)
406                          shiftcolrs(scanline, xmax, scale);
407 +                for (x = 0; x < xmax; x++)
408 +                        scanline[x][GRN] = normbright(scanline[x]);
409                  colrs_gambs(scanline, xmax);
410                  if (maxcolors < 256)
411                          for (x = 0; x < xmax; x++) {
412 <                                thiscolor = ((long)normbright(scanline[x]) *
413 <                                        maxcolors + 128) >> 8;
412 >                                thiscolor = ((long)scanline[x][GRN] *
413 >                                                maxcolors + maxcolors/2) / 256;
414                                  if (thiscolor != lastcolor)
415                                          _setcolor((lastcolor=thiscolor)+minpix);
416                                  _setpixel(x, y);
417                          }
418                  else
419                          for (x = 0; x < xmax; x++) {
420 <                                thiscolor = normbright(scanline[x]);
420 >                                thiscolor = scanline[x][GRN];
421                                  if (thiscolor != lastcolor)
422                                          _setcolor((lastcolor=thiscolor)+minpix);
423                                  _setpixel(x, y);
# Line 434 | Line 434 | mappedimage()                  /* display color-mapped image */
434                                          /* set gamma correction */
435          setcolrgam(gamcor);
436                                          /* make histogram */
437 +        _outtext("Quantizing image -- Please wait...");
438          new_histo();
439          for (y = 0; y < ymax; y++) {
440                  if (getscan(y) < 0)
# Line 477 | Line 478 | int  y;
478                  if (fseek(fin, scanpos[y], 0) == -1)
479                          quiterr("fseek error");
480                  cury = y;
481 <        } else if (scanpos != NULL && scanpos[y] == -1)
481 >        } else if (fin != stdin && scanpos[y] == -1)
482                  scanpos[y] = ftell(fin);
483  
484          if (freadcolrs(scanline, xmax, fin) < 0)
# Line 587 | Line 588 | ms_init()
588      int386x( 0x33, &inregs, &outregs, &sregs );
589  
590      return(1);
591 + }
592 +
593 + ms_done()
594 + {
595 +    union REGS inregs, outregs;
596 +
597 +    /* uninstall watcher */
598 +
599 +    inregs.w.ax = 0;
600 +    int386 (0x33, &inregs, &outregs);
601   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines