18 |
|
|
19 |
|
#include <stdio.h> |
20 |
|
#include <math.h> |
21 |
– |
#ifdef MSDOS |
22 |
– |
#include <fcntl.h> |
23 |
– |
#endif |
21 |
|
#include <time.h> |
22 |
|
|
23 |
+ |
#include "platform.h" |
24 |
+ |
#include "rtio.h" |
25 |
|
#include "pict.h" |
26 |
|
#include "color.h" |
27 |
|
#include "resolu.h" |
32 |
|
float gamcor = 2.0; |
33 |
|
int bradj = 0; |
34 |
|
|
35 |
< |
/* First some utility routines */ |
35 |
> |
static void putrect(int xorg, int yorg, int xsize, int ysize); |
36 |
> |
static void putfprect(int xorg, int yorg, int xsize, int ysize); |
37 |
> |
static void putalong(long l); |
38 |
> |
static void putashort(short s); |
39 |
> |
static void putbyte(int b); |
40 |
> |
static void putbytes(unsigned char *buf, int n ); |
41 |
> |
static void putpict(int xsize, int ysize); |
42 |
> |
static void getrow(FILE *in, char *cbuf, int xsize); |
43 |
> |
static int packbits(unsigned char *ibits, unsigned char *pbits, int nbits); |
44 |
> |
static void usage(void); |
45 |
|
|
46 |
< |
putrect(xorg,yorg,xsize,ysize) |
47 |
< |
int xorg, yorg, xsize, ysize; |
46 |
> |
|
47 |
> |
/* First some utility routines */ |
48 |
> |
static void |
49 |
> |
putrect( |
50 |
> |
int xorg, |
51 |
> |
int yorg, |
52 |
> |
int xsize, |
53 |
> |
int ysize |
54 |
> |
) |
55 |
|
{ |
56 |
|
putashort(yorg); |
57 |
|
putashort(xorg); |
59 |
|
putashort(xsize); |
60 |
|
} |
61 |
|
|
62 |
< |
putfprect(xorg,yorg,xsize,ysize) |
63 |
< |
int xorg, yorg, xsize, ysize; |
62 |
> |
static void |
63 |
> |
putfprect( |
64 |
> |
int xorg, |
65 |
> |
int yorg, |
66 |
> |
int xsize, |
67 |
> |
int ysize |
68 |
> |
) |
69 |
|
{ |
70 |
|
putalong(yorg<<16); |
71 |
|
putalong(xorg<<16); |
73 |
|
putalong(xsize<<16); |
74 |
|
} |
75 |
|
|
76 |
< |
putalong(l) |
77 |
< |
long l; |
76 |
> |
static void |
77 |
> |
putalong( |
78 |
> |
long l |
79 |
> |
) |
80 |
|
{ |
81 |
|
putbyte((l>>24)&0xff); |
82 |
|
putbyte((l>>16)&0xff); |
84 |
|
putbyte((l>>0)&0xff); |
85 |
|
} |
86 |
|
|
87 |
< |
putashort(s) |
88 |
< |
short s; |
87 |
> |
static void |
88 |
> |
putashort( |
89 |
> |
short s |
90 |
> |
) |
91 |
|
{ |
92 |
|
putbyte((s>>8)&0xff); |
93 |
|
putbyte((s>>0)&0xff); |
94 |
|
} |
95 |
|
|
96 |
< |
putbyte(b) |
97 |
< |
int b; |
96 |
> |
static void |
97 |
> |
putbyte( |
98 |
> |
int b |
99 |
> |
) |
100 |
|
{ |
101 |
|
if (putc(b,stdout) == EOF && ferror(stdout)) { |
102 |
|
fprintf(stderr,"%s: error on write\n", progname); |
105 |
|
outbytes++; |
106 |
|
} |
107 |
|
|
108 |
< |
putbytes(buf,n) |
109 |
< |
unsigned char *buf; |
110 |
< |
int n; |
108 |
> |
static void |
109 |
> |
putbytes( |
110 |
> |
unsigned char *buf, |
111 |
> |
int n |
112 |
> |
) |
113 |
|
{ |
114 |
|
if(!fwrite(buf,n,1,stdout)) { |
115 |
|
fprintf(stderr,"%s: error on write\n", progname); |
118 |
|
outbytes+=n; |
119 |
|
} |
120 |
|
|
121 |
< |
main(argc,argv) |
122 |
< |
int argc; |
123 |
< |
char **argv; |
121 |
> |
int |
122 |
> |
main( |
123 |
> |
int argc, |
124 |
> |
char **argv |
125 |
> |
) |
126 |
|
{ |
127 |
|
int xsize, ysize; |
128 |
|
int i, picsize; |
129 |
|
int ssizepos, lsizepos; |
130 |
< |
#ifdef MSDOS |
131 |
< |
extern int _fmode; |
132 |
< |
_fmode = O_BINARY; |
103 |
< |
setmode(fileno(stdin), O_BINARY); |
104 |
< |
setmode(fileno(stdout), O_BINARY); |
105 |
< |
#endif |
130 |
> |
SET_DEFAULT_BINARY(); |
131 |
> |
SET_FILE_BINARY(stdin); |
132 |
> |
SET_FILE_BINARY(stdout); |
133 |
|
progname = argv[0]; |
134 |
|
|
135 |
|
for (i = 1; i < argc ; i++) |
155 |
|
goto outofparse; |
156 |
|
break; /* NOTREACHED */ |
157 |
|
|
158 |
< |
otherwise: usage(); |
158 |
> |
default: |
159 |
> |
usage(); |
160 |
|
break; |
161 |
|
} |
162 |
|
else |
240 |
|
return 0; /* lint fodder */ |
241 |
|
} |
242 |
|
|
243 |
< |
putpict(xsize, ysize) |
244 |
< |
int xsize; |
245 |
< |
int ysize; |
243 |
> |
static void |
244 |
> |
putpict( |
245 |
> |
int xsize, |
246 |
> |
int ysize |
247 |
> |
) |
248 |
|
{ |
249 |
|
int y; |
250 |
|
int nbytes, rowbytes; |
315 |
|
free(pbuf); |
316 |
|
} |
317 |
|
|
318 |
< |
int getrow(in, cbuf, xsize) |
319 |
< |
FILE *in; |
320 |
< |
char *cbuf; |
321 |
< |
int xsize; |
318 |
> |
static void |
319 |
> |
getrow( |
320 |
> |
FILE *in, |
321 |
> |
char *cbuf, |
322 |
> |
int xsize |
323 |
> |
) |
324 |
|
{ |
325 |
|
extern char *tempbuffer(); /* defined in color.c */ |
326 |
|
COLR *scanin = NULL; |
351 |
|
} |
352 |
|
|
353 |
|
|
354 |
< |
packbits(ibits,pbits,nbits) |
355 |
< |
unsigned char *ibits, *pbits; |
356 |
< |
int nbits; |
354 |
> |
static int |
355 |
> |
packbits( |
356 |
> |
unsigned char *ibits, |
357 |
> |
unsigned char *pbits, |
358 |
> |
int nbits |
359 |
> |
) |
360 |
|
{ |
326 |
– |
int bytes; /* UNUSED */ |
361 |
|
unsigned char *sptr; |
362 |
|
unsigned char *ibitsend; |
363 |
|
unsigned char *optr = pbits; |
398 |
|
return optr-pbits; |
399 |
|
} |
400 |
|
|
401 |
< |
usage() |
401 |
> |
static void |
402 |
> |
usage(void) |
403 |
|
{ |
404 |
|
fprintf(stderr, "Usage: %s [-v] [-g gamma] [infile [outfile]]\n", |
405 |
|
progname); |