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

Comparing ray/src/px/ra_t8.c (file contents):
Revision 2.4 by greg, Tue Oct 13 11:36:13 1992 UTC vs.
Revision 2.9 by greg, Fri Nov 10 17:04:52 1995 UTC

# Line 27 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27  
28   #ifndef  BSD
29   #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
30 extern char  *memcpy();
30   #endif
31  
32   #define  goodpic(h)     (my_imType(h) && my_mapType(h))
# Line 38 | Line 37 | extern char  *memcpy();
37  
38   #define  taralloc(h)    (BYTE *)emalloc((h)->x*(h)->y)
39  
40 < extern BYTE  clrtab[][3];
40 > BYTE  clrtab[256][3];
41  
42 + extern int      samplefac;
43 +
44   extern char     *ecalloc(), *emalloc();
45  
46   extern long  ftell();
# Line 76 | Line 77 | char  *argv[];
77          setmode(fileno(stdout), O_BINARY);
78   #endif
79          progname = argv[0];
80 +        samplefac = 0;
81  
82          for (i = 1; i < argc; i++)
83                  if (argv[i][0] == '-')
# Line 100 | Line 102 | char  *argv[];
102                          case 'c':
103                                  ncolors = atoi(argv[++i]);
104                                  break;
105 +                        case 'n':
106 +                                samplefac = atoi(argv[++i]);
107 +                                break;
108                          default:
109                                  goto userr;
110                          }
# Line 125 | Line 130 | char  *argv[];
130                  xmax = head.x;
131                  ymax = head.y;
132                                          /* put header */
133 +                newheader("RADIANCE", stdout);
134                  printargs(i, argv, stdout);
135                  fputformat(COLRFMT, stdout);
136                  putchar('\n');
# Line 147 | Line 153 | char  *argv[];
153          quiterr(NULL);
154   userr:
155          fprintf(stderr,
156 <        "Usage: %s [-d][-c ncolors][-b][-g gamv][-e +/-stops] input [output]\n",
156 >        "Usage: %s [-d][-n samp][-c ncolors][-b][-g gamv][-e +/-stops] input [output]\n",
157                          progname);
158          fprintf(stderr, "   Or: %s -r [-g gamv][-e +/-stops] [input [output]]\n",
159                          progname);
# Line 351 | Line 357 | int  dith;             /* use dithering? */
357  
358          setcolrgam(gamv);
359          fpos = ftell(stdin);
360 <        new_histo();                    /* build histogram */
360 >        if ((samplefac ? neu_init(xmax*ymax) : new_histo(xmax*ymax)) == -1)
361 >                quiterr("cannot initialized histogram");
362          for (y = ymax-1; y >= 0; y--) {
363                  if (freadcolrs(inl, xmax, stdin) < 0)
364                          quiterr("error reading Radiance input");
365                  if (bradj)
366                          shiftcolrs(inl, xmax, bradj);
367                  colrs_gambs(inl, xmax);
368 <                cnt_colrs(inl, xmax);
368 >                if (samplefac)
369 >                        neu_colrs(inl, xmax);
370 >                else
371 >                        cnt_colrs(inl, xmax);
372          }
373          if (fseek(stdin, fpos, 0) == EOF)
374                  quiterr("Radiance input must be from a file");
375 <        new_clrtab(nc);                 /* map colors */
375 >        if (samplefac)                  /* map colors */
376 >                neu_clrtab(nc);
377 >        else
378 >                new_clrtab(nc);
379          for (y = ymax-1; y >= 0; y--) {
380                  if (freadcolrs(inl, xmax, stdin) < 0)
381                          quiterr("error reading Radiance input");
382                  if (bradj)
383                          shiftcolrs(inl, xmax, bradj);
384                  colrs_gambs(inl, xmax);
385 <                if (dith)
386 <                        dith_colrs(tarData+y*xmax, inl, xmax);
385 >                if (samplefac)
386 >                        if (dith)
387 >                                neu_dith_colrs(tarData+y*xmax, inl, xmax);
388 >                        else
389 >                                neu_map_colrs(tarData+y*xmax, inl, xmax);
390                  else
391 <                        map_colrs(tarData+y*xmax, inl, xmax);
391 >                        if (dith)
392 >                                dith_colrs(tarData+y*xmax, inl, xmax);
393 >                        else
394 >                                map_colrs(tarData+y*xmax, inl, xmax);
395          }
396   }
397  
# Line 391 | Line 410 | int  nc;               /* number of colors to use */
410                          quiterr("error reading Radiance input");
411                  if (bradj)
412                          shiftcolrs(inl, xmax, bradj);
413 +                x = xmax;
414 +                while (x--)
415 +                        inl[x][GRN] = normbright(inl[x]);
416                  colrs_gambs(inl, xmax);
417                  x = xmax;
418                  if (nc < 256)
419                          while (x--)
420 <                                *--dp = ((long)normbright(inl[x])*nc+128)>>8;
420 >                                *--dp = ((long)inl[x][GRN]*nc+nc/2)>>8;
421                  else
422                          while (x--)
423 <                                *--dp = normbright(inl[x]);
423 >                                *--dp = inl[x][GRN];
424          }
425          for (x = 0; x < nc; x++)
426                  clrtab[x][RED] = clrtab[x][GRN] =
427 <                        clrtab[x][BLU] = ((long)x*256+nc/2)/nc;
427 >                        clrtab[x][BLU] = ((long)x*256+128)/nc;
428   }
429  
430  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines