| 1 |
#ifndef lint
|
| 2 |
static const char RCSid[] = "$Id: ra_im.c,v 2.4 2004/03/28 20:33:14 schorsch Exp $";
|
| 3 |
#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 |
#include "rtprocess.h"
|
| 13 |
|
| 14 |
#define PCOMM "pvalue -h -b -db"
|
| 15 |
|
| 16 |
#define MINVAL 1
|
| 17 |
#define MAXVAL 252
|
| 18 |
|
| 19 |
extern FILE *freopen();
|
| 20 |
|
| 21 |
|
| 22 |
int
|
| 23 |
main(
|
| 24 |
int argc,
|
| 25 |
char *argv[]
|
| 26 |
)
|
| 27 |
{
|
| 28 |
register int c;
|
| 29 |
register FILE *fp;
|
| 30 |
|
| 31 |
if (argc > 3) {
|
| 32 |
fputs("Usage: ", stderr);
|
| 33 |
fputs(argv[0], stderr);
|
| 34 |
fputs(" [infile [outfile]]\n", stderr);
|
| 35 |
exit(1);
|
| 36 |
}
|
| 37 |
if (argc > 1 && freopen(argv[1], "r", stdin) == NULL) {
|
| 38 |
perror(argv[1]);
|
| 39 |
exit(1);
|
| 40 |
}
|
| 41 |
if (argc > 2 && freopen(argv[2], "w", stdout) == NULL) {
|
| 42 |
perror(argv[2]);
|
| 43 |
exit(1);
|
| 44 |
}
|
| 45 |
if ((fp = popen(PCOMM, "r")) == NULL) {
|
| 46 |
perror(argv[0]);
|
| 47 |
exit(1);
|
| 48 |
}
|
| 49 |
while ((c = getc(fp)) != EOF) {
|
| 50 |
if (c < MINVAL)
|
| 51 |
putc(MINVAL, stdout);
|
| 52 |
else if (c > MAXVAL)
|
| 53 |
putc(MAXVAL, stdout);
|
| 54 |
else
|
| 55 |
putc(c, stdout);
|
| 56 |
}
|
| 57 |
exit(pclose(fp));
|
| 58 |
}
|