| 1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* ttyimage.c - program to dump pixel file to dumb terminal. |
| 6 |
|
* |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
|
#include <stdio.h> |
| 11 |
+ |
#include <time.h> |
| 12 |
|
|
| 13 |
+ |
#include "platform.h" |
| 14 |
|
#include "color.h" |
| 15 |
+ |
#include "resolu.h" |
| 16 |
|
|
| 17 |
|
|
| 18 |
< |
#define NCOLS 133 |
| 18 |
> |
#define NCOLS 133 |
| 19 |
|
|
| 20 |
|
|
| 21 |
|
main(argc, argv) |
| 33 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], argv[1]); |
| 34 |
|
exit(1); |
| 35 |
|
} |
| 36 |
< |
|
| 37 |
< |
/* discard header */ |
| 38 |
< |
getheader(input, NULL); |
| 36 |
> |
SET_FILE_BINARY(input); |
| 37 |
|
/* get picture dimensions */ |
| 38 |
< |
if (fgetresolu(&xres, &yres, input) != (YMAJOR|YDECR)) { |
| 39 |
< |
fprintf(stderr, "%s: bad picture size\n", argv[0]); |
| 38 |
> |
if (checkheader(input, COLRFMT, NULL) < 0 || |
| 39 |
> |
fgetresolu(&xres, &yres, input) < 0) { |
| 40 |
> |
fprintf(stderr, "%s: bad picture format\n", argv[0]); |
| 41 |
|
exit(1); |
| 42 |
|
} |
| 43 |
|
if (xres > NCOLS) { |
| 50 |
|
fprintf(stderr, "%s: read error\n", argv[0]); |
| 51 |
|
exit(1); |
| 52 |
|
} |
| 53 |
< |
normcolrs(scanline, xres); |
| 53 |
> |
normcolrs(scanline, xres, 0); |
| 54 |
|
for (j = 0; j < xres; j++) |
| 55 |
|
putchar(shade(scanline[j])); |
| 56 |
|
putchar('\n'); |
| 64 |
|
shade(clr) /* return character for color */ |
| 65 |
|
COLR clr; |
| 66 |
|
{ |
| 67 |
< |
#define NSHADES 13 |
| 67 |
> |
#define NSHADES 13 |
| 68 |
|
|
| 69 |
|
static char shadech[NSHADES+1] = " .,:;+?%&*$@#"; |
| 70 |
|
|