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.11 by schorsch, Fri Jan 2 12:47:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  vgaimage.c - driver for VGA board under DOS
6   */
7  
8 + #include <stdio.h>
9 +
10   #include  "standard.h"
11   #include  <graph.h>
12   #include  "color.h"
# Line 73 | Line 72 | char  errmsg[128];
72  
73   extern BYTE  clrtab[256][3];            /* global color map */
74  
75 < extern long  ftell();
75 > static gethfunc headline;
76  
77  
78   main(argc, argv)
# Line 82 | Line 81 | char  *argv[];
81   {
82          extern char  *getenv(), *fixargv0();
83          char  *gv;
85        int  headline();
84          int  i;
85  
86          progname = argv[0] = fixargv0(argv[0]);
87 <        if ((gv = getenv("GAMMA")) != NULL)
87 >        if ((gv = getenv("DISPLAY_GAMMA")) != NULL)
88                  gamcor = atof(gv);
89  
90          for (i = 1; i < argc; i++)
# Line 147 | Line 145 | userr:
145   }
146  
147  
148 < headline(s)             /* get relevant info from header */
149 < char  *s;
148 > static int
149 > headline(               /* get relevant info from header */
150 >        char    *s,
151 >        void    *p
152 > )
153   {
154          char  fmt[32];
155  
# Line 158 | Line 159 | char  *s;
159                  formatval(fmt, s);
160                  wrongformat = strcmp(fmt, COLRFMT);
161          }
162 +        return(0);
163   }
164  
165  
# Line 168 | Line 170 | init()                 /* initialize and load display */
170                  short   xsiz, ysiz;
171          } video[] = {
172                  {_MRES256COLOR, 320, 200},
173 <                {_VRES256COLOR, 640, 400},
173 >                {_VRES256COLOR, 640, 480},
174                  {_SVRES256COLOR, 800, 600},
175                  {_XRES256COLOR, 1024, 768},
176 <                -1
176 >                {-1, 0, 0}
177          };
178          struct videoconfig      config;
179          register int    i;
# Line 183 | Line 185 | init()                 /* initialize and load display */
185                  quiterr("input picture too large");
186          if (_setvideomode(video[i].mode) == 0)
187                  quiterr("inadequate display card for picture");
188 +        ms_init();
189          initialized = 1;
190          _getvideoconfig(&config);
191 <        if (maxcolors == 0)
192 <                maxcolors = config.numcolors;
193 <        if (maxcolors > 4) {
194 <                maxcolors -= minpix = 2;
195 <                _settextcolor(ourwhite);
196 <        }
191 >        if (maxcolors == 0 | maxcolors > config.numcolors)
192 >                maxcolors = config.numcolors-2;
193 >        if (maxcolors <= config.numcolors-2)
194 >                minpix = 2;
195 >        else
196 >                ourwhite = maxcolors-1;
197 >        _settextcolor(ourwhite);
198          cheight = config.numypixels/config.numtextrows;
199          cwidth = config.numxpixels/config.numtextcols;
200                                  /* clear scan position array */
# Line 207 | Line 211 | init()                 /* initialize and load display */
211   quiterr(err)            /* print message and exit */
212   char  *err;
213   {
214 <        if (initialized)
214 >        if (initialized) {
215 >                ms_done();
216                  _setvideomode(_DEFAULTMODE);
217 +        }
218          if (err != NULL) {
219                  fprintf(stderr, "%s: %s\n", progname, err);
220                  exit(1);
# Line 267 | Line 273 | docommand()                    /* execute command */
273  
274   watch_mouse()                   /* look after mousie */
275   {
270        static int      mouse_installed = 0;
276          int     a_x, a_y, l_x, l_y;
277  
273        if (!mouse_installed) {
274                ms_init();
275                mouse_installed = 1;
276        }
278          if (mouse_event & M_MOTION)
279                  move_cursor(mouse_xpos, mouse_ypos);
280          if (!(mouse_event & M_LDOWN))
# Line 377 | Line 378 | setpalette()                   /* set our palette using clrtab */
378          long    cvals[256];
379          register int    i;
380  
381 <        if (minpix >= 2) {
382 <                cvals[ourblack] = _BLACK; cvals[ourwhite] = _BRIGHTWHITE;
382 <        }
381 >        cvals[ourblack] = _BLACK;
382 >        cvals[ourwhite] = _BRIGHTWHITE;
383          for (i = 0; i < maxcolors; i++)
384 <                cvals[i+minpix] = clrtab[i][BLU]<<14 & 0x3f0000L |
384 >                cvals[i+minpix] = (long)clrtab[i][BLU]<<14 & 0x3f0000L |
385                                    clrtab[i][GRN]<<6 & 0x3f00 |
386                                    clrtab[i][RED]>>2;
387          _remapallpalette(cvals);
# Line 397 | Line 397 | greyimage()                    /* display greyscale image */
397          setcolrgam(gamcor);
398                                          /* set up color map */
399          for (x = 0; x < maxcolors; x++)
400 <                clrtab[x][RED] = clrtab[x][GRN] =
401 <                        clrtab[x][BLU] = ((long)x*256+maxcolors/2)/maxcolors;
400 >                clrtab[x][RED] = clrtab[x][GRN] = clrtab[x][BLU] =
401 >                                ((long)x*256 + 128)/maxcolors;
402          setpalette();
403          _setplotaction(_GPSET);
404                                          /* read and display file */
# Line 406 | Line 406 | greyimage()                    /* display greyscale image */
406                  getscan(y);
407                  if (scale)
408                          shiftcolrs(scanline, xmax, scale);
409 +                for (x = 0; x < xmax; x++)
410 +                        scanline[x][GRN] = normbright(scanline[x]);
411                  colrs_gambs(scanline, xmax);
412                  if (maxcolors < 256)
413                          for (x = 0; x < xmax; x++) {
414 <                                thiscolor = ((long)normbright(scanline[x]) *
415 <                                        maxcolors + 128) >> 8;
414 >                                thiscolor = ((long)scanline[x][GRN] *
415 >                                                maxcolors + maxcolors/2) / 256;
416                                  if (thiscolor != lastcolor)
417                                          _setcolor((lastcolor=thiscolor)+minpix);
418                                  _setpixel(x, y);
419                          }
420                  else
421                          for (x = 0; x < xmax; x++) {
422 <                                thiscolor = normbright(scanline[x]);
422 >                                thiscolor = scanline[x][GRN];
423                                  if (thiscolor != lastcolor)
424                                          _setcolor((lastcolor=thiscolor)+minpix);
425                                  _setpixel(x, y);
# Line 434 | Line 436 | mappedimage()                  /* display color-mapped image */
436                                          /* set gamma correction */
437          setcolrgam(gamcor);
438                                          /* make histogram */
439 +        _outtext("Quantizing image -- Please wait...");
440          new_histo();
441          for (y = 0; y < ymax; y++) {
442                  if (getscan(y) < 0)
# Line 477 | Line 480 | int  y;
480                  if (fseek(fin, scanpos[y], 0) == -1)
481                          quiterr("fseek error");
482                  cury = y;
483 <        } else if (scanpos != NULL && scanpos[y] == -1)
483 >        } else if (fin != stdin && scanpos[y] == -1)
484                  scanpos[y] = ftell(fin);
485  
486          if (freadcolrs(scanline, xmax, fin) < 0)
# Line 587 | Line 590 | ms_init()
590      int386x( 0x33, &inregs, &outregs, &sregs );
591  
592      return(1);
593 + }
594 +
595 + ms_done()
596 + {
597 +    union REGS inregs, outregs;
598 +
599 +    /* uninstall watcher */
600 +
601 +    inregs.w.ax = 0;
602 +    int386 (0x33, &inregs, &outregs);
603   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines