5 |
|
* program to convert between RADIANCE and Poskanzer Pixmaps |
6 |
|
*/ |
7 |
|
|
8 |
– |
#include <stdio.h> |
8 |
|
#include <math.h> |
9 |
|
#include <ctype.h> |
11 |
– |
#include <time.h> |
12 |
– |
|
10 |
|
#include "platform.h" |
11 |
+ |
#include "rtio.h" |
12 |
|
#include "color.h" |
13 |
|
#include "resolu.h" |
14 |
|
|
16 |
|
int bradj = 0; /* brightness adjustment */ |
17 |
|
double gamcor = 2.2; /* gamma correction value */ |
18 |
|
int maxval = 255; /* maximum primary value */ |
21 |
– |
char *progname; |
19 |
|
int xmax, ymax; |
20 |
|
|
21 |
|
typedef int colrscanf_t(COLR *scan, int len, FILE *fp); |
50 |
|
int ptype; |
51 |
|
int i; |
52 |
|
|
53 |
< |
progname = argv[0]; |
53 |
> |
fixargv0(argv[0]); |
54 |
|
|
55 |
|
for (i = 1; i < argc; i++) |
56 |
|
if (argv[i][0] == '-') |
100 |
|
if (read(fileno(stdin), inpbuf, 2) != 2 || inpbuf[0] != 'P') |
101 |
|
quiterr("input not a Poskanzer Pixmap"); |
102 |
|
ptype = inpbuf[1]; |
103 |
< |
#ifdef _WIN32 |
103 |
> |
#if defined(_WIN32) || defined(_WIN64) |
104 |
|
if (ptype > 4) |
105 |
|
SET_FILE_BINARY(stdin); |
106 |
|
SET_FILE_BINARY(stdout); |
150 |
|
quiterr("unsupported Pixmap type"); |
151 |
|
} |
152 |
|
} else { |
153 |
< |
#ifdef _WIN32 |
153 |
> |
#if defined(_WIN32) || defined(_WIN64) |
154 |
|
SET_FILE_BINARY(stdin); |
155 |
|
if (binflag) |
156 |
|
SET_FILE_BINARY(stdout); |
217 |
|
|
218 |
|
|
219 |
|
static void |
220 |
< |
ra2ppm( /* convert Radiance picture to Pixmap */ |
220 |
> |
ra2ppm( /* convert Radiance picture to 1-byte/sample Pixmap */ |
221 |
|
int binary, |
222 |
|
int grey |
223 |
|
) |
582 |
|
{ |
583 |
|
register int lowerb, upperb; |
584 |
|
|
588 |
– |
lowerb = getc(fp); |
585 |
|
upperb = getc(fp); |
586 |
< |
if (upperb == EOF) |
586 |
> |
lowerb = getc(fp); |
587 |
> |
if (lowerb == EOF) |
588 |
|
return(EOF); |
589 |
|
return(upperb<<8 | lowerb); |
590 |
|
} |
596 |
|
register FILE *fp |
597 |
|
) |
598 |
|
{ |
602 |
– |
putc(w & 0xff, fp); |
599 |
|
putc(w>>8 & 0xff, fp); |
600 |
+ |
putc(w & 0xff, fp); |
601 |
|
if (ferror(fp)) { |
602 |
|
fprintf(stderr, "%s: write error on PPM output\n", progname); |
603 |
|
exit(1); |