| 1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 10 |
|
|
| 11 |
|
#include <stdio.h> |
| 12 |
|
|
| 13 |
+ |
#ifdef MSDOS |
| 14 |
+ |
#include <fcntl.h> |
| 15 |
+ |
#endif |
| 16 |
+ |
|
| 17 |
|
#include <ctype.h> |
| 18 |
|
|
| 19 |
|
#include "color.h" |
| 20 |
|
|
| 21 |
< |
extern double atof(), pow(); |
| 21 |
> |
#include "resolu.h" |
| 22 |
|
|
| 23 |
+ |
extern double pow(); |
| 24 |
+ |
|
| 25 |
+ |
extern char *malloc(); |
| 26 |
+ |
|
| 27 |
|
int agryscan(), bgryscan(), aclrscan(), bclrscan(); |
| 28 |
|
|
| 29 |
|
int bradj = 0; /* brightness adjustment */ |
| 39 |
|
int argc; |
| 40 |
|
char *argv[]; |
| 41 |
|
{ |
| 42 |
+ |
char inpbuf[2]; |
| 43 |
|
double gamma = 2.2; |
| 44 |
|
int binflag = 1; |
| 45 |
|
int reverse = 0; |
| 86 |
|
setcolrgam(gamma); |
| 87 |
|
if (reverse) { |
| 88 |
|
/* get header */ |
| 89 |
< |
if (getc(stdin) != 'P') |
| 89 |
> |
if (read(fileno(stdin), inpbuf, 2) != 2 || inpbuf[0] != 'P') |
| 90 |
|
quiterr("input not a Poskanzer Pixmap"); |
| 91 |
< |
ptype = getc(stdin); |
| 91 |
> |
ptype = inpbuf[1]; |
| 92 |
> |
#ifdef MSDOS |
| 93 |
> |
if (ptype > 4) |
| 94 |
> |
setmode(fileno(stdin), O_BINARY); |
| 95 |
> |
setmode(fileno(stdout), O_BINARY); |
| 96 |
> |
#endif |
| 97 |
|
xmax = scanint(stdin); |
| 98 |
|
ymax = scanint(stdin); |
| 99 |
|
maxval = scanint(stdin); |
| 101 |
|
printargs(i, argv, stdout); |
| 102 |
|
fputformat(COLRFMT, stdout); |
| 103 |
|
putchar('\n'); |
| 104 |
< |
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
| 104 |
> |
fprtresolu(xmax, ymax, stdout); |
| 105 |
|
/* convert file */ |
| 106 |
|
switch (ptype) { |
| 107 |
|
case '2': |
| 120 |
|
quiterr("unsupported Pixmap type"); |
| 121 |
|
} |
| 122 |
|
} else { |
| 123 |
+ |
#ifdef MSDOS |
| 124 |
+ |
setmode(fileno(stdin), O_BINARY); |
| 125 |
+ |
if (binflag) |
| 126 |
+ |
setmode(fileno(stdout), O_BINARY); |
| 127 |
+ |
#endif |
| 128 |
|
/* get header info. */ |
| 129 |
|
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
| 130 |
< |
fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR)) |
| 130 |
> |
fgetresolu(&xmax, &ymax, stdin) < 0) |
| 131 |
|
quiterr("bad picture format"); |
| 132 |
|
/* write PPM header */ |
| 133 |
|
printf("P%c\n%d %d\n%d\n", binflag ? '6' : '3', |