diff options
author | Guido van Rossum <guido@python.org> | 1991-10-30 11:52:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-10-30 11:52:48 (GMT) |
commit | e4bddeae233b107ee08f939e6645357fb245d8cb (patch) | |
tree | bb77370d73740914eecdeba9e1a31d7d9c7b0fae /Demo/sgi/video/v2i.c | |
parent | baf0ebf43c45e85e9a47d25e5279c99ca9455838 (diff) | |
download | cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.zip cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.tar.gz cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.tar.bz2 |
Initial revision
Diffstat (limited to 'Demo/sgi/video/v2i.c')
-rwxr-xr-x | Demo/sgi/video/v2i.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Demo/sgi/video/v2i.c b/Demo/sgi/video/v2i.c new file mode 100755 index 0000000..41589d4 --- /dev/null +++ b/Demo/sgi/video/v2i.c @@ -0,0 +1,63 @@ +#include <stdio.h> +#include <gl/image.h> + +long bm[1280]; +short rb[1280], gb[1280], bb[1280]; +long h, w; + +#define R(comp) ((comp) & 0xff) +#define G(comp) (((comp)>>8) & 0xff) +#define B(comp) (((comp)>>16) & 0xff) + +main(argc, argv) + char **argv; +{ + char lbuf[100]; + int x, y; + int i; + IMAGE * of; + int pmask; + + if( argc != 3 && argc != 4) { + fprintf(stderr, "Usage: v2i videofile imgfile [planemask]\n"); + exit(1); + } + if ( argc == 4) + pmask = atoi(argv[3]); + else + pmask = 7; + if ( freopen(argv[1], "r", stdin) == NULL ) { + perror(argv[1]); + exit(1); + } + gets(lbuf); + if ( sscanf(lbuf, "(%d,%d)", &w, &h) != 2) { + fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); + exit(1); + } + gets(lbuf); /* Skip time info */ + if ( w > 1280 ) { + fprintf(stderr, "%s: Sorry, too wide\n", argv[0]); + exit(1); + } + if ( (of=iopen(argv[2], "w", RLE(1), 3, w, h, 3)) == 0) { + perror(argv[2]); + exit(1); + } + for( y=0; y<h; y++) { + if( fread(bm, sizeof(long), w, stdin) != w) { + fprintf(stderr, "%s: short read\n", argv[0]); + exit(1); + } + for( x=0; x<w; x++) { + if ( pmask & 1) rb[x] = R(bm[x]); + if ( pmask & 2) gb[x] = G(bm[x]); + if ( pmask & 4) bb[x] = B(bm[x]); + } + putrow(of, rb, y, 0); + putrow(of, gb, y, 1); + putrow(of, bb, y, 2); + } + iclose(of); + exit(0); +} |