diff options
author | Guido van Rossum <guido@python.org> | 1991-11-04 15:54:36 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-11-04 15:54:36 (GMT) |
commit | bac4572300b195678a407ff8b28b35cd1e8634e7 (patch) | |
tree | dc097f2e6edff986724e45db58fb097eebded48b /Demo | |
parent | 5d731fc88c8019e0fd5b6a44a0edb5988b447ea0 (diff) | |
download | cpython-bac4572300b195678a407ff8b28b35cd1e8634e7.zip cpython-bac4572300b195678a407ff8b28b35cd1e8634e7.tar.gz cpython-bac4572300b195678a407ff8b28b35cd1e8634e7.tar.bz2 |
Fixed to understand new file format; and cosmetics.
Diffstat (limited to 'Demo')
-rwxr-xr-x | Demo/sgi/video/v2i.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Demo/sgi/video/v2i.c b/Demo/sgi/video/v2i.c index 41589d4..5f8f3b5 100755 --- a/Demo/sgi/video/v2i.c +++ b/Demo/sgi/video/v2i.c @@ -1,9 +1,14 @@ +/* Convert the first image of a CMIF video movie file to SGI .rgb format. + usage: v2i videofile imagefile [planemask] + link with -limage +*/ + #include <stdio.h> #include <gl/image.h> long bm[1280]; short rb[1280], gb[1280], bb[1280]; -long h, w; +long w, h, pf; #define R(comp) ((comp) & 0xff) #define G(comp) (((comp)>>8) & 0xff) @@ -20,7 +25,7 @@ main(argc, argv) if( argc != 3 && argc != 4) { fprintf(stderr, "Usage: v2i videofile imgfile [planemask]\n"); - exit(1); + exit(2); } if ( argc == 4) pmask = atoi(argv[3]); @@ -30,12 +35,23 @@ main(argc, argv) perror(argv[1]); exit(1); } - gets(lbuf); - if ( sscanf(lbuf, "(%d,%d)", &w, &h) != 2) { + if (fgets(lbuf, sizeof lbuf, stdin) == NULL) { + fprintf(stderr, "Immediate EOF\n"); + exit(1); + } + if (strncmp(lbuf, "CMIF", 4) == 0) { + /* Skip optional header line */ + if (fgets(lbuf, sizeof lbuf, stdin) == NULL) { + fprintf(stderr, "Immediate EOF after header\n"); + exit(1); + } + } + pf = 2; /* Default */ + if ( sscanf(lbuf, "(%d,%d,%d)", &w, &h, &pf) < 2) { fprintf(stderr, "%s: bad size spec: %s\n", argv[0], lbuf); exit(1); } - gets(lbuf); /* Skip time info */ + fgets(lbuf, sizeof lbuf, stdin); /* Skip time info */ if ( w > 1280 ) { fprintf(stderr, "%s: Sorry, too wide\n", argv[0]); exit(1); |