From 4faba574ffbf531095d3c482a7829920d4a9ac11 Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Thu, 5 Jul 2012 19:07:22 -0400 Subject: got rid of extra x and y variables, fixed our fopen, though there is still a problem with it --- fly-tools/background/main.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'fly-tools/background/main.c') diff --git a/fly-tools/background/main.c b/fly-tools/background/main.c index 1440a78..89ebd13 100644 --- a/fly-tools/background/main.c +++ b/fly-tools/background/main.c @@ -59,7 +59,7 @@ int main(int argc, char **argv ) { double green, red, blue; - int i,j, k, x, y; + int i,j, k; int image = 0; char filename[256]; @@ -104,7 +104,6 @@ int main(int argc, char **argv ) { printf("number of images: %d \n", nImages); - // initialize the storage arrays uint8_t * array = (uint8_t *)malloc(nImages*height*width*3*sizeof(uint8_t)); @@ -117,7 +116,15 @@ int main(int argc, char **argv ) { } // store each pixel in the storage array. array(nImages,height,width,{ R, G, B} ) + input_file = fopen( image_list, "r"); + if(input_file == NULL ) { + printf("error could not open input file"); + exit(1); + } + + while ((fgets(filename, sizeof(filename), input_file)) != NULL ) { + temp = strchr(filename, '\n'); if (temp != NULL) *temp = '\0'; @@ -149,6 +156,8 @@ int main(int argc, char **argv ) { image++; } + fclose(input_file); + // calculate histograms for (j = 0; j < height; j++) { @@ -183,14 +192,14 @@ int main(int argc, char **argv ) { MagickNewImage(output_wand,width,height,p_out); output_iterator=NewPixelIterator(output_wand); - for(x=0;x