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

Comparing ray/src/px/x11image.c (file contents):
Revision 2.34 by greg, Mon Nov 15 10:55:33 1993 UTC vs.
Revision 2.40 by greg, Wed Nov 23 14:24:34 1994 UTC

# Line 56 | Line 56 | static char SCCSid[] = "$SunId$ LBL";
56   #define  redraw(x,y,w,h) patch_raster(wind,(x)-xoff,(y)-yoff,x,y,w,h,ourras)
57  
58   double  gamcor = 2.2;                   /* gamma correction */
59 + char  *gamstr = NULL;                   /* gamma value override */
60  
61   int  dither = 1;                        /* dither colors? */
62   int  fast = 0;                          /* keep picture in Pixmap? */
# Line 112 | Line 113 | char  *progname;
113  
114   char  errmsg[128];
115  
116 < extern BYTE  clrtab[256][3];            /* global color map */
116 > BYTE  clrtab[256][3];                   /* global color map */
117  
118   extern long  ftell();
119  
120 + extern char  *getenv();
121 +
122   Display  *thedisplay;
123   Atom  closedownAtom, wmProtocolsAtom;
124  
# Line 128 | Line 131 | main(argc, argv)
131   int  argc;
132   char  *argv[];
133   {
131        extern char  *getenv();
132        char  *gv;
134          int  headline();
135          int  i;
136          int  pid;
137          
138          progname = argv[0];
138        if ((gv = getenv("GAMMA")) != NULL)
139                gamcor = atof(gv);
139  
140          for (i = 1; i < argc; i++)
141                  if (argv[i][0] == '-')
# Line 148 | Line 147 | char  *argv[];
147                                  greyscale = !greyscale;
148                                  break;
149                          case 'm':
150 +                                greyscale = 1;
151                                  maxcolors = 2;
152                                  break;
153                          case 'd':
# Line 168 | Line 168 | char  *argv[];
168                                  if (argv[i][2] == 'e')
169                                          geometry = argv[++i];
170                                  else
171 <                                        gamcor = atof(argv[++i]);
171 >                                        gamstr = argv[++i];
172                                  break;
173                          default:
174                                  goto userr;
# Line 215 | Line 215 | char  *argv[];
215  
216          init(argc, argv);                       /* get file and open window */
217  
218        if (parent < 0) {
219                kill(getppid(), SIGCONT);       /* signal parent if child */
220                sigrecv--;
221        }
218          for ( ; ; )
219                  getevent();             /* main loop */
220   userr:
221          fprintf(stderr,
222 < "Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops] pic ..\n",
222 > "Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops][-g gamcor] pic ..\n",
223                          progname);
224          exit(1);
225   }
# Line 273 | Line 269 | char **argv;
269          name += i+1;
270          if ((thedisplay = XOpenDisplay(dispname)) == NULL)
271                  quiterr("cannot open display");
272 +                                /* set gamma value */
273 +        if (gamstr == NULL)             /* get it from the X server */
274 +                gamstr = XGetDefault(thedisplay, "radiance", "gamma");
275 +        if (gamstr == NULL)             /* get it from the environment */
276 +                gamstr = getenv("DISPLAY_GAMMA");
277 +        if (gamstr != NULL)
278 +                gamcor = atof(gamstr);
279                                  /* get best visual for default screen */
280          getbestvis();
281                                  /* store image */
# Line 299 | Line 302 | char **argv;
302                  }
303          }
304          /* open window */
305 +        i = CWEventMask|CWCursor|CWBackPixel|CWBorderPixel;
306          ourwinattr.border_pixel = ourwhite;
307          ourwinattr.background_pixel = ourblack;
308 <        ourwinattr.colormap = XCreateColormap(thedisplay, ourroot,
309 <                        ourvis.visual, AllocNone);
308 >        if (ourvis.visual != DefaultVisual(thedisplay,ourscreen)) {
309 >                ourwinattr.colormap = newcmap(thedisplay, ourscreen, ourvis.visual);
310 >                i |= CWColormap;
311 >        }
312          ourwinattr.event_mask = ExposureMask|KeyPressMask|ButtonPressMask|
313                          ButtonReleaseMask|ButtonMotionMask|StructureNotifyMask;
314          ourwinattr.cursor = XCreateFontCursor(thedisplay, XC_diamond_cross);
315          wind = XCreateWindow(thedisplay, ourroot, xszhints.x, xszhints.y,
316                          xszhints.width, xszhints.height, BORWIDTH,
317 <                        ourvis.depth, InputOutput, ourvis.visual, CWEventMask|
318 <                        CWCursor|CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr);
317 >                        ourvis.depth, InputOutput, ourvis.visual,
318 >                        i, &ourwinattr);
319          if (wind == 0)
320                  quiterr("cannot create window");
321          width = xmax;
# Line 347 | Line 353 | char **argv;
353          XSetWMProtocols(thedisplay, wind, &closedownAtom, 1);
354  
355          XMapWindow(thedisplay, wind);
350        return;
356   } /* end of init */
357  
358  
# Line 360 | Line 365 | char  *err;
365          if (es = err != NULL)
366                  fprintf(stderr, "%s: %s: %s\n", progname,
367                                  fname==NULL?"<stdin>":fname, err);
368 <        if (parent > 0 & wind != 0) {
369 <                XDestroyWindow(thedisplay, wind);
370 <                XFlush(thedisplay);
366 <        } else if (parent < 0 & sigrecv == 0)
368 >        if (thedisplay != NULL)
369 >                XCloseDisplay(thedisplay);
370 >        if (parent < 0 & sigrecv == 0)
371                  kill(getppid(), SIGCONT);
372          while (parent > 0 && wait(&cs) != -1) { /* wait for any children */
373                  if (es == 0)
# Line 557 | Line 561 | getevent()                             /* process the next event */
561                  map_rcolors(ourras, wind);
562                  if (fast)
563                          make_rpixmap(ourras, wind);
564 +                if (parent < 0 & sigrecv == 0) {        /* notify parent */
565 +                        kill(getppid(), SIGCONT);
566 +                        sigrecv--;
567 +                }
568                  break;
569          case UnmapNotify:
570                  if (!fast)
# Line 942 | Line 950 | getfull()                      /* get full (24-bit) data */
950                  colrs_gambs(scanline, xmax);
951                  if (ourras->image->blue_mask & 1)
952                          for (x = 0; x < xmax; x++)
953 <                                *dp++ = scanline[x][RED] << 16 |
954 <                                        scanline[x][GRN] << 8 |
955 <                                        scanline[x][BLU] ;
953 >                                *dp++ = (unsigned int4)scanline[x][RED] << 16 |
954 >                                        (unsigned int4)scanline[x][GRN] << 8 |
955 >                                        (unsigned int4)scanline[x][BLU] ;
956                  else
957                          for (x = 0; x < xmax; x++)
958 <                                *dp++ = scanline[x][RED] |
959 <                                        scanline[x][GRN] << 8 |
960 <                                        scanline[x][BLU] << 16 ;
958 >                                *dp++ = (unsigned int4)scanline[x][RED] |
959 >                                        (unsigned int4)scanline[x][GRN] << 8 |
960 >                                        (unsigned int4)scanline[x][BLU] << 16 ;
961          }
962   }
963  
# Line 994 | Line 1002 | getmapped()                    /* get color-mapped data */
1002                                          /* set gamma correction */
1003          setcolrgam(gamcor);
1004                                          /* make histogram */
1005 <        new_histo();
1005 >        if (new_histo((long)xmax*ymax) == -1)
1006 >                quiterr("cannot initialize histogram");
1007          for (y = 0; y < ymax; y++) {
1008                  if (getscan(y) < 0)
1009                          break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines