Browse Source

Shorter line length

Bob Mottram 2 years ago
parent
commit
fc37b2e4ea
1 changed files with 12 additions and 9 deletions
  1. 12 9
      src/gallery.c

+ 12 - 9
src/gallery.c

@@ -47,7 +47,8 @@ int extract_segments_from_image(image * img)
         (unsigned char*)malloc(img->image_width*img->image_height*
                                sizeof(unsigned char));
     if (!img->segment_map) {
-        printf("Unable to allocate memory for segmentation map of dimensions %dx%d\n",
+        printf("Unable to allocate memory for segmentation" \
+               "map of dimensions %dx%d\n",
                img->image_width, img->image_height);
         return 1;
     }
@@ -68,6 +69,7 @@ int gallery_create(char * directory, gallery * image_gallery)
     struct dirent *ent;
     unsigned int image_bitsperpixel=0;
     char filename[1024];
+    int no_of_images;
 
     image_gallery->no_of_images = 0;
 
@@ -76,18 +78,19 @@ int gallery_create(char * directory, gallery * image_gallery)
         while ((ent = readdir (dir)) != NULL) {
             if (strstr(ent->d_name,".png") != NULL) {
                 sprintf(filename,"%s/%s",directory, ent->d_name);
-                image_gallery->pic[image_gallery->no_of_images].image_data =
+                no_of_images = image_gallery->no_of_images;
+                image_gallery->pic[no_of_images].image_data =
                     read_png_file(filename,
-                                  &image_gallery->pic[image_gallery->no_of_images].image_width,
-                                  &image_gallery->pic[image_gallery->no_of_images].image_height,
+                                  &image_gallery->pic[no_of_images].image_width,
+                                  &image_gallery->pic[no_of_images].image_height,
                                   &image_bitsperpixel);
-                if (image_gallery->pic[image_gallery->no_of_images].image_data != NULL) {
+                if (image_gallery->pic[no_of_images].image_data != NULL) {
                     if (image_bitsperpixel == 24) {
-                        if (image_is_mono(image_gallery->pic[image_gallery->no_of_images].image_data,
-                                          image_gallery->pic[image_gallery->no_of_images].image_width,
-                                          image_gallery->pic[image_gallery->no_of_images].image_height) != 0) {
+                        if (image_is_mono(image_gallery->pic[no_of_images].image_data,
+                                          image_gallery->pic[no_of_images].image_width,
+                                          image_gallery->pic[no_of_images].image_height) != 0) {
                             printf("Segmenting %s\n", ent->d_name);
-                            if (extract_segments_from_image(&image_gallery->pic[image_gallery->no_of_images]) == 0) {
+                            if (extract_segments_from_image(&image_gallery->pic[no_of_images]) == 0) {
                                 image_gallery->no_of_images++;
                                 if (image_gallery->no_of_images >= MAX_IMAGES) break;
                             }