2 * i2v -- image-to-video.
3 * Convert an SGI image file to a format that is immediately usable
5 * The header of the file contains a description (in ASCII)
6 * padded to 8196 byte for fast access of the rest of the file.
8 * Based upon "showimg.c" by Paul Haeberli.
9 * --Guido van Rossum, CWI, Amsterdam
13 #include <gl/device.h>
16 unsigned short rs
[8192];
17 unsigned short gs
[8192];
18 unsigned short bs
[8192];
21 int xsize
, ysize
, zsize
;
25 char *progname
= "i2v";
32 if (argc
> 0) progname
= argv
[0];
34 fprintf(stderr
, "usage: %s infile outfile\n", progname
);
37 if( (image
=iopen(argv
[1],"r")) == NULL
) {
38 fprintf(stderr
, "%s: can't open input file %s\n",progname
, argv
[1]);
44 if ((fp
= fopen(argv
[2], "w")) == NULL
) {
45 fprintf(stderr
,"%s: can't open output file %s\n", progname
, argv
[2]);
48 fprintf(fp
, "CMIF video 1.0\n");
49 fprintf(fp
, "(%d, %d, %d)\n", xsize
, ysize
, 0);
50 fprintf(fp
, "0, %ld\n", (long)xsize
* (long)ysize
* sizeof(long));
52 for(y
= 0; y
< ysize
; y
++) {
54 getrow(image
, rs
, y
, 0);
55 writepacked(xsize
, rs
, rs
, rs
);
57 getrow(image
, rs
, y
, 0);
58 getrow(image
, gs
, y
, 1);
59 getrow(image
, bs
, y
, 2);
60 writepacked(xsize
, rs
, gs
, bs
);
66 writepacked(n
, rsptr
, gsptr
, bsptr
)
68 short *rsptr
, *gsptr
, *bsptr
;
74 *pptr
++ = *rsptr
++ | (*gsptr
++<<8) | (*bsptr
++<<16);
76 if (fwrite((char *) parray
, sizeof(long), n
, fp
) != n
) {