#include #include #include #include #include "neuzeichnen.h" #include "mygraph.h" #include "ReadData.h" void usage(const char *message){ printf("%s\n",message); printf("Usage: Contor_mpg [-magnify newx newy xofs yofs]\n" " [-center]\n" " [-nocuts nocuts]\n" " [-noadjust min max cut1 ... cutn]\n" " filename1 ... filenameN\n" "where the datatypes are given by:\n" " int newx newy\n" " double xofs yofs min max cut1 ... cutN\n" "-nocuts needs to be defined before -noadjust\n" "If the filenames should be obtained automatically there is also the\n" "option '-name formatstring increment LargestNumber' which will \n" "automatically write the appropriate filename\n" "(c) Alexander Wagner 2003 (requires mjpegtools)\n"); exit(1); } int main(int argc, char *argv[]) { int number=200,i,j,k,Xsize,Ysize,dummy, compress=0,magnify=0,center=0,newx,newy, nocuts=1,adjust; char **names=NULL,*spointer,*command,addstr[100], ppmstr[500]; int ppmx,ppmy; double *datap=NULL,*cut=NULL,dmin,dmax,xofs,yofs; FILE *ppmfile; if (argc>1) { /* filenames are given as parameters to the program */ i=1; errno=0; while ((i=argc)&&(names==NULL)) usage("No files to process!"); } if (cut==NULL) cut=(double *) malloc(nocuts*sizeof(double)); if (names==NULL){ names = &(argv[i]); number= argc-i; } } else usage("No Arguments!"); InitGraphics(dummy); command = (char *) malloc(256*number*sizeof(char)); for (i=0;i pic.ppm"); system(command); /* There is an undocumented restriction on ppmtoy4m which requires the dimensions of the ppm image to be powers of two. I could not find any documentation of this problem, but this is supposed to be a workaround. First we determine the size of the ppm image and then, using pnmcut, we reduce its size as required.*/ ppmfile=fopen("pic.ppm","r"); fscanf(ppmfile,"%s %i %i",&(ppmstr[0]),&ppmx,&ppmy); fclose(ppmfile); printf("Analyse pic.ppm: %s %i %i\n",ppmstr,ppmx,ppmy); if (((ppmx&1)==1) || ((ppmy&1)==1)){ sprintf(command, "cat pic.ppm | pnmcut -width %i -height %i >pic_%05i.ppm", (ppmx>>1)<<1,(ppmy>>1)<<1,i); system(command); } else { sprintf(command,"mv pic.ppm pic_%05i.ppm",i); system(command); } } sprintf(command,"cat "); for (i=0;i