Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19f2aec

Browse files
committed
Initial revision
1 parent f47d048 commit 19f2aec

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

Demo/sgi/video/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
all: v2i i2v
2+
3+
v2i: v2i.o
4+
$(CC) v2i.o -limage -o v2i
5+
6+
i2v: i2v.o
7+
$(CC) i2v.o -limage -o i2v

Demo/sgi/video/i2v.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* i2v -- image-to-video.
3+
* Convert an SGI image file to a format that is immediately usable
4+
* by lrectwrite.
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.
7+
*
8+
* Based upon "showimg.c" by Paul Haeberli.
9+
* --Guido van Rossum, CWI, Amsterdam
10+
*/
11+
#include <stdio.h>
12+
#include <gl/gl.h>
13+
#include <gl/device.h>
14+
#include <gl/image.h>
15+
16+
unsigned short rs[8192];
17+
unsigned short gs[8192];
18+
unsigned short bs[8192];
19+
20+
IMAGE *image;
21+
int xsize, ysize, zsize;
22+
FILE *fp;
23+
24+
char header[100];
25+
char *progname = "i2v";
26+
27+
main(argc,argv)
28+
int argc;
29+
char **argv;
30+
{
31+
int y;
32+
if (argc > 0) progname = argv[0];
33+
if( argc != 3 ) {
34+
fprintf(stderr, "usage: %s infile outfile\n", progname);
35+
exit(2);
36+
}
37+
if( (image=iopen(argv[1],"r")) == NULL ) {
38+
fprintf(stderr, "%s: can't open input file %s\n",progname, argv[1]);
39+
exit(1);
40+
}
41+
xsize = image->xsize;
42+
ysize = image->ysize;
43+
zsize = image->zsize;
44+
if ((fp = fopen(argv[2], "w")) == NULL) {
45+
fprintf(stderr,"%s: can't open output file %s\n", progname, argv[2]);
46+
exit(1);
47+
}
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));
51+
fflush(fp);
52+
for(y = 0; y < ysize; y++) {
53+
if(zsize<3) {
54+
getrow(image, rs, y, 0);
55+
writepacked(xsize, rs, rs, rs);
56+
} else {
57+
getrow(image, rs, y, 0);
58+
getrow(image, gs, y, 1);
59+
getrow(image, bs, y, 2);
60+
writepacked(xsize, rs, gs, bs);
61+
}
62+
}
63+
exit(0);
64+
}
65+
66+
writepacked(n, rsptr, gsptr, bsptr)
67+
int n;
68+
short *rsptr, *gsptr, *bsptr;
69+
{
70+
long parray[8192];
71+
long *pptr = parray;
72+
int i = n;
73+
while (--i >= 0) {
74+
*pptr++ = *rsptr++ | (*gsptr++<<8) | (*bsptr++<<16);
75+
}
76+
if (fwrite((char *) parray, sizeof(long), n, fp) != n) {
77+
perror("fwrite");
78+
exit(1);
79+
}
80+
}

0 commit comments

Comments
 (0)