1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
13 |
|
#include <stdio.h> |
14 |
|
|
15 |
|
#include "color.h" |
16 |
+ |
#include "resolu.h" |
17 |
|
|
18 |
|
|
19 |
|
#define NCOLS 133 |
26 |
|
FILE *input; |
27 |
|
int xres, yres; |
28 |
|
COLR scanline[NCOLS]; |
28 |
– |
char sbuf[256]; |
29 |
|
register int i, j; |
30 |
|
|
31 |
|
if (argc < 2) |
35 |
|
exit(1); |
36 |
|
} |
37 |
|
|
38 |
– |
/* discard header */ |
39 |
– |
while (fgets(sbuf, sizeof(sbuf), input) != NULL && sbuf[0] != '\n') |
40 |
– |
; |
38 |
|
/* get picture dimensions */ |
39 |
< |
if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { |
40 |
< |
fprintf(stderr, "%s: bad picture size\n", argv[0]); |
39 |
> |
if (checkheader(input, COLRFMT, NULL) < 0 || |
40 |
> |
fgetresolu(&xres, &yres, input) < 0) { |
41 |
> |
fprintf(stderr, "%s: bad picture format\n", argv[0]); |
42 |
|
exit(1); |
43 |
|
} |
44 |
|
if (xres > NCOLS) { |
51 |
|
fprintf(stderr, "%s: read error\n", argv[0]); |
52 |
|
exit(1); |
53 |
|
} |
54 |
+ |
normcolrs(scanline, xres, 0); |
55 |
|
for (j = 0; j < xres; j++) |
56 |
|
putchar(shade(scanline[j])); |
57 |
|
putchar('\n'); |
68 |
|
#define NSHADES 13 |
69 |
|
|
70 |
|
static char shadech[NSHADES+1] = " .,:;+?%&*$@#"; |
72 |
– |
COLR nclr; |
73 |
– |
register int b; |
71 |
|
|
72 |
< |
colr_norm(clr, nclr); |
76 |
< |
b = norm_bright(nclr); |
77 |
< |
b = b*NSHADES/256; |
78 |
< |
return(shadech[b]); |
72 |
> |
return(shadech[normbright(clr)*NSHADES/256]); |
73 |
|
|
74 |
|
#undef NSHADES |
75 |
|
} |