/******************************************************************** * This is a template that can be used to write programs which * * manipulate raster files. * * * * To compile, type "cc rffmain.c rff.o -o example -lpixrect -lm" * * * * (NB: rff.o must be within the same directory) * * * * After compiling, to run type "example"; it will them prompt you * * for some information (eg. input/output files). * ********************************************************************/ # include # include main () { /* ********************************************************************** NAME: Main() DECLARATION OF VARIABLES IN MAIN: temp - output rasterfile screen - a pixrect that contains the rasterfile image to be manipulated image, final_image - 1D arrays holding input and output images resp. dx, dy - number of columns and number of rows resp. depth - 2^depth = number of grey levels in image fp,out - pointers to sources of input and output respectively colormap - structure that contains the colormap for screen type - the type of rasterfile that is used name1,name2 - hold names of input file, template file(s), and ouput file respectively ********************************************************************** */ struct rasterfile temp; struct pixrect *screen, *read_image(); long *image, *final_image; int dx,dy,depth; FILE *out, *fp; colormap_t colormap; int type = RT_STANDARD; char name1[20],name2[20]; int i,j; printf("Enter name of image to be read\n"); scanf("%s",name1); fp = fopen(name1,"r"); printf("Enter name of output file\n"); scanf("%s",name2); out = fopen(name2,"w"); /* Reading in input image */ screen=read_image(fp, &colormap); dx=screen->pr_size.x; /* number of columns */ dy=screen->pr_size.y; /* number of rows */ depth=screen->pr_depth; /* 2^depth = # grey levels */ /* allocating 1D array to store image */ image=(long *)malloc(dx*dy*sizeof(long)); load_rff_image(screen,image); pr_close(screen); /* allocating 1D array to store output image */ final_image = (long *)malloc(dx*dy*sizeof(long)); /***********PUT BULK OF PROGRAM HERE********************/ /* for eg. here we copy the input array into output array */ for (i=0;i