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.76 by greg, Thu Aug 2 18:33:48 2018 UTC vs.
Revision 2.80 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 118 | Line 118 | char  *geometry = NULL;                        /* geometry specification */
118   char  icondata[ICONSIZ*ICONSIZ/8];      /* icon bitmap data */
119   int  iconwidth = 0, iconheight = 0;
120  
121 char  *progname;
122
121   char  errmsg[128];
122  
123   uby8  clrtab[256][3];                   /* global color map */
# Line 168 | Line 166 | main(int  argc, char  *argv[])
166          int  i;
167          int  pid;
168          
169 <        progname = argv[0];
169 >        fixargv0(argv[0]);              /* sets global progname */
170          fin = stdin;
171  
172          for (i = 1; i < argc; i++)
# Line 288 | Line 286 | headline(              /* get relevant info from header */
286          if (isexpos(s))
287                  exposure *= exposval(s);
288          else if (formatval(fmt, s))
289 <                wrongformat = strcmp(fmt, COLRFMT);
290 <        else if (isview(s) && sscanview(&ourview, s) > 0)
291 <                gotview++;
289 >                wrongformat = strcmp(fmt, COLRFMT) && strcmp(fmt, SPECFMT);
290 >        else if (isview(s))
291 >                gotview += sscanview(&ourview, s);
292 >        else if (isncomp(s))
293 >                NCSAMP = ncompval(s);
294 >        else if (iswlsplit(s))
295 >                wlsplitval(WLPART, s);
296          return(0);
297   }
298  
# Line 308 | Line 310 | init(                  /* get data and open window */
310          XTextProperty   windowName, iconName;
311          XGCValues       xgcv;
312          char    *name;
313 <        register int    i;
313 >        int     i;
314          
315          if (fname != NULL) {
316                  scanpos = (long *)malloc(ymax*sizeof(long));
# Line 418 | Line 420 | quiterr(               /* print message and exit */
420          char  *err
421   )
422   {
423 <        register int  es;
423 >        int  es;
424          int  cs;
425  
426          if ( (es = (err != NULL)) )
# Line 439 | Line 441 | quiterr(               /* print message and exit */
441  
442   static int
443   viscmp(         /* compare visual to see which is better, descending */
444 <        register XVisualInfo    *v1,
445 <        register XVisualInfo    *v2
444 >        XVisualInfo     *v1,
445 >        XVisualInfo     *v2
446   )
447   {
448          int     bad1 = 0, bad2 = 0;
449 <        register int  *rp;
449 >        int  *rp;
450  
451          if (v1->class == v2->class) {
452                  if ((v1->class == TrueColor) | (v1->class == DirectColor)) {
# Line 501 | Line 503 | static char  vistype[][12] = {
503          };
504          XVisualInfo     *xvi;
505          int     vismatched;
506 <        register int    i, j;
506 >        int     i, j;
507  
508          if (greyscale) {
509                  ourrank = rankings[2];
# Line 672 | Line 674 | traceray(                      /* print requested pixel data */
674          RREAL  hv[2];
675          FVECT  rorg, rdir;
676          COLOR  cval;
677 <        register char  *cp;
677 >        char  *cp;
678  
679          bbox.xmin = xpos; bbox.xsiz = 1;
680          bbox.ymin = ypos; bbox.ysiz = 1;
# Line 950 | Line 952 | revbox(                        /* draw bbox with reversed lines */
952  
953   static void
954   colavg(
955 <        register COLR   *scn,
956 <        register int    n,
955 >        COLR    *scn,
956 >        int     n,
957          void *cavg
958   )
959   {
960          COLOR   col;
961  
962          while (n--) {
963 <                colr_color(col, *scn++);
963 >                colr_color(col, *scn);
964                  addcolor((COLORV*)cavg, col);
965 +                scn++;
966          }
967   }
968  
# Line 970 | Line 973 | avgbox(                                /* average color over current bbox */
973   )
974   {
975          double  d;
976 <        register int    rval;
976 >        int     rval;
977  
978          setcolor(cavg, 0., 0., 0.);
979 <        rval = dobox(colavg, (void *)cavg);
979 >        rval = dobox(colavg, cavg);
980          if (rval > 0) {
981                  d = 1./rval;
982                  scalecolor(cavg, d);
# Line 984 | Line 987 | avgbox(                                /* average color over current bbox */
987  
988   static int
989   dobox(                          /* run function over bbox */
987        //void  (*f)(),                 /* function to call for each subscan */
990          doboxf_t *f,                    /* function to call for each subscan */
991          void    *p                      /* pointer to private data */
992   )
# Line 1009 | Line 1011 | dobox(                         /* run function over bbox */
1011          if (top >= bottom)
1012                  return(0);
1013          for (y = top; y < bottom; y++) {
1014 <                if (getscan(y) == -1)
1014 >                if (getscan(y) < 0)
1015                          return(-1);
1016                  (*f)(scanline+left, right-left, p);
1017          }
# Line 1069 | Line 1071 | make_tonemap(void)                     /* initialize tone mapping */
1071                  tmGlobal = tmInit(flags, stdprims, gamcor);
1072                  if (tmGlobal == NULL)
1073                          goto memerr;
1074 <                if (tmSetSpace(tmGlobal, stdprims, WHTEFFICACY/exposure, NULL))
1074 >                if (tmSetSpace(tmGlobal, stdprims, WHTEFFICACY/exposure))
1075                          goto tmerr;
1076                                                  /* compute picture histogram */
1077                  for (y = 0; y < ymax; y++) {
# Line 1082 | Line 1084 | make_tonemap(void)                     /* initialize tone mapping */
1084                  }
1085          }
1086          tmCurrent = tmDup(tmGlobal);    /* add fixations to duplicate map */
1087 <        dobox(addfix, (void *)tmCurrent);
1087 >        dobox(addfix, tmCurrent);
1088                                          /* (re)compute tone mapping */
1089          if (tmComputeMapping(tmCurrent, gamcor, 0., 0.))
1090                  goto tmerr;
# Line 1096 | Line 1098 | tmerr:
1098  
1099   static void
1100   tmap_colrs(             /* apply tone mapping to scanline */
1101 <        register COLR  *scn,
1101 >        COLR  *scn,
1102          int  len
1103   )
1104   {
1105 <        register uby8  *ps;
1105 >        uby8  *ps;
1106  
1107          if (tmflags == TM_F_LINEAR) {
1108                  if (scale)
# Line 1138 | Line 1140 | tmerr:
1140   static void
1141   getmono(void)                   /* get monochrome data */
1142   {
1143 <        register unsigned char  *dp;
1144 <        register int    x, err;
1143 >        unsigned char   *dp;
1144 >        int     x, err;
1145          int     y, errp;
1146          short   *cerr;
1147  
# Line 1164 | Line 1166 | getmono(void)                  /* get monochrome data */
1166                          cerr[x] = err + errp;
1167                  }
1168          }
1169 <        free((void *)cerr);
1169 >        free(cerr);
1170   }
1171  
1172  
# Line 1178 | Line 1180 | add2icon(              /* add a scanline to our icon data */
1180          static int  ynext;
1181          static char  *dp;
1182          COLR  clr;
1183 <        register int  err;
1184 <        register int    x, ti;
1183 >        int  err;
1184 >        int     x, ti;
1185          int  errp;
1186  
1187          if (iconheight == 0) {          /* initialize */
# Line 1226 | Line 1228 | static void
1228   getfull(void)                   /* get full (24-bit) data */
1229   {
1230          int     y;
1231 <        register uint32 *dp;
1232 <        register uint16 *dph;
1233 <        register int    x;
1231 >        uint32  *dp;
1232 >        uint16  *dph;
1233 >        int     x;
1234                                          /* initialize tone mapping */
1235          make_tonemap();
1236                                          /* read and convert file */
# Line 1294 | Line 1296 | static void
1296   getgrey(void)                   /* get greyscale data */
1297   {
1298          int     y;
1299 <        register unsigned char  *dp;
1300 <        register int    x;
1299 >        unsigned char   *dp;
1300 >        int     x;
1301                                          /* initialize tone mapping */
1302          make_tonemap();
1303                                          /* read and convert file */
# Line 1353 | Line 1355 | getmapped(void)                        /* get color-mapped data */
1355  
1356   static void
1357   scale_rcolors(                  /* scale color map */
1358 <        register XRASTER        *xr,
1358 >        XRASTER *xr,
1359          double  sf
1360   )
1361   {
1362 <        register int    i;
1362 >        int     i;
1363          long    maxv;
1364  
1365          if (xr->pixels == NULL)
# Line 1388 | Line 1390 | getscan(
1390   {
1391          static int  trunced = -1;               /* truncated file? */
1392   skipit:
1393 <        if (trunced >= 0 && y >= trunced) {
1394 <                memset(scanline, '\0', xmax*sizeof(COLR));
1393 >        if (y == cury-1)                        /* already got it? */
1394 >                return(0);
1395 >        if ((trunced >= 0) & (y >= trunced)) {
1396 >                memset(scanline, 0, xmax*sizeof(COLR));
1397                  return(-1);
1398          }
1399          if (y != cury) {
1400 <                if (scanpos == NULL || scanpos[y] == -1)
1400 >                if (scanpos == NULL || scanpos[y] < 0)
1401                          return(-1);
1402 <                if (fseek(fin, scanpos[y], 0) == -1)
1402 >                if (fseek(fin, scanpos[y], 0) < 0)
1403                          quiterr("fseek error");
1404                  cury = y;
1405 <        } else if (scanpos != NULL && scanpos[y] == -1)
1405 >        } else if (scanpos != NULL && scanpos[y] < 0)
1406                  scanpos[y] = ftell(fin);
1407  
1408 <        if (freadcolrs(scanline, xmax, fin) < 0) {
1408 >        if (fread2colrs(scanline, xmax, fin, NCSAMP, WLPART) < 0) {
1409                  fprintf(stderr, "%s: %s: unfinished picture\n",
1410                                  progname, fname==NULL?"<stdin>":fname);
1411                  trunced = y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines