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

Comparing ray/src/px/ra_ppm.c (file contents):
Revision 2.11 by schorsch, Sun Jul 27 22:12:03 2003 UTC vs.
Revision 2.12 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 14 | Line 14 | static const char      RCSid[] = "$Id$";
14   #include  "color.h"
15   #include  "resolu.h"
16  
17
18 int  agryscan(), bgryscan(), aclrscan(), bclrscan();
19 int  agryscan2(), bgryscan2(), aclrscan2(), bclrscan2();
20 int  normval();
21 unsigned int    scanint(), intv(), getby2();
22
17   #define fltv(i)         (((i)+.5)/(maxval+1.))
24
18   int  bradj = 0;                         /* brightness adjustment */
26
19   double  gamcor = 2.2;                   /* gamma correction value */
28
20   int  maxval = 255;                      /* maximum primary value */
30
21   char  *progname;
32
22   int  xmax, ymax;
23  
24 + typedef int colrscanf_t(COLR *scan, int len, FILE *fp);
25 + typedef int colorscanf_t(COLOR *scan, int len, FILE *fp);
26  
27 < main(argc, argv)
28 < int  argc;
29 < char  *argv[];
27 > static colrscanf_t agryscan, bgryscan, aclrscan, bclrscan;
28 > static void ppm2ra(colrscanf_t *getscan);
29 > static void ra2ppm(int  binary, int  grey);
30 >
31 > static colorscanf_t agryscan2, bgryscan2, aclrscan2, bclrscan2;
32 > static void ppm2ra2(colorscanf_t *getscan);
33 > static void ra2ppm2(int  binary, int  grey);
34 >
35 > static int normval(unsigned int  v);
36 > static unsigned int scanint(FILE  *fp);
37 > static unsigned int intv(double v);
38 > static unsigned int getby2(FILE *fp);
39 > static void putby2(unsigned int w, FILE *fp);
40 > static void quiterr(char  *err);
41 >
42 >
43 > int
44 > main(
45 >        int  argc,
46 >        char  *argv[]
47 > )
48   {
49          char  inpbuf[2];
50          int  gryflag = 0;
# Line 171 | Line 180 | userr:
180   }
181  
182  
183 < quiterr(err)            /* print message and exit */
184 < char  *err;
183 > static void
184 > quiterr(                /* print message and exit */
185 >        char  *err
186 > )
187   {
188          if (err != NULL) {
189                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 182 | Line 193 | char  *err;
193   }
194  
195  
196 < ppm2ra(getscan)         /* convert 1-byte Pixmap to Radiance picture */
197 < int  (*getscan)();
196 > static void
197 > ppm2ra(         /* convert 1-byte Pixmap to Radiance picture */
198 >        colrscanf_t *getscan
199 > )
200   {
201          COLR    *scanout;
202          int     y;
# Line 206 | Line 219 | int  (*getscan)();
219   }
220  
221  
222 < ra2ppm(binary, grey)    /* convert Radiance picture to Pixmap */
223 < int  binary, grey;
222 > static void
223 > ra2ppm( /* convert Radiance picture to Pixmap */
224 >        int  binary,
225 >        int  grey
226 > )
227   {
228          COLR    *scanin;
229          register int    x;
# Line 252 | Line 268 | int  binary, grey;
268   }
269  
270  
271 < ppm2ra2(getscan)        /* convert 2-byte Pixmap to Radiance picture */
272 < int  (*getscan)();
271 > static void
272 > ppm2ra2(        /* convert 2-byte Pixmap to Radiance picture */
273 >        colorscanf_t *getscan
274 > )
275   {
276          COLOR   *scanout;
277          double  mult;
# Line 287 | Line 305 | int  (*getscan)();
305   }
306  
307  
308 < ra2ppm2(binary, grey)   /* convert Radiance picture to Pixmap (2-byte) */
309 < int  binary, grey;
308 > static void
309 > ra2ppm2(        /* convert Radiance picture to Pixmap (2-byte) */
310 >        int  binary,
311 >        int  grey
312 > )
313   {
314          COLOR   *scanin;
315          double  mult, d;
# Line 351 | Line 372 | int  binary, grey;
372   }
373  
374  
375 < agryscan(scan, len, fp)                 /* get an ASCII greyscale scanline */
376 < register COLR  *scan;
377 < register int  len;
378 < FILE  *fp;
375 > static int
376 > agryscan(                       /* get an ASCII greyscale scanline */
377 >        register COLR  *scan,
378 >        register int  len,
379 >        FILE  *fp
380 > )
381   {
382          while (len-- > 0) {
383                  scan[0][RED] =
# Line 366 | Line 389 | FILE  *fp;
389   }
390  
391  
392 < bgryscan(scan, len, fp)                 /* get a binary greyscale scanline */
393 < register COLR  *scan;
394 < int  len;
395 < register FILE  *fp;
392 > static int
393 > bgryscan(                       /* get a binary greyscale scanline */
394 >        register COLR  *scan,
395 >        int  len,
396 >        register FILE  *fp
397 > )
398   {
399          register int  c;
400  
# Line 387 | Line 412 | register FILE  *fp;
412   }
413  
414  
415 < aclrscan(scan, len, fp)                 /* get an ASCII color scanline */
416 < register COLR  *scan;
417 < register int  len;
418 < FILE  *fp;
415 > static int
416 > aclrscan(                       /* get an ASCII color scanline */
417 >        register COLR  *scan,
418 >        register int  len,
419 >        FILE  *fp
420 > )
421   {
422          while (len-- > 0) {
423                  scan[0][RED] = normval(scanint(fp));
# Line 402 | Line 429 | FILE  *fp;
429   }
430  
431  
432 < bclrscan(scan, len, fp)                 /* get a binary color scanline */
433 < register COLR  *scan;
434 < int  len;
435 < register FILE  *fp;
432 > static int
433 > bclrscan(                       /* get a binary color scanline */
434 >        register COLR  *scan,
435 >        int  len,
436 >        register FILE  *fp
437 > )
438   {
439          int  r, g, b;
440  
# Line 429 | Line 458 | register FILE  *fp;
458   }
459  
460  
461 < agryscan2(scan, len, fp)                /* get an ASCII greyscale scanline */
462 < register COLOR  *scan;
463 < register int  len;
464 < FILE  *fp;
461 > static int
462 > agryscan2(              /* get an ASCII greyscale scanline */
463 >        register COLOR  *scan,
464 >        register int  len,
465 >        FILE  *fp
466 > )
467   {
468          while (len-- > 0) {
469                  colval(scan[0],RED) =
# Line 444 | Line 475 | FILE  *fp;
475   }
476  
477  
478 < bgryscan2(scan, len, fp)                /* get a binary greyscale scanline */
479 < register COLOR  *scan;
480 < int  len;
481 < register FILE  *fp;
478 > static int
479 > bgryscan2(              /* get a binary greyscale scanline */
480 >        register COLOR  *scan,
481 >        int  len,
482 >        register FILE  *fp
483 > )
484   {
485          register int  c;
486  
# Line 463 | Line 496 | register FILE  *fp;
496   }
497  
498  
499 < aclrscan2(scan, len, fp)                /* get an ASCII color scanline */
500 < register COLOR  *scan;
501 < register int  len;
502 < FILE  *fp;
499 > static int
500 > aclrscan2(              /* get an ASCII color scanline */
501 >        register COLOR  *scan,
502 >        register int  len,
503 >        FILE  *fp
504 > )
505   {
506          while (len-- > 0) {
507                  colval(scan[0],RED) = fltv(scanint(fp));
# Line 478 | Line 513 | FILE  *fp;
513   }
514  
515  
516 < bclrscan2(scan, len, fp)                /* get a binary color scanline */
517 < register COLOR  *scan;
518 < int  len;
519 < register FILE  *fp;
516 > static int
517 > bclrscan2(              /* get a binary color scanline */
518 >        register COLOR  *scan,
519 >        int  len,
520 >        register FILE  *fp
521 > )
522   {
523          int  r, g, b;
524  
# Line 499 | Line 536 | register FILE  *fp;
536   }
537  
538  
539 < unsigned int
540 < scanint(fp)                     /* scan the next positive integer value */
541 < register FILE  *fp;
539 > static unsigned int
540 > scanint(                        /* scan the next positive integer value */
541 >        register FILE  *fp
542 > )
543   {
544          register int  c;
545          register unsigned int  i;
# Line 527 | Line 565 | tryagain:
565   }
566  
567  
568 < int
569 < normval(v)                      /* normalize a value to [0,255] */
570 < register unsigned int  v;
568 > static int
569 > normval(                        /* normalize a value to [0,255] */
570 >        register unsigned int  v
571 > )
572   {
573          if (v >= maxval)
574                  return(255);
# Line 539 | Line 578 | register unsigned int  v;
578   }
579  
580  
581 < unsigned int
582 < getby2(fp)                      /* return 2-byte quantity from fp */
583 < register FILE   *fp;
581 > static unsigned int
582 > getby2(                 /* return 2-byte quantity from fp */
583 >        register FILE   *fp
584 > )
585   {
586          register int    lowerb, upperb;
587  
# Line 553 | Line 593 | register FILE  *fp;
593   }
594  
595  
596 < putby2(w, fp)                   /* put 2-byte quantity to fp */
597 < register unsigned int   w;
598 < register FILE   *fp;
596 > static void
597 > putby2(                 /* put 2-byte quantity to fp */
598 >        register unsigned int   w,
599 >        register FILE   *fp
600 > )
601   {
602          putc(w & 0xff, fp);
603          putc(w>>8 & 0xff, fp);
# Line 566 | Line 608 | register FILE  *fp;
608   }
609  
610  
611 < unsigned int
612 < intv(v)                         /* return integer quantity for v */
613 < register double v;
611 > static unsigned int
612 > intv(                           /* return integer quantity for v */
613 >        register double v
614 > )
615   {
616          if (v >= 0.99999)
617                  return(maxval);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines