/* (c) SPDsoft & GTIC 6 septiembre 1993 */ #include #include #include #include "pict.h" #ifdef THINK_C #include #endif #ifdef MYGETOPT char getopt( int argc, char *argv[], char *format ); #endif void usage(char *name); void fatalError(char *name,char *str); void usage(char *name) { fprintf(stderr, "usage: %s [-o output] evenfield oddfield\n",name); exit(-1); } void fatalError(char *name,char *str) { fprintf(stderr, "%s: Fatal Error: %s. bye...\n",name,str); exit(-2); } main(int argc,char *argv[]) { char *fname="itrlc.pict",format; int OutputOpt=0; char Verbose=0; Pict pictIn[2],pictOut; int i,j,opcion; int theError=0; int ih=0, iw=0; extern char *optarg; extern int optind,opterr; #ifdef THINK_C argc = ccommand(&argv); #endif while ( (opcion=getopt(argc,argv,"o:vh")) != EOF ) { switch(opcion) { case 'o': theError += ( *optarg==0x00 ); OutputOpt=optind-1; break; case 'v': printf("%s:v. Sat May 20, 1995\n",argv[0]); Verbose=1; break; defatult: usage(argv[0]); } } if ( optind+2!=argc) theError ++; if ( theError!=0) usage(argv[0]); if(Verbose) { printf("%s:output)\t%s\n",argv[0],OutputOpt!=0?argv[OutputOpt]:fname); } for(i=0;i<=1;i++) { if(Verbose) printf("%d)\t%s\n",i,argv[optind+i]); pictIn[i] = pict_open(argv[optind+i],P_READ,0,0,0,NULL); if(pictIn[i]->n_comp==1) fatalError(argv[0],"Not True Color!"); if (iw==0) { iw=pictIn[i]->image_W; ih=pictIn[i]->image_H; if( ih%2 != 0 ) fatalError(argv[0],"Sorry, H must be even"); } else { if((iw!=pictIn[i]->image_W)|| (ih!=pictIn[i]->image_H)) fatalError(argv[0],"Dim Error!"); } if ((pictIn[i]->pixels = (U_char*) malloc((size_t)(iw *pictIn[i]->n_comp+1)))==NULL) fatalError(argv[0],"Buy more memory!"); } pictOut = pict_open(OutputOpt!=0?argv[OutputOpt]:fname,P_WRITE, ih,iw,pictIn[0]->clr_mode,pictIn[0]->map); if ((pictOut->pixels = (U_char*)malloc(iw *pictIn[0]->n_comp))==NULL) fatalError(argv[0],"Buy more memory!"); /******************************************************************/ /* This is the real work */ for(j=1;j<=ih/2;j++) { pict_get_line(pictIn[0],pictIn[0]->pixels); pict_put_line(pictOut,pictIn[0]->pixels); pict_get_line(pictIn[0],pictIn[0]->pixels); pict_get_line(pictIn[1],pictIn[1]->pixels); pict_get_line(pictIn[1],pictIn[1]->pixels); pict_put_line(pictOut,pictIn[1]->pixels); }/* lines */ /* End of real work */ /******************************************************************/ pict_close(pictIn[0]); pict_free(pictIn[0]); pict_close(pictIn[1]); pict_free(pictIn[0]); pict_close(pictOut); pict_free(pictIn[0]); }