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.56 by greg, Sat Feb 22 02:07:28 2003 UTC vs.
Revision 2.65 by schorsch, Fri Jan 2 12:47:01 2004 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id";
3   #endif
4   /*
5   *  x11image.c - driver for X-windows
# Line 18 | Line 18 | static const char      RCSid[] = "$Id$";
18  
19   #include  "standard.h"
20  
21 + #include  <string.h>
22   #include  <signal.h>
23   #include  <X11/Xlib.h>
24   #include  <X11/cursorfont.h>
# Line 125 | Line 126 | Atom  closedownAtom, wmProtocolsAtom;
126  
127   int  sigrecv;
128  
129 < int  onsig() { sigrecv++; }
129 > void  onsig(int i) { sigrecv++; }
130  
131 + static gethfunc headline;
132  
133 +
134   main(argc, argv)
135   int  argc;
136   char  *argv[];
137   {
135        int  headline();
138          int  i;
139          int  pid;
140          
# Line 245 | Line 247 | userr:
247   }
248  
249  
250 < int
251 < headline(s)             /* get relevant info from header */
252 < char  *s;
250 > static int
251 > headline(               /* get relevant info from header */
252 >        char    *s,
253 >        void    *p
254 > )
255   {
256          char  fmt[32];
257  
# Line 383 | Line 387 | char  *err;
387          register int  es;
388          int  cs;
389  
390 <        if (es = err != NULL)
390 >        if ( (es = err != NULL) )
391                  fprintf(stderr, "%s: %s: %s\n", progname,
392                                  fname==NULL?"<stdin>":fname, err);
393          if (thedisplay != NULL)
394                  XCloseDisplay(thedisplay);
395 <        if (parent < 0 & sigrecv == 0)
395 >        if ((parent < 0) & (sigrecv == 0))
396                  kill(getppid(), SIGCONT);
397          while (parent > 0 && wait(&cs) != -1) { /* wait for any children */
398                  if (es == 0)
# Line 493 | Line 497 | static char  vistype[][12] = {
497          if (viscmp(&xvi[i],&ourvis) > 0)
498                  quiterr("inadequate visuals on this screen");
499                                          /* OK, we'll use it */
500 <        copystruct(&ourvis, &xvi[i]);
500 >        ourvis = xvi[i];
501   #ifdef DEBUG
502          fprintf(stderr, "Selected visual type %s, depth %d\n",
503                          vistype[ourvis.class], ourvis.depth);
# Line 536 | Line 540 | getras()                               /* get raster file */
540                  if (ourras == NULL)
541                          goto fail;
542                  getmono();
543 <        } else if (ourvis.class == TrueColor | ourvis.class == DirectColor) {
544 <                int  datsiz = ourvis.depth>16 ? sizeof(int4) : sizeof(int2);
543 >        } else if ((ourvis.class == TrueColor) | (ourvis.class == DirectColor)) {
544 >                int  datsiz = ourvis.depth>16 ? sizeof(int32) : sizeof(int16);
545                  ourdata = (unsigned char *)malloc(datsiz*xmax*ymax);
546                  if (ourdata == NULL)
547                          goto fail;
# Line 584 | Line 588 | getevent()                             /* process the next event */
588                  map_rcolors(ourras, wind);
589                  if (fast)
590                          make_rpixmap(ourras, wind);
591 <                if (!sequential & parent < 0 & sigrecv == 0) {
591 >                if ((!sequential) & (parent < 0) & (sigrecv == 0)) {
592                          kill(getppid(), SIGCONT);
593                          sigrecv--;
594                  }
# Line 625 | Line 629 | getevent()                             /* process the next event */
629   traceray(xpos, ypos)                    /* print requested pixel data */
630   int  xpos, ypos;
631   {
632 <        extern char  *index();
629 <        FLOAT  hv[2];
632 >        RREAL  hv[2];
633          FVECT  rorg, rdir;
634          COLOR  cval;
635          register char  *cp;
# Line 674 | Line 677 | XKeyPressedEvent  *ekey;
677          XColor  cvx;
678          int  com, n;
679          double  comp;
680 <        FLOAT  hv[2];
680 >        RREAL  hv[2];
681  
682          n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL);
683          if (n == 0)
# Line 794 | Line 797 | XKeyPressedEvent  *ekey;
797                  free_rpixmap(ourras);
798                  return(0);
799          case '0':                               /* recenter origin */
800 <                if (xoff == 0 & yoff == 0)
800 >                if ((xoff == 0) & (yoff == 0))
801                          return(0);
802                  xoff = yoff = 0;
803                  XClearWindow(thedisplay, wind);
# Line 892 | Line 895 | int  x0, y0, x1, y1;
895   }
896  
897  
898 < int
898 > void
899   colavg(scn, n, cavg)
900   register COLR   *scn;
901   register int    n;
# Line 926 | Line 929 | COLOR  cavg;
929  
930   int
931   dobox(f, p)                             /* run function over bbox */
932 < int     (*f)();                 /* function to call for each subscan */
932 > void    (*f)();                 /* function to call for each subscan */
933   char    *p;                     /* pointer to private data */
934   {
935          int  left, right, top, bottom;
# Line 957 | Line 960 | char   *p;                     /* pointer to private data */
960   }
961  
962  
963 < int
963 > void
964   addfix(scn, n)                  /* add fixation points to histogram */
965   COLR    *scn;
966   int     n;
# Line 1153 | Line 1156 | COLR  *scan;
1156   getfull()                       /* get full (24-bit) data */
1157   {
1158          int     y;
1159 <        register unsigned int4  *dp;
1160 <        register unsigned int2  *dph;
1159 >        register uint32 *dp;
1160 >        register uint16 *dph;
1161          register int    x;
1162                                          /* initialize tone mapping */
1163          make_tonemap();
1164                                          /* read and convert file */
1165 <        dp = (unsigned int4 *)ourdata;
1166 <        dph = (unsigned int2 *)ourdata;
1165 >        dp = (uint32 *)ourdata;
1166 >        dph = (uint16 *)ourdata;
1167          for (y = 0; y < ymax; y++) {
1168                  getscan(y);
1169                  add2icon(y, scanline);
# Line 1168 | Line 1171 | getfull()                      /* get full (24-bit) data */
1171                  switch (ourras->image->blue_mask) {
1172                  case 0xff:              /* 24-bit RGB */
1173                          for (x = 0; x < xmax; x++)
1174 <                                *dp++ = (unsigned int4)scanline[x][RED] << 16 |
1175 <                                        (unsigned int4)scanline[x][GRN] << 8 |
1176 <                                        (unsigned int4)scanline[x][BLU] ;
1174 >                                *dp++ = (uint32)scanline[x][RED] << 16 |
1175 >                                        (uint32)scanline[x][GRN] << 8 |
1176 >                                        (uint32)scanline[x][BLU] ;
1177                          break;
1178                  case 0xff0000:          /* 24-bit BGR */
1179                          for (x = 0; x < xmax; x++)
1180 <                                *dp++ = (unsigned int4)scanline[x][RED] |
1181 <                                        (unsigned int4)scanline[x][GRN] << 8 |
1182 <                                        (unsigned int4)scanline[x][BLU] << 16 ;
1180 >                                *dp++ = (uint32)scanline[x][RED] |
1181 >                                        (uint32)scanline[x][GRN] << 8 |
1182 >                                        (uint32)scanline[x][BLU] << 16 ;
1183                          break;
1184   #if 0
1185                  case 0x1f:              /* 15-bit RGB */
# Line 1232 | Line 1235 | getgrey()                      /* get greyscale data */
1235                  tmap_colrs(scanline, xmax);
1236                  if (maxcolors < 256)
1237                          for (x = 0; x < xmax; x++)
1238 <                                *dp++ = ((int4)scanline[x][GRN] *
1238 >                                *dp++ = ((int32)scanline[x][GRN] *
1239                                          maxcolors + maxcolors/2) >> 8;
1240                  else
1241                          for (x = 0; x < xmax; x++)
# Line 1240 | Line 1243 | getgrey()                      /* get greyscale data */
1243          }
1244          for (x = 0; x < maxcolors; x++)
1245                  clrtab[x][RED] = clrtab[x][GRN] =
1246 <                        clrtab[x][BLU] = ((int4)x*256 + 128)/maxcolors;
1246 >                        clrtab[x][BLU] = ((int32)x*256 + 128)/maxcolors;
1247   }
1248  
1249  
# Line 1253 | Line 1256 | getmapped()                    /* get color-mapped data */
1256                                          /* initialize tone mapping */
1257          make_tonemap();
1258                                          /* make histogram */
1259 <        if (new_histo((int4)xmax*ymax) == -1)
1259 >        if (new_histo((int32)xmax*ymax) == -1)
1260                  quiterr("cannot initialize histogram");
1261          for (y = 0; y < ymax; y++) {
1262                  if (getscan(y) < 0)
# Line 1310 | Line 1313 | int  y;
1313          static int  trunced = -1;               /* truncated file? */
1314   skipit:
1315          if (trunced >= 0 && y >= trunced) {
1316 <                bzero(scanline, xmax*sizeof(COLR));
1316 >                memset(scanline, '\0', xmax*sizeof(COLR));
1317                  return(-1);
1318          }
1319          if (y != cury) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines