/* combine_band_interleave.c ** this program combine the ** input generic binary image file then output ** "band interleave by line" image! */ #include #include #include #include main(int argc, char **argv) { FILE *f1,*f2, *fout; unsigned long int img_length; unsigned long int img_width, step; unsigned long int num_of_band, bandth_num; unsigned long int count1, count2, count3; unsigned char *store, *sub_row_start; if(argc == 6) { img_length = atoi(argv[1]); img_width = atoi(argv[2]); store = (unsigned char *)malloc(img_width); if((fout = fopen(argv[3],"wb")) == NULL) { fprintf(stderr,"Failed to open %s\n",argv[3]); exit(EXIT_FAILURE); } if((f1 = fopen(argv[4],"rb")) == NULL) { fprintf(stderr,"Failed to open %s\n",argv[4]); exit(EXIT_FAILURE); } if((f2 = fopen(argv[5],"rb")) == NULL) { fprintf(stderr,"Failed to open %s\n",argv[5]); exit(EXIT_FAILURE); } for(count1 = 0; count1 < img_length; count1++) { fread(store,1,img_width,f1); fwrite(store,1,img_width,fout); fread(store,1,img_width,f2); fwrite(store,1,img_width,fout); } fclose(f1); fclose(f2); fclose(fout); free(store); } else printf("\nUsage:\n\tcombine_interleave 'rows in file' ' cols' 'output file' 'input file1' 'file2' .\n\n"); }