| 1 |
greg |
1.1 |
#ifndef lint
|
| 2 |
schorsch |
2.3 |
static const char RCSid[] = "$Id: ra_im.c,v 2.2 2003/02/22 02:07:27 greg Exp $";
|
| 3 |
greg |
1.1 |
#endif
|
| 4 |
|
|
/*
|
| 5 |
|
|
* ra_im.c - convert Radiance picture to imagetools raw format.
|
| 6 |
|
|
*
|
| 7 |
|
|
* 9/16/88
|
| 8 |
|
|
*/
|
| 9 |
|
|
|
| 10 |
|
|
#include <stdio.h>
|
| 11 |
|
|
|
| 12 |
schorsch |
2.3 |
#include "rtprocess.h"
|
| 13 |
greg |
1.1 |
|
| 14 |
|
|
#define PCOMM "pvalue -h -b -db"
|
| 15 |
|
|
|
| 16 |
|
|
#define MINVAL 1
|
| 17 |
|
|
#define MAXVAL 252
|
| 18 |
|
|
|
| 19 |
schorsch |
2.3 |
extern FILE *freopen();
|
| 20 |
greg |
1.1 |
|
| 21 |
|
|
|
| 22 |
|
|
main(argc, argv)
|
| 23 |
|
|
int argc;
|
| 24 |
|
|
char *argv[];
|
| 25 |
|
|
{
|
| 26 |
|
|
register int c;
|
| 27 |
|
|
register FILE *fp;
|
| 28 |
|
|
|
| 29 |
|
|
if (argc > 3) {
|
| 30 |
|
|
fputs("Usage: ", stderr);
|
| 31 |
|
|
fputs(argv[0], stderr);
|
| 32 |
|
|
fputs(" [infile [outfile]]\n", stderr);
|
| 33 |
|
|
exit(1);
|
| 34 |
|
|
}
|
| 35 |
|
|
if (argc > 1 && freopen(argv[1], "r", stdin) == NULL) {
|
| 36 |
|
|
perror(argv[1]);
|
| 37 |
|
|
exit(1);
|
| 38 |
|
|
}
|
| 39 |
|
|
if (argc > 2 && freopen(argv[2], "w", stdout) == NULL) {
|
| 40 |
|
|
perror(argv[2]);
|
| 41 |
|
|
exit(1);
|
| 42 |
|
|
}
|
| 43 |
|
|
if ((fp = popen(PCOMM, "r")) == NULL) {
|
| 44 |
|
|
perror(argv[0]);
|
| 45 |
|
|
exit(1);
|
| 46 |
|
|
}
|
| 47 |
|
|
while ((c = getc(fp)) != EOF) {
|
| 48 |
|
|
if (c < MINVAL)
|
| 49 |
|
|
putc(MINVAL, stdout);
|
| 50 |
|
|
else if (c > MAXVAL)
|
| 51 |
|
|
putc(MAXVAL, stdout);
|
| 52 |
|
|
else
|
| 53 |
|
|
putc(c, stdout);
|
| 54 |
|
|
}
|
| 55 |
|
|
exit(pclose(fp));
|
| 56 |
|
|
}
|