/* Image Enhancement Programme */ /* S.D.Price */ /* July 98 */ /* Compiled using North C */ /* By Steve Hawtin */ #include #define MAXWIDTH 1024 main(argc,argv) int argc; char *argv[]; { FILE *fpsrc,*fpout; float const; short count=0,count2=0,width,height,oldheight,pad,loop,count3; unsigned char input,char1=0,widthlsb,widthmsb,heightlsb,heightmsb,outnme[32]; unsigned char value,tempval[2]; unsigned char botval[3][MAXWIDTH],mark,mark2; /* ----------- Get command line args and check for problems, open files. ----------------- */ if(argc!=2&&argc!=3) { puts("\nFormat:\nHam32k [Outputfile]\n\n"); exit(1); } fpsrc=fopen(argv[1],"r"); if(fpsrc==(FILE *)NULL) { puts("\nCant find input file.\n"); exit(1); } if(argc==2){ strcpy(outnme,argv[1]); strcat(outnme,".32k");} else{ strcpy(outnme,argv[2]);} fpout=fopen(outnme,"r"); if(fpout!=(FILE *)NULL) { puts("\nOutput file already exists!\n"); exit(1); } fpout=fopen(outnme,"w"); if(fpout==(FILE *)NULL) { puts("\nI cant open the output file!\n"); exit(1); } /*-------------------------- Begining of main part of program. ------------------------------------*/ puts("\nImage enhancement programme,\nBy SDPrice 1998\n"); /* Prog start banner */ for(count=0;count!=18;count++) { char1=fgetc(fpsrc); /* Read in and output first part of file header. */ fputc(char1,fpout);} widthlsb=fgetc(fpsrc); /* Read in width LeastSignificantByte */ widthmsb=fgetc(fpsrc); /* Read in width MostSB */ width=widthlsb+widthmsb*256; /* Calculate value of width */ if(width>MAXWIDTH){ printf("\nSorry this release can only handle files up to %d wide.",MAXWIDTH); exit(1);} fputc(widthlsb,fpout); /* Output the width value to */ fputc(widthmsb,fpout); /* File header of the output file. */ char1=fgetc(fpsrc); /* Read in and */ fputc(char1,fpout); /* Output the next 2 bytes of the header. */ char1=fgetc(fpsrc); fputc(char1,fpout); heightlsb=fgetc(fpsrc); /* Now read in and convert the height value. */ heightmsb=fgetc(fpsrc); height=(heightlsb+heightmsb*256)*2; /* Times the height value by 2 before outputting */ oldheight=height/2; /* Added later to speed up loop. */ heightmsb=height/256; /* Reconvert to LSB and MSB before */ heightlsb=height%256; fputc(heightlsb,fpout); /* Outputting to the out file. */ fputc(heightmsb,fpout); printf("Output will be called %s\n",outnme); printf("BMP file. Original dimensions: %d X %d\n",width,oldheight); printf(" New dimensions: %d X %d\n",width,height); puts("File conversion will take some time.\nPercent complete = 0%\b\b\b\b"); pad=4-((width*3)%4); /* Calculate no. of padding 0's per line required. */ pad=pad&3; /* Now at pos 24, data starts at 109. Read in and output rest of header. */ for(count=24;count<54;++count) { char1=fgetc(fpsrc); /* Read in and output last part of file header. */ fputc(char1,fpout); } /* ---------------------------------- Begin processing. ----------------------------------------- */ for(loop=0;loop