#include "stdio.h" #include "stdlib.h" #include "string.h" #include "math.h" /* Program to experiment with lenticular sheet generation Expect a series of images of the form base0000.ppm, base0001.ppm, etc Supports forward or reverse image ordering */ typedef struct { unsigned char r,g,b; } PIXEL; void GetImageSize(char *,int *,int *); void ReadImage(char *,int,int,PIXEL *); int main(int argc,char **argv) { int i,j,k,f,index; int inew,jnew; int dir = 1; int n,width,height,nwidth,nheight; char basename[64]; char fname[128]; PIXEL *lenticular,*image; PIXEL white = {255,255,255},black = {0,0,0}; /* Check and get the command line arguments */ if (argc < 3) { fprintf(stderr,"Usage: %s basename nimage [r]\n",argv[0]); exit(-1); } n = atoi(argv[2]); if (n < 2) { fprintf(stderr,"There must be at least 2 images\n"); exit(-1); } if (argc > 3 && argv[3][0] == 'r') dir = -1; /* Get the image size from the first image. All images must be the same size */ sprintf(fname,"%s%04d.ppm",argv[1],0); GetImageSize(fname,&width,&height); fprintf(stderr,"The images are all assumed to be %d by %d\n",width,height); /* Create an image for the combined image */ nwidth = n * width; nheight = n * height; if ((lenticular = malloc(nwidth*nheight*sizeof(PIXEL))) == NULL) { fprintf(stderr,"Malloc of lenticular image failed\n"); exit(-1); } /* Make the whole image black */ for (i=0;i