/* ** Display a pair of stereo images in certain interval to produce 3d ** effects. Glasses are needed to view the image. ** ** Based on B. Land's original codes. ** Modified by Bin Li, AGRL. ** Packing routine written by Bin Li. Program tested by Dave Richers. ** ** */ #include #include #include main() { unsigned long pixarray[1024] [1024], pixarray2[1024][1024]; unsigned char temp[3072][1024]; FILE *fp1, *fp2, *f1; char left[20], right[20]; int count, i, j; int inter; printf ("Enter name of the left image: "); scanf ("%s", left); printf ("Enter name of the right image: "); scanf("%s", right); printf ("Enter swap interval: "); scanf ("%d", &inter); if ((fp1=fopen(left, "rb")) == NULL) { printf("cannot open left image file \n"); exit(1); } if ((fp2=fopen(right,"rb")) == NULL) { printf("cannot open right image file \n"); exit(1); } if((f1 = fopen("/dev/ttyd1","w"))==NULL) { printf("cannot open /dev/ttyd1 \n"); exit(1); } maxsize (1024,1024); keepaspect(1,1); winopen ("3D Image"); RGBmode(); swapinterval(inter); doublebuffer(); gconfig(); RGBcolor(0,0,0); clear(); swapbuffers(); RGBcolor(0,0,0); clear(); /* read_pixs(); */ fread (temp, sizeof (temp), 1, fp1); count = 0; for (i=0; i<3072; i=i+3) { for (j=0; j<1024; j++) { pixarray[count][j] |= temp[i][j]; pixarray[count][j] |= temp[i+1][j] << 8; pixarray[count][j] |= temp[i+2][j] << 16; } count++; } lrectwrite(0,0,1023,1023,pixarray); /* read_pixs(argv[2]); */ fread (temp, sizeof (temp), 1, fp2); count = 0; for (i=0; i<3072; i=i+3) { for (j=0; j<1024; j++) { pixarray2[count][j] |= temp[i][j]; pixarray2[count][j] |= temp[i+1][j] << 8; pixarray2[count][j] |= temp[i+2][j] << 16; } count++; } swapbuffers(); lrectwrite(0,0,1023,1023,pixarray2); while(1) { fputs("A\n", f1); swapbuffers(); /* if (getbutton(LEFTMOUSE)) { fputs (" \n ",f1); } */ } }