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