diff options
author | Guido van Rossum <guido@python.org> | 1992-02-11 14:50:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-02-11 14:50:54 (GMT) |
commit | 19f2aec581482d233ce66439963d8fdaa7605c23 (patch) | |
tree | edf9c3d5d980ad49639e00b8389ba62aab5b6b85 | |
parent | f47d0485a08fe883672438ed9c24c57135a6934a (diff) | |
download | cpython-19f2aec581482d233ce66439963d8fdaa7605c23.zip cpython-19f2aec581482d233ce66439963d8fdaa7605c23.tar.gz cpython-19f2aec581482d233ce66439963d8fdaa7605c23.tar.bz2 |
Initial revision
-rwxr-xr-x | Demo/sgi/video/Makefile | 7 | ||||
-rwxr-xr-x | Demo/sgi/video/i2v.c | 80 |
2 files changed, 87 insertions, 0 deletions
diff --git a/Demo/sgi/video/Makefile b/Demo/sgi/video/Makefile new file mode 100755 index 0000000..266ea52 --- /dev/null +++ b/Demo/sgi/video/Makefile @@ -0,0 +1,7 @@ +all: v2i i2v + +v2i: v2i.o + $(CC) v2i.o -limage -o v2i + +i2v: i2v.o + $(CC) i2v.o -limage -o i2v diff --git a/Demo/sgi/video/i2v.c b/Demo/sgi/video/i2v.c new file mode 100755 index 0000000..21dfabe --- /dev/null +++ b/Demo/sgi/video/i2v.c @@ -0,0 +1,80 @@ +/* + * i2v -- image-to-video. + * Convert an SGI image file to a format that is immediately usable + * by lrectwrite. + * The header of the file contains a description (in ASCII) + * padded to 8196 byte for fast access of the rest of the file. + * + * Based upon "showimg.c" by Paul Haeberli. + * --Guido van Rossum, CWI, Amsterdam + */ +#include <stdio.h> +#include <gl/gl.h> +#include <gl/device.h> +#include <gl/image.h> + +unsigned short rs[8192]; +unsigned short gs[8192]; +unsigned short bs[8192]; + +IMAGE *image; +int xsize, ysize, zsize; +FILE *fp; + +char header[100]; +char *progname = "i2v"; + +main(argc,argv) +int argc; +char **argv; +{ + int y; + if (argc > 0) progname = argv[0]; + if( argc != 3 ) { + fprintf(stderr, "usage: %s infile outfile\n", progname); + exit(2); + } + if( (image=iopen(argv[1],"r")) == NULL ) { + fprintf(stderr, "%s: can't open input file %s\n",progname, argv[1]); + exit(1); + } + xsize = image->xsize; + ysize = image->ysize; + zsize = image->zsize; + if ((fp = fopen(argv[2], "w")) == NULL) { + fprintf(stderr,"%s: can't open output file %s\n", progname, argv[2]); + exit(1); + } + fprintf(fp, "CMIF video 1.0\n"); + fprintf(fp, "(%d, %d, %d)\n", xsize, ysize, 0); + fprintf(fp, "0, %ld\n", (long)xsize * (long)ysize * sizeof(long)); + fflush(fp); + for(y = 0; y < ysize; y++) { + if(zsize<3) { + getrow(image, rs, y, 0); + writepacked(xsize, rs, rs, rs); + } else { + getrow(image, rs, y, 0); + getrow(image, gs, y, 1); + getrow(image, bs, y, 2); + writepacked(xsize, rs, gs, bs); + } + } + exit(0); +} + +writepacked(n, rsptr, gsptr, bsptr) + int n; + short *rsptr, *gsptr, *bsptr; +{ + long parray[8192]; + long *pptr = parray; + int i = n; + while (--i >= 0) { + *pptr++ = *rsptr++ | (*gsptr++<<8) | (*bsptr++<<16); + } + if (fwrite((char *) parray, sizeof(long), n, fp) != n) { + perror("fwrite"); + exit(1); + } +} |