]> bicyclesonthemoon.info Git - ott/enhance/commitdiff
action on multiple pictues finished but not working.
authorb <rowerynaksiezycu@gmail.com>
Tue, 15 Nov 2022 20:35:50 +0000 (20:35 +0000)
committerb <rowerynaksiezycu@gmail.com>
Tue, 15 Nov 2022 20:35:50 +0000 (20:35 +0000)
bluenh.c
core.c
core.h
nofading.c
reveal.c

index db32f5535c6a9acc88e912c4c5aa59ca1e1d36a3..bb0f61bfba01d35e45114686c2f760aadb01adfa 100644 (file)
--- a/bluenh.c
+++ b/bluenh.c
@@ -1,7 +1,7 @@
 /*
 bluenh.c
 ENHANCE the bluepix!
-13.11.2022
+15.11.2022
 
 Copyright (C) 2015, 2022  Balthasar Szczepański
 
@@ -103,7 +103,7 @@ int subtool_bluenh (int argc, char **argv, int argi, char **err)
                data.max = upscale_value(0xFF, info.image_bpc);
                calculate_bluenh_parameters (&data);
                
-               r = action_1picture (
+               r = perform_action_1picture (
                        0,
                        0, 0, 0, 0, 0, 0,
                        &bluenhance,
diff --git a/core.c b/core.c
index 71d514db74a7455c50296b95bf56443e710ee478..2a789dfd8868e43e58e8d0bcc8195ecda11d7d03 100644 (file)
--- a/core.c
+++ b/core.c
@@ -1,7 +1,7 @@
 /*
 core.c
 The tool with multiple enhancements and manipulations of pictures
-14.11.2022
+15.11.2022
 
 Copyright (C) 2014, 2015, 2022  Balthasar Szczepański
 
@@ -635,401 +635,414 @@ int get_info (uint_fast16_t id, struct IL_full_info *info, ILint frame)
        return r;
 }
 
-int action_1picture (
+int perform_action_1picture (
        uint_fast16_t id,
-       ILint x0, ILint y0, ILint f0, ILint width, ILint height, ILint frames,
+       ILint x0, ILint y0, ILint f0,
+       ILint width, ILint height, ILint frames,
        ACTION_F *function,
        FLAG_TYPE flags,
        void *data
 )
 {
-       ILint actual_frames;
-       struct PixelInfo p;
-       int r = 0;
+       return perform_action(
+               1,
+               &id,
+               &x0, &y0, &f0,
+               width, height, frames,
+               function,
+               &flags,
+               data
+       );
        
-       p.flags = flags & ~(IS_MULTIPLE);
        
-       if (id >= n_pictures)
-               return EINVAL;
+       // ILint actual_frames;
+       // struct PixelInfo p;
+       // int r = 0;
        
-       if (!(picture[id].open))
-               return EINVAL;
+       // p.flags = flags & ~(IS_MULTIPLE);
        
-       ilBindImage(picture[id].handle);
-       get_info(id, &(p.info), 0);
+       // if (id >= n_pictures)
+               // return EINVAL;
        
-       if (p.info.num_images > 0)
-               p.flags |= IS_MULTIPLE;
-       actual_frames = (p.flags & CAN_BE_MULTIPLE) ? (p.info.num_images+1) : 1;
+       // if (!(picture[id].open))
+               // return EINVAL;
        
-       if (!(flags & IN_WINDOW))
-       {
-               f0 = 0;
-               frames = actual_frames;
-       }
+       // ilBindImage(picture[id].handle);
+       // get_info(id, &(p.info), 0);
        
-       for (
-               p.f_window = 0, p.f_pict = f0;
-               (p.f_window  < frames) && (r == 0);
-               ++(p.f_window), ++(p.f_pict)
-       ){
-               if ((p.f_pict >= 0) && (p.f_pict <= p.info.num_images))
-               {
-                       ilBindImage(picture[id].handle);
-                       ilActiveImage(p.f_pict);
-                       p.data = ilGetData();
-                       p.flags &= ~(IS_GRAY|IS_INDEXED|IS_OVER_8BIT|IS_PALETTE_ONLY);
+       // if (p.info.num_images > 0)
+               // p.flags |= IS_MULTIPLE;
+       // actual_frames = (p.flags & CAN_BE_MULTIPLE) ? (p.info.num_images+1) : 1;
+       
+       // if (!(flags & IN_WINDOW))
+       // {
+               // f0 = 0;
+               // frames = actual_frames;
+       // }
+       
+       // for (
+               // p.f_window = 0, p.f_pict = f0;
+               // (p.f_window  < frames) && (r == 0);
+               // ++(p.f_window), ++(p.f_pict)
+       // ){
+               // if ((p.f_pict >= 0) && (p.f_pict <= p.info.num_images))
+               // {
+                       // ilBindImage(picture[id].handle);
+                       // ilActiveImage(p.f_pict);
+                       // p.data = ilGetData();
+                       // p.flags &= ~(IS_GRAY|IS_INDEXED|IS_OVER_8BIT|IS_PALETTE_ONLY);
                        
-                       p.alpha_offset = 0;
-                       p.value_offset = 0;
-                       p.index_offset = 0;
-                       p.red_offset = 0;
-                       p.green_offset = 0;
-                       p.blue_offset = 0;
+                       // p.alpha_offset = 0;
+                       // p.value_offset = 0;
+                       // p.index_offset = 0;
+                       // p.red_offset = 0;
+                       // p.green_offset = 0;
+                       // p.blue_offset = 0;
                        
-                       switch (p.info.image_format)
-                       {
-                       case IL_COLOUR_INDEX:
-                               p.flags |= IS_INDEXED;
-                               p.palette = ilGetPalette();
-                               switch (p.info.palette_type)
-                               {
-                               case IL_PAL_BGR32:
-                               case IL_PAL_RGB32:
-                                       p.flags |= IS_OVER_8BIT;
-                                       break;
-                               case IL_PAL_BGRA32:
-                                       p.flags |= HAS_ALPHA;
-                                       p.alpha_offset = 3;
-                               case IL_PAL_BGR24:
-                                       p.red_offset = 2;
-                                       p.green_offset = 1;
-                                       p.blue_offset = 0;
-                                       break;
-                               case IL_PAL_RGBA32:
-                                       p.flags |= HAS_ALPHA;
-                                       p.alpha_offset = 3;
-                               case IL_PAL_RGB24:
-                               default:
-                                       p.red_offset = 0;
-                                       p.green_offset = 1;
-                                       p.blue_offset = 2;
-                                       break;
-                               }
-                               break;
-                       case IL_LUMINANCE_ALPHA:
-                               p.flags |= HAS_ALPHA;
-                               p.alpha_offset = 1 * p.info.image_bpc;
-                       case IL_LUMINANCE:
-                               p.flags |= IS_GRAY;
-                               p.value_offset = 0 * p.info.image_bpc;
-                               break;
-                       case IL_BGRA:
-                               p.flags |= HAS_ALPHA;
-                               p.alpha_offset = 3 * p.info.image_bpc;
-                       case IL_BGR:
-                               p.red_offset = 2 * p.info.image_bpc;
-                               p.green_offset = 1 * p.info.image_bpc;
-                               p.blue_offset = 0 * p.info.image_bpc;
-                               break;
-                       case IL_RGBA:
-                               p.flags |= HAS_ALPHA;
-                               p.alpha_offset = 3 * p.info.image_bpc;
-                       case IL_RGB:
-                       default:
-                               p.red_offset = 0 * p.info.image_bpc;
-                               p.green_offset = 1 * p.info.image_bpc;
-                               p.blue_offset = 2 * p.info.image_bpc;
-                               break;
-                       }
-                       if (p.info.image_bpc > 1)
-                               p.flags |= IS_OVER_8BIT;
+                       // switch (p.info.image_format)
+                       // {
+                       // case IL_COLOUR_INDEX:
+                               // p.flags |= IS_INDEXED;
+                               // p.palette = ilGetPalette();
+                               // switch (p.info.palette_type)
+                               // {
+                               // case IL_PAL_BGR32:
+                               // case IL_PAL_RGB32:
+                                       // p.flags |= IS_OVER_8BIT;
+                                       // break;
+                               // case IL_PAL_BGRA32:
+                                       // p.flags |= HAS_ALPHA;
+                                       // p.alpha_offset = 3;
+                               // case IL_PAL_BGR24:
+                                       // p.red_offset = 2;
+                                       // p.green_offset = 1;
+                                       // p.blue_offset = 0;
+                                       // break;
+                               // case IL_PAL_RGBA32:
+                                       // p.flags |= HAS_ALPHA;
+                                       // p.alpha_offset = 3;
+                               // case IL_PAL_RGB24:
+                               // default:
+                                       // p.red_offset = 0;
+                                       // p.green_offset = 1;
+                                       // p.blue_offset = 2;
+                                       // break;
+                               // }
+                               // break;
+                       // case IL_LUMINANCE_ALPHA:
+                               // p.flags |= HAS_ALPHA;
+                               // p.alpha_offset = 1 * p.info.image_bpc;
+                       // case IL_LUMINANCE:
+                               // p.flags |= IS_GRAY;
+                               // p.value_offset = 0 * p.info.image_bpc;
+                               // break;
+                       // case IL_BGRA:
+                               // p.flags |= HAS_ALPHA;
+                               // p.alpha_offset = 3 * p.info.image_bpc;
+                       // case IL_BGR:
+                               // p.red_offset = 2 * p.info.image_bpc;
+                               // p.green_offset = 1 * p.info.image_bpc;
+                               // p.blue_offset = 0 * p.info.image_bpc;
+                               // break;
+                       // case IL_RGBA:
+                               // p.flags |= HAS_ALPHA;
+                               // p.alpha_offset = 3 * p.info.image_bpc;
+                       // case IL_RGB:
+                       // default:
+                               // p.red_offset = 0 * p.info.image_bpc;
+                               // p.green_offset = 1 * p.info.image_bpc;
+                               // p.blue_offset = 2 * p.info.image_bpc;
+                               // break;
+                       // }
+                       // if (p.info.image_bpc > 1)
+                               // p.flags |= IS_OVER_8BIT;
                        
-                       if ((p.flags & IS_INDEXED) && (p.flags & OK_PALETTE_ONLY))
-                       {
-                               p.flags |= IS_PALETTE_ONLY;
-                               for (
-                                       p.index = 0, p.pal_offset=0;
-                                       (p.index < p.info.palette_num_cols) && (r == 0);
-                                       ++p.index, p.pal_offset += p.info.palette_bpp
-                               ){
-                                       if (!(p.flags & NOT_READABLE))
-                                       {
-                                               p.red   = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.red_offset)));
-                                               p.green = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.green_offset)));
-                                               p.blue  = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.blue_offset)));
-                                               if (p.flags & HAS_ALPHA)
-                                               {
-                                                       if (p.flags & CANNOT_HAVE_ALPHA)
-                                                               p.alpha = 0xFF;
-                                                       else
-                                                               p.alpha = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)));
-                                               }
-                                               else if (p.flags & MUST_HAVE_ALPHA)
-                                                       p.alpha = 0xFF;
-                                               if (p.flags & MUST_BE_GRAY)
-                                                       p.value = (p.red + p.green + p.blue) / 3;
-                                       }
+                       // if ((p.flags & IS_INDEXED) && (p.flags & OK_PALETTE_ONLY))
+                       // {
+                               // p.flags |= IS_PALETTE_ONLY;
+                               // for (
+                                       // p.index = 0, p.pal_offset=0;
+                                       // (p.index < p.info.palette_num_cols) && (r == 0);
+                                       // ++p.index, p.pal_offset += p.info.palette_bpp
+                               // ){
+                                       // if (!(p.flags & NOT_READABLE))
+                                       // {
+                                               // p.red   = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.red_offset)));
+                                               // p.green = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.green_offset)));
+                                               // p.blue  = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.blue_offset)));
+                                               // if (p.flags & HAS_ALPHA)
+                                               // {
+                                                       // if (p.flags & CANNOT_HAVE_ALPHA)
+                                                               // p.alpha = 0xFF;
+                                                       // else
+                                                               // p.alpha = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)));
+                                               // }
+                                               // else if (p.flags & MUST_HAVE_ALPHA)
+                                                       // p.alpha = 0xFF;
+                                               // if (p.flags & MUST_BE_GRAY)
+                                                       // p.value = (p.red + p.green + p.blue) / 3;
+                                       // }
                                        
-                                       r = function(1, &p, data);
-                                       if (r)
-                                               break;
+                                       // r = function(1, &p, data);
+                                       // if (r)
+                                               // break;
                                        
-                                       if (!(p.flags & NOT_READABLE))
-                                       {
-                                               if (p.flags & MUST_BE_GRAY)
-                                               {
-                                                       p.red   = p.value;
-                                                       p.green = p.value;
-                                                       p.blue  = p.value;
-                                               }
-                                               if (p.flags & HAS_ALPHA)
-                                               {
-                                                       if (p.flags & CANNOT_HAVE_ALPHA)
-                                                               p.alpha = 0xFF;
-                                                       *((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)) = (ILubyte)p.alpha;
-                                               }
-                                               *((ILubyte*)(p.palette + p.pal_offset + p.red_offset))   = (ILubyte)p.red;
-                                               *((ILubyte*)(p.palette + p.pal_offset + p.green_offset)) = (ILubyte)p.green;
-                                               *((ILubyte*)(p.palette + p.pal_offset + p.blue_offset))  = (ILubyte)p.blue;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               p.line_bytes = p.info.image_bytes_per_pixel * p.info.image_width;
-                               p.frame_bytes = p.line_bytes * p.info.image_height;
+                                       // if (!(p.flags & NOT_READABLE))
+                                       // {
+                                               // if (p.flags & MUST_BE_GRAY)
+                                               // {
+                                                       // p.red   = p.value;
+                                                       // p.green = p.value;
+                                                       // p.blue  = p.value;
+                                               // }
+                                               // if (p.flags & HAS_ALPHA)
+                                               // {
+                                                       // if (p.flags & CANNOT_HAVE_ALPHA)
+                                                               // p.alpha = 0xFF;
+                                                       // *((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)) = (ILubyte)p.alpha;
+                                               // }
+                                               // *((ILubyte*)(p.palette + p.pal_offset + p.red_offset))   = (ILubyte)p.red;
+                                               // *((ILubyte*)(p.palette + p.pal_offset + p.green_offset)) = (ILubyte)p.green;
+                                               // *((ILubyte*)(p.palette + p.pal_offset + p.blue_offset))  = (ILubyte)p.blue;
+                                       // }
+                               // }
+                       // }
+                       // else
+                       // {
+                               // p.line_bytes = p.info.image_bytes_per_pixel * p.info.image_width;
+                               // p.frame_bytes = p.line_bytes * p.info.image_height;
                                
-                               if (p.info.image_origin == IL_ORIGIN_LOWER_LEFT)
-                               {
-                                       p.line_start = p.frame_bytes - p.line_bytes;
-                                       p.line_bytes = 0 - p.line_bytes;
-                               }
-                               else
-                                       p.line_start = 0;
+                               // if (p.info.image_origin == IL_ORIGIN_LOWER_LEFT)
+                               // {
+                                       // p.line_start = p.frame_bytes - p.line_bytes;
+                                       // p.line_bytes = 0 - p.line_bytes;
+                               // }
+                               // else
+                                       // p.line_start = 0;
                                
-                               if (!(flags & IN_WINDOW))
-                               {
-                                       x0 = 0;
-                                       y0 = 0;
-                                       width = p.info.image_width;
-                                       height = p.info.image_height;
-                               }
+                               // if (!(flags & IN_WINDOW))
+                               // {
+                                       // x0 = 0;
+                                       // y0 = 0;
+                                       // width = p.info.image_width;
+                                       // height = p.info.image_height;
+                               // }
 
-                               for (
-                                       p.y_window = 0, p.y_pict = y0, p.line_offset = p.line_start + (p.y_pict * p.line_bytes);
-                                       (p.y_window < height) && (r == 0);
-                                       ++p.y_window, ++p.y_pict, p.line_offset += p.line_bytes
-                               ){
-                                       if ((p.y_pict >= 0) && (p.y_pict < p.info.image_height))
-                                       {
-                                               for (
-                                                       p.x_window = 0, p.x_pict = x0, p.pixel_offset = p.line_offset + (p.x_pict * p.info.image_bytes_per_pixel);
-                                                       (p.x_window < width) && (r == 0);
-                                                       ++p.x_window, ++p.x_pict, p.pixel_offset += p.info.image_bytes_per_pixel
-                                               ){
-                                                       if ((p.x_pict >=0) && (p.x_pict < p.info.image_width))
-                                                       {
-                                                               if (!(p.flags & NOT_READABLE))
-                                                               {
-                                                                       /* can this be done better? think about it */
-                                                                       switch (p.info.image_type)
-                                                                       {
-                                                                       case IL_INT:
-                                                                       case IL_UNSIGNED_INT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       p.index = *((ILuint*)(p.data + p.pixel_offset + p.index_offset));
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               p.value = *((ILuint*)(p.data + p.pixel_offset + p.value_offset));
-                                                                                       else
-                                                                                       {
-                                                                                               p.red   = *((ILuint*)(p.data + p.pixel_offset + p.red_offset));
-                                                                                               p.green = *((ILuint*)(p.data + p.pixel_offset + p.green_offset));
-                                                                                               p.blue  = *((ILuint*)(p.data + p.pixel_offset + p.blue_offset));
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               p.alpha = *((ILuint*)(p.data + p.pixel_offset + p.alpha_offset));
-                                                                               }
-                                                                               break;
-                                                                       case IL_SHORT:
-                                                                       case IL_UNSIGNED_SHORT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       p.index = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.index_offset)));
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               p.value = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.value_offset)));
-                                                                                       else
-                                                                                       {
-                                                                                               p.red   = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.red_offset)));
-                                                                                               p.green = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.green_offset)));
-                                                                                               p.blue  = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.blue_offset)));
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               p.alpha = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.alpha_offset)));
-                                                                               }
-                                                                               break;
-                                                                       case IL_BYTE:
-                                                                       case IL_UNSIGNED_BYTE:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       p.index = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.index_offset)));
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               p.value = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.value_offset)));
-                                                                                       else
-                                                                                       {
-                                                                                               p.red   = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.red_offset)));
-                                                                                               p.green = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.green_offset)));
-                                                                                               p.blue  = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.blue_offset)));
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               p.alpha = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.alpha_offset)));
-                                                                               }
-                                                                               break;
-                                                                       default:
-                                                                               break;
-                                                                       }
+                               // for (
+                                       // p.y_window = 0, p.y_pict = y0, p.line_offset = p.line_start + (p.y_pict * p.line_bytes);
+                                       // (p.y_window < height) && (r == 0);
+                                       // ++p.y_window, ++p.y_pict, p.line_offset += p.line_bytes
+                               // ){
+                                       // if ((p.y_pict >= 0) && (p.y_pict < p.info.image_height))
+                                       // {
+                                               // for (
+                                                       // p.x_window = 0, p.x_pict = x0, p.pixel_offset = p.line_offset + (p.x_pict * p.info.image_bytes_per_pixel);
+                                                       // (p.x_window < width) && (r == 0);
+                                                       // ++p.x_window, ++p.x_pict, p.pixel_offset += p.info.image_bytes_per_pixel
+                                               // ){
+                                                       // if ((p.x_pict >=0) && (p.x_pict < p.info.image_width))
+                                                       // {
+                                                               // if (!(p.flags & NOT_READABLE))
+                                                               // {
+                                                                       // /* can this be done better? think about it */
+                                                                       // switch (p.info.image_type)
+                                                                       // {
+                                                                       // case IL_INT:
+                                                                       // case IL_UNSIGNED_INT:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // p.index = *((ILuint*)(p.data + p.pixel_offset + p.index_offset));
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // p.value = *((ILuint*)(p.data + p.pixel_offset + p.value_offset));
+                                                                                       // else
+                                                                                       // {
+                                                                                               // p.red   = *((ILuint*)(p.data + p.pixel_offset + p.red_offset));
+                                                                                               // p.green = *((ILuint*)(p.data + p.pixel_offset + p.green_offset));
+                                                                                               // p.blue  = *((ILuint*)(p.data + p.pixel_offset + p.blue_offset));
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // p.alpha = *((ILuint*)(p.data + p.pixel_offset + p.alpha_offset));
+                                                                               // }
+                                                                               // break;
+                                                                       // case IL_SHORT:
+                                                                       // case IL_UNSIGNED_SHORT:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // p.index = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.index_offset)));
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // p.value = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.value_offset)));
+                                                                                       // else
+                                                                                       // {
+                                                                                               // p.red   = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.red_offset)));
+                                                                                               // p.green = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.green_offset)));
+                                                                                               // p.blue  = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.blue_offset)));
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // p.alpha = (ILuint)(*((ILushort*)(p.data + p.pixel_offset + p.alpha_offset)));
+                                                                               // }
+                                                                               // break;
+                                                                       // case IL_BYTE:
+                                                                       // case IL_UNSIGNED_BYTE:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // p.index = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.index_offset)));
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // p.value = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.value_offset)));
+                                                                                       // else
+                                                                                       // {
+                                                                                               // p.red   = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.red_offset)));
+                                                                                               // p.green = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.green_offset)));
+                                                                                               // p.blue  = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.blue_offset)));
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // p.alpha = (ILuint)(*((ILubyte*)(p.data + p.pixel_offset + p.alpha_offset)));
+                                                                               // }
+                                                                               // break;
+                                                                       // default:
+                                                                               // break;
+                                                                       // }
                                                                        
-                                                                       if ((p.flags & IS_INDEXED) && (p.flags & CANNOT_BE_INDEXED))
-                                                                       {
-                                                                               if (p.index < p.info.palette_num_cols)
-                                                                               {
-                                                                                       p.pal_offset = p.index * p.info.palette_bpp;
-                                                                                       p.red   = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.red_offset)));
-                                                                                       p.green = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.green_offset)));
-                                                                                       p.blue  = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.blue_offset)));
-                                                                                       if (p.flags & HAS_ALPHA)
-                                                                                               p.alpha = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)));
-                                                                               }
-                                                                       }
+                                                                       // if ((p.flags & IS_INDEXED) && (p.flags & CANNOT_BE_INDEXED))
+                                                                       // {
+                                                                               // if (p.index < p.info.palette_num_cols)
+                                                                               // {
+                                                                                       // p.pal_offset = p.index * p.info.palette_bpp;
+                                                                                       // p.red   = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.red_offset)));
+                                                                                       // p.green = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.green_offset)));
+                                                                                       // p.blue  = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.blue_offset)));
+                                                                                       // if (p.flags & HAS_ALPHA)
+                                                                                               // p.alpha = (ILuint)(*((ILubyte*)(p.palette + p.pal_offset + p.alpha_offset)));
+                                                                               // }
+                                                                       // }
                                                                        
-                                                                       if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
-                                                                       {
-                                                                               p.red   = p.value;
-                                                                               p.green = p.value;
-                                                                               p.blue  = p.value;
-                                                                       }
-                                                                       else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
-                                                                               p.value = (p.red + p.green + p.blue) / 3;
+                                                                       // if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
+                                                                       // {
+                                                                               // p.red   = p.value;
+                                                                               // p.green = p.value;
+                                                                               // p.blue  = p.value;
+                                                                       // }
+                                                                       // else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
+                                                                               // p.value = (p.red + p.green + p.blue) / 3;
                                                                        
-                                                                       if (((!(p.flags & HAS_ALPHA)) && (p.flags & MUST_HAVE_ALPHA)) || ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA)))
-                                                                       {
-                                                                               switch (p.info.image_type)
-                                                                               {
-                                                                               case IL_INT:
-                                                                               case IL_UNSIGNED_INT:
-                                                                                       p.alpha = 0xFFFFFFFF;
-                                                                                       break;
-                                                                               case IL_SHORT:
-                                                                               case IL_UNSIGNED_SHORT:
-                                                                                       p.alpha = 0xFFFF;
-                                                                                       break;
-                                                                               case IL_BYTE:
-                                                                               case IL_UNSIGNED_BYTE:
-                                                                                       p.alpha = 0xFF;
-                                                                                       break;
-                                                                               default:
-                                                                                       break;
-                                                                               }
-                                                                       }
-                                                               }
+                                                                       // if (((!(p.flags & HAS_ALPHA)) && (p.flags & MUST_HAVE_ALPHA)) || ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA)))
+                                                                       // {
+                                                                               // switch (p.info.image_type)
+                                                                               // {
+                                                                               // case IL_INT:
+                                                                               // case IL_UNSIGNED_INT:
+                                                                                       // p.alpha = 0xFFFFFFFF;
+                                                                                       // break;
+                                                                               // case IL_SHORT:
+                                                                               // case IL_UNSIGNED_SHORT:
+                                                                                       // p.alpha = 0xFFFF;
+                                                                                       // break;
+                                                                               // case IL_BYTE:
+                                                                               // case IL_UNSIGNED_BYTE:
+                                                                                       // p.alpha = 0xFF;
+                                                                                       // break;
+                                                                               // default:
+                                                                                       // break;
+                                                                               // }
+                                                                       // }
+                                                               // }
                                                                
-                                                               r = function(1, &p, data);
-                                                               if (r)
-                                                                       break;
+                                                               // r = function(1, &p, data);
+                                                               // if (r)
+                                                                       // break;
                                                                
-                                                               if (!(p.flags & NOT_WRITABLE))
-                                                               {
-                                                                       if ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA))
-                                                                               p.alpha = 0xFFFFFFFF;
+                                                               // if (!(p.flags & NOT_WRITABLE))
+                                                               // {
+                                                                       // if ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA))
+                                                                               // p.alpha = 0xFFFFFFFF;
                                                                        
-                                                                       else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
-                                                                       {
-                                                                               p.red   = p.value;
-                                                                               p.green = p.value;
-                                                                               p.blue  = p.value;
-                                                                       }
-                                                                       else if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
-                                                                               p.value = (p.red + p.green + p.blue) / 3;
+                                                                       // else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
+                                                                       // {
+                                                                               // p.red   = p.value;
+                                                                               // p.green = p.value;
+                                                                               // p.blue  = p.value;
+                                                                       // }
+                                                                       // else if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
+                                                                               // p.value = (p.red + p.green + p.blue) / 3;
                                                                        
-                                                                       switch (p.info.image_type)
-                                                                       {
-                                                                       case IL_INT:
-                                                                       case IL_UNSIGNED_INT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILuint*)(p.data + p.pixel_offset + p.index_offset)) = p.index;
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.value_offset)) = p.value;
-                                                                                       else
-                                                                                       {
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.red_offset))   = p.red;
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.green_offset)) = p.green;
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.blue_offset))  = p.blue;
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
-                                                                               }
-                                                                               break;
-                                                                       case IL_SHORT:
-                                                                       case IL_UNSIGNED_SHORT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILushort*)(p.data + p.pixel_offset + p.index_offset)) = (ILushort)p.index;
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.value_offset)) = (ILushort)p.value;
-                                                                                       else
-                                                                                       {
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.red_offset))   = (ILushort)p.red;
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.green_offset)) = (ILushort)p.green;
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.blue_offset))  = (ILushort)p.blue;
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILushort)p.alpha;
-                                                                               }
-                                                                               break;
-                                                                       case IL_BYTE:
-                                                                       case IL_UNSIGNED_BYTE:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILubyte*)(p.data + p.pixel_offset + p.index_offset)) = (ILubyte)p.index;
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.value_offset)) = (ILubyte)p.value;
-                                                                                       else
-                                                                                       {
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.red_offset))   = (ILubyte)p.red;
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.green_offset)) = (ILubyte)p.green;
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.blue_offset))  = (ILubyte)p.blue;
-                                                                                       }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
-                                                                               }
-                                                                               break;
-                                                                       default:
-                                                                               break;
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
+                                                                       // switch (p.info.image_type)
+                                                                       // {
+                                                                       // case IL_INT:
+                                                                       // case IL_UNSIGNED_INT:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // *((ILuint*)(p.data + p.pixel_offset + p.index_offset)) = p.index;
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // *((ILuint*)(p.data + p.pixel_offset + p.value_offset)) = p.value;
+                                                                                       // else
+                                                                                       // {
+                                                                                               // *((ILuint*)(p.data + p.pixel_offset + p.red_offset))   = p.red;
+                                                                                               // *((ILuint*)(p.data + p.pixel_offset + p.green_offset)) = p.green;
+                                                                                               // *((ILuint*)(p.data + p.pixel_offset + p.blue_offset))  = p.blue;
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // *((ILuint*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
+                                                                               // }
+                                                                               // break;
+                                                                       // case IL_SHORT:
+                                                                       // case IL_UNSIGNED_SHORT:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // *((ILushort*)(p.data + p.pixel_offset + p.index_offset)) = (ILushort)p.index;
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // *((ILushort*)(p.data + p.pixel_offset + p.value_offset)) = (ILushort)p.value;
+                                                                                       // else
+                                                                                       // {
+                                                                                               // *((ILushort*)(p.data + p.pixel_offset + p.red_offset))   = (ILushort)p.red;
+                                                                                               // *((ILushort*)(p.data + p.pixel_offset + p.green_offset)) = (ILushort)p.green;
+                                                                                               // *((ILushort*)(p.data + p.pixel_offset + p.blue_offset))  = (ILushort)p.blue;
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // *((ILushort*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILushort)p.alpha;
+                                                                               // }
+                                                                               // break;
+                                                                       // case IL_BYTE:
+                                                                       // case IL_UNSIGNED_BYTE:
+                                                                               // if(p.flags & IS_INDEXED)
+                                                                                       // *((ILubyte*)(p.data + p.pixel_offset + p.index_offset)) = (ILubyte)p.index;
+                                                                               // else
+                                                                               // {
+                                                                                       // if(p.flags & IS_GRAY)
+                                                                                               // *((ILubyte*)(p.data + p.pixel_offset + p.value_offset)) = (ILubyte)p.value;
+                                                                                       // else
+                                                                                       // {
+                                                                                               // *((ILubyte*)(p.data + p.pixel_offset + p.red_offset))   = (ILubyte)p.red;
+                                                                                               // *((ILubyte*)(p.data + p.pixel_offset + p.green_offset)) = (ILubyte)p.green;
+                                                                                               // *((ILubyte*)(p.data + p.pixel_offset + p.blue_offset))  = (ILubyte)p.blue;
+                                                                                       // }
+                                                                                       // if(p.flags & HAS_ALPHA)
+                                                                                               // *((ILubyte*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
+                                                                               // }
+                                                                               // break;
+                                                                       // default:
+                                                                               // break;
+                                                                       // }
+                                                               // }
+                                                       // }
+                                               // }
+                                       // }
+                               // }
+                       // }
+               // }
+       // }
        
-       return r;
+       // return r;
 }
 
 int perform_action (
        uint_fast16_t n,
        uint_fast16_t *id,
-       ILint *x0, ILint *y0, *ILint f0, ILint width, ILint height, ILint frames,
+       ILint *x0, ILint *y0, ILint *f0,
+       ILint width, ILint height, ILint frames,
        ACTION_F *function,
        FLAG_TYPE *flags,
        void *data
@@ -1067,7 +1080,7 @@ int perform_action (
                        free(p);
                        return EINVAL;
                }
-               if (!(picture[id].open))
+               if (!(picture[id[i]].open))
                {
                        free(p);
                        return EINVAL;
@@ -1079,8 +1092,8 @@ int perform_action (
                        p[i].flags |= IS_MULTIPLE;
                if (p[i].flags & CAN_BE_MULTIPLE)
                {
-                       if (p[i].num_images+1 < actual_frames)
-                               actual_frames = p[i].num_images+1;
+                       if (p[i].info.num_images+1 < actual_frames)
+                               actual_frames = p[i].info.num_images+1;
                }
                else
                        actual_frames = 1;
@@ -1143,8 +1156,8 @@ int perform_action (
                        
                        if (palette_only)
                        {
-                               if (p[i].palette_num_cols < actual_colours)
-                                       actual_colours = p[i].palette_num_cols;
+                               if (p[i].info.palette_num_cols < actual_colours)
+                                       actual_colours = p[i].info.palette_num_cols;
                        }
                        
                        switch (p[i].info.image_format)
@@ -1213,7 +1226,7 @@ int perform_action (
                                {
                                        p[i].index = 0;
                                        p[i].pal_offset = 0;
-                                       flags[i] |= IS_PALETE_ONLY;
+                                       flags[i] |= IS_PALETTE_ONLY;
                                }
                                for (j=0; (j<actual_colours) && (r==0); ++j)
                                {
@@ -1258,9 +1271,9 @@ int perform_action (
                                                                        p[i].alpha = 0xFF;
                                                                *((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].alpha_offset)) = (ILubyte)(p[i].alpha);
                                                        }
-                                                       *((ILubyte*)(p.[i]palette + p[i].pal_offset + p[i].red_offset))   = (ILubyte)(p[i].red);
-                                                       *((ILubyte*)(p.[i]palette + p[i].pal_offset + p[i].green_offset)) = (ILubyte)(p[i].green);
-                                                       *((ILubyte*)(p.[i]palette + p[i].pal_offset + p[i].blue_offset))  = (ILubyte)(p[i].blue);
+                                                       *((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].red_offset))   = (ILubyte)(p[i].red);
+                                                       *((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].green_offset)) = (ILubyte)(p[i].green);
+                                                       *((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].blue_offset))  = (ILubyte)(p[i].blue);
                                                }
                                                
                                                ++(p[i].index);
@@ -1292,7 +1305,7 @@ int perform_action (
                                        skip_line = 0;
                                        for (i=0; i<n; ++i)
                                        {
-                                               if ((p[i].y_pict < 0) || (p[i].y_pict >= p[i]info.image_height))
+                                               if ((p[i].y_pict < 0) || (p[i].y_pict >= p[i].info.image_height))
                                                {
                                                        skip_line = 1;
                                                        break;
@@ -1309,7 +1322,7 @@ int perform_action (
                                                        skip_pixel = 0;
                                                        for (i=0; i<n; ++i)
                                                        {
-                                                               if ((p[i].x_pict < 0) || (p[i].x_pict >= p[i]info.image_width))
+                                                               if ((p[i].x_pict < 0) || (p[i].x_pict >= p[i].info.image_width))
                                                                {
                                                                        skip_pixel = 1;
                                                                        break;
@@ -1338,7 +1351,7 @@ int perform_action (
                                                                                                        p[i].green = *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].green_offset));
                                                                                                        p[i].blue  = *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].blue_offset));
                                                                                                }
-                                                                                               if (p.flags & HAS_ALPHA)
+                                                                                               if (p[i].flags & HAS_ALPHA)
                                                                                                        p[i].alpha = *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset));
                                                                                        }
                                                                                        break;
@@ -1348,7 +1361,7 @@ int perform_action (
                                                                                                p[i].index = (ILuint)(*((ILushort*)(p[i].data + p[i].pixel_offset + p[i].index_offset)));
                                                                                        else
                                                                                        {
-                                                                                               if(p.flags & IS_GRAY)
+                                                                                               if(p[i].flags & IS_GRAY)
                                                                                                        p[i].value = (ILuint)(*((ILushort*)(p[i].data + p[i].pixel_offset + p[i].value_offset)));
                                                                                                else
                                                                                                {
@@ -1356,17 +1369,17 @@ int perform_action (
                                                                                                        p[i].green = (ILuint)(*((ILushort*)(p[i].data + p[i].pixel_offset + p[i].green_offset)));
                                                                                                        p[i].blue  = (ILuint)(*((ILushort*)(p[i].data + p[i].pixel_offset + p[i].blue_offset)));
                                                                                                }
-                                                                                               if(p.flags & HAS_ALPHA)
+                                                                                               if(p[i].flags & HAS_ALPHA)
                                                                                                        p[i].alpha = (ILuint)(*((ILushort*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset)));
                                                                                        }
                                                                                        break;
                                                                                case IL_BYTE:
                                                                                case IL_UNSIGNED_BYTE:
-                                                                                       if(p.flags & IS_INDEXED)
+                                                                                       if(p[i].flags & IS_INDEXED)
                                                                                                p[i].index = (ILuint)(*((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].index_offset)));
                                                                                        else
                                                                                        {
-                                                                                               if(p.flags & IS_GRAY)
+                                                                                               if(p[i].flags & IS_GRAY)
                                                                                                        p[i].value = (ILuint)(*((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].value_offset)));
                                                                                                else
                                                                                                {
@@ -1374,7 +1387,7 @@ int perform_action (
                                                                                                        p[i].green = (ILuint)(*((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].green_offset)));
                                                                                                        p[i].blue  = (ILuint)(*((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].blue_offset)));
                                                                                                }
-                                                                                               if(p.flags & HAS_ALPHA)
+                                                                                               if(p[i].flags & HAS_ALPHA)
                                                                                                        p[i].alpha = (ILuint)(*((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset)));
                                                                                        }
                                                                                        break;
@@ -1389,129 +1402,128 @@ int perform_action (
                                                                                                p[i].pal_offset = p[i].index * p[i].info.palette_bpp;
                                                                                                p[i].red   = (ILuint)(*((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].red_offset)));
                                                                                                p[i].green = (ILuint)(*((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].green_offset)));
-                                                                                               p[i].blue  = (ILuint)(*((ILubyte*)(p.[i]palette + p[i].pal_offset + p[i].blue_offset)));
+                                                                                               p[i].blue  = (ILuint)(*((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].blue_offset)));
                                                                                                if (p[i].flags & HAS_ALPHA)
                                                                                                        p[i].alpha = (ILuint)(*((ILubyte*)(p[i].palette + p[i].pal_offset + p[i].alpha_offset)));
                                                                                        }
                                                                                }
-                                                                       
-                                                                       if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
-                                                                       {
-                                                                               p.red   = p.value;
-                                                                               p.green = p.value;
-                                                                               p.blue  = p.value;
-                                                                       }
-                                                                       else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
-                                                                               p.value = (p.red + p.green + p.blue) / 3;
-                                                                       
-                                                                       if (((!(p.flags & HAS_ALPHA)) && (p.flags & MUST_HAVE_ALPHA)) || ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA)))
-                                                                       {
-                                                                               switch (p.info.image_type)
+                                                                               
+                                                                               if ((p[i].flags & IS_GRAY) && (p[i].flags & CANNOT_BE_GRAY))
                                                                                {
-                                                                               case IL_INT:
-                                                                               case IL_UNSIGNED_INT:
-                                                                                       p.alpha = 0xFFFFFFFF;
-                                                                                       break;
-                                                                               case IL_SHORT:
-                                                                               case IL_UNSIGNED_SHORT:
-                                                                                       p.alpha = 0xFFFF;
-                                                                                       break;
-                                                                               case IL_BYTE:
-                                                                               case IL_UNSIGNED_BYTE:
-                                                                                       p.alpha = 0xFF;
-                                                                                       break;
-                                                                               default:
-                                                                                       break;
+                                                                                       p[i].red   = p[i].value;
+                                                                                       p[i].green = p[i].value;
+                                                                                       p[i].blue  = p[i].value;
                                                                                }
+                                                                               else if (!(p[i].flags & IS_GRAY) && (p[i].flags & MUST_BE_GRAY))
+                                                                                       p[i].value = (p[i].red + p[i].green + p[i].blue) / 3;
+                                                                               
+                                                                               if (((!(p[i].flags & HAS_ALPHA)) && (p[i].flags & MUST_HAVE_ALPHA)) || ((p[i].flags & HAS_ALPHA) && (p[i].flags & CANNOT_HAVE_ALPHA)))
+                                                                                       p[i].alpha = upscale_value(0xFF, p[i].info.image_bpc);
                                                                        }
                                                                }
                                                                
-                                                               r = function(1, &p, data);
+                                                               r = function(n, p, data);
                                                                if (r)
                                                                        break;
                                                                
-                                                               if (!(p.flags & NOT_WRITABLE))
+                                                               for (i=0; i<n; ++i)
                                                                {
-                                                                       if ((p.flags & HAS_ALPHA) && (p.flags & CANNOT_HAVE_ALPHA))
-                                                                               p.alpha = 0xFFFFFFFF;
-                                                                       
-                                                                       else if (!(p.flags & IS_GRAY) && (p.flags & MUST_BE_GRAY))
+                                                                       if (!(p[i].flags & NOT_WRITABLE))
                                                                        {
-                                                                               p.red   = p.value;
-                                                                               p.green = p.value;
-                                                                               p.blue  = p.value;
-                                                                       }
-                                                                       else if ((p.flags & IS_GRAY) && (p.flags & CANNOT_BE_GRAY))
-                                                                               p.value = (p.red + p.green + p.blue) / 3;
+                                                                               if ((p[i].flags & HAS_ALPHA) && (p[i].flags & CANNOT_HAVE_ALPHA))
+                                                                                       p[i].alpha = upscale_value(0xFF, p[i].info.image_bpc);
+                                                                               
+                                                                               else if (!(p[i].flags & IS_GRAY) && (p[i].flags & MUST_BE_GRAY))
+                                                                               {
+                                                                                       p[i].red   = p[i].value;
+                                                                                       p[i].green = p[i].value;
+                                                                                       p[i].blue  = p[i].value;
+                                                                               }
+                                                                               else if ((p[i].flags & IS_GRAY) && (p[i].flags & CANNOT_BE_GRAY))
+                                                                                       p[i].value = (p[i].red + p[i].green + p[i].blue) / 3;
                                                                        
-                                                                       switch (p.info.image_type)
-                                                                       {
-                                                                       case IL_INT:
-                                                                       case IL_UNSIGNED_INT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILuint*)(p.data + p.pixel_offset + p.index_offset)) = p.index;
-                                                                               else
+                                                                               switch (p[i].info.image_type)
                                                                                {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.value_offset)) = p.value;
+                                                                               case IL_INT:
+                                                                               case IL_UNSIGNED_INT:
+                                                                                       if(p[i].flags & IS_INDEXED)
+                                                                                               *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].index_offset)) = p[i].index;
                                                                                        else
                                                                                        {
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.red_offset))   = p.red;
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.green_offset)) = p.green;
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.blue_offset))  = p.blue;
+                                                                                               if(p[i].flags & IS_GRAY)
+                                                                                                       *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].value_offset)) = p[i].value;
+                                                                                               else
+                                                                                               {
+                                                                                                       *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].red_offset))   = p[i].red;
+                                                                                                       *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].green_offset)) = p[i].green;
+                                                                                                       *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].blue_offset))  = p[i].blue;
+                                                                                               }
+                                                                                               if(p[i].flags & HAS_ALPHA)
+                                                                                                       *((ILuint*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset)) = (ILubyte)p[i].alpha;
                                                                                        }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILuint*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
-                                                                               }
-                                                                               break;
-                                                                       case IL_SHORT:
-                                                                       case IL_UNSIGNED_SHORT:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILushort*)(p.data + p.pixel_offset + p.index_offset)) = (ILushort)p.index;
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.value_offset)) = (ILushort)p.value;
+                                                                                       break;
+                                                                               case IL_SHORT:
+                                                                               case IL_UNSIGNED_SHORT:
+                                                                                       if(p[i].flags & IS_INDEXED)
+                                                                                               *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].index_offset)) = (ILushort)p[i].index;
                                                                                        else
                                                                                        {
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.red_offset))   = (ILushort)p.red;
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.green_offset)) = (ILushort)p.green;
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.blue_offset))  = (ILushort)p.blue;
+                                                                                               if(p[i].flags & IS_GRAY)
+                                                                                                       *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].value_offset)) = (ILushort)p[i].value;
+                                                                                               else
+                                                                                               {
+                                                                                                       *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].red_offset))   = (ILushort)p[i].red;
+                                                                                                       *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].green_offset)) = (ILushort)p[i].green;
+                                                                                                       *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].blue_offset))  = (ILushort)p[i].blue;
+                                                                                               }
+                                                                                               if(p[i].flags & HAS_ALPHA)
+                                                                                                       *((ILushort*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset)) = (ILushort)p[i].alpha;
                                                                                        }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILushort*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILushort)p.alpha;
-                                                                               }
-                                                                               break;
-                                                                       case IL_BYTE:
-                                                                       case IL_UNSIGNED_BYTE:
-                                                                               if(p.flags & IS_INDEXED)
-                                                                                       *((ILubyte*)(p.data + p.pixel_offset + p.index_offset)) = (ILubyte)p.index;
-                                                                               else
-                                                                               {
-                                                                                       if(p.flags & IS_GRAY)
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.value_offset)) = (ILubyte)p.value;
+                                                                                       break;
+                                                                               case IL_BYTE:
+                                                                               case IL_UNSIGNED_BYTE:
+                                                                                       if(p[i].flags & IS_INDEXED)
+                                                                                               *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].index_offset)) = (ILubyte)p[i].index;
                                                                                        else
                                                                                        {
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.red_offset))   = (ILubyte)p.red;
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.green_offset)) = (ILubyte)p.green;
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.blue_offset))  = (ILubyte)p.blue;
+                                                                                               if(p[i].flags & IS_GRAY)
+                                                                                                       *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].value_offset)) = (ILubyte)p[i].value;
+                                                                                               else
+                                                                                               {
+                                                                                                       *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].red_offset))   = (ILubyte)p[i].red;
+                                                                                                       *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].green_offset)) = (ILubyte)p[i].green;
+                                                                                                       *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].blue_offset))  = (ILubyte)p[i].blue;
+                                                                                               }
+                                                                                               if(p[i].flags & HAS_ALPHA)
+                                                                                                       *((ILubyte*)(p[i].data + p[i].pixel_offset + p[i].alpha_offset)) = (ILubyte)p[i].alpha;
                                                                                        }
-                                                                                       if(p.flags & HAS_ALPHA)
-                                                                                               *((ILubyte*)(p.data + p.pixel_offset + p.alpha_offset)) = (ILubyte)p.alpha;
+                                                                                       break;
+                                                                               default:
+                                                                                       break;
                                                                                }
-                                                                               break;
-                                                                       default:
-                                                                               break;
                                                                        }
                                                                }
                                                        }
+                                                       for (i=0; i<n; ++i)
+                                                       {
+                                                               ++(p[i].x_window);
+                                                               ++(p[i].x_pict);
+                                                               p[i].pixel_offset = p[i].info.image_bytes_per_pixel;
+                                                       }
                                                }
                                        }
+                                       for (i=0; i<n; ++i)
+                                       {
+                                               ++(p[i].y_window);
+                                               ++(p[i].y_pict);
+                                               p[i].line_offset += p[i].line_bytes;
+                                       }
                                }
                        }
                }
        }
        
+       free(p);
        return r;
 }
 
diff --git a/core.h b/core.h
index 750f84f5f92786b88b968242cf2a7d442e9df707..4dab0082b92a9eb9c2d1d3fd9b32b956b74d006f 100644 (file)
--- a/core.h
+++ b/core.h
@@ -1,7 +1,7 @@
  /*
 core.h
 The tool with multiple enhancements and manipulations of pictures
-14.11.2022
+15.11.2022
 
 Copyright (C) 2022  Balthasar Szczepański
 
@@ -187,13 +187,24 @@ int get_info (uint_fast16_t id, struct IL_full_info *info, ILint frame);
 ILuint upscale_value (ILubyte x, ILint bytes);
 ILubyte downscale_value (ILuint x, ILint bytes);
 
-int action_1picture (
+int perform_action_1picture (
        uint_fast16_t id,
-       ILint x0, ILint y0, ILint f0, ILint width, ILint height, ILint frames,
+       ILint x0, ILint y0, ILint f0,
+       ILint width, ILint height, ILint frames,
        ACTION_F *function,
        FLAG_TYPE flags,
        void *f_data
 );
 
+int perform_action (
+       uint_fast16_t n,
+       uint_fast16_t *id,
+       ILint *x0, ILint *y0, ILint *f0,
+       ILint width, ILint height, ILint frames,
+       ACTION_F *function,
+       FLAG_TYPE *flags,
+       void *data
+);
+
 
 ACTION_F action;
\ No newline at end of file
index 52df73c9796f227801edaaea0cd4225f46eb9a17..877eaf4b9bf29bb4d416cb876700b8b910b6d030 100644 (file)
@@ -1,7 +1,7 @@
 /*
 nofading.c
 The tool to remove fading from an image
-13.11.2022
+15.11.2022
 
 Copyright (C) 2015, 2022  Balthasar Szczepański
 
@@ -214,7 +214,7 @@ int subtool_nofading (int argc, char **argv, int argi, char **err)
                        }
                }
                
-               r = action_1picture (
+               r = perform_action_1picture (
                        0,
                        x0, y0, f, width, height, frames,
                        &find_fading_range,
@@ -226,7 +226,7 @@ int subtool_nofading (int argc, char **argv, int argi, char **err)
                        *err = CONVERT_FAILED;
                        return r;
                }
-               r = action_1picture (
+               r = perform_action_1picture (
                        0,
                        x0, y0, f, width, height, frames,
                        &enhance_fading,
index 6d70a27284b34f46472493a1d9cd0bcba8b0d723..f4769bb61e119044c85a04dde01ec2e5531f646b 100644 (file)
--- a/reveal.c
+++ b/reveal.c
@@ -1,7 +1,7 @@
 /*
 reveal.c
 reveal hidden details
-13.11.2022
+15.11.2022
 
 Copyright (C) 2014 - 2019, 2022  Balthasar Szczepański
 
@@ -66,7 +66,7 @@ int subtool_reveal (int argc, char **argv, int argi, char **err)
                return r;
        }
        
-       r = action_1picture (
+       r = perform_action_1picture (
                0,
                0, 0, 0, 0, 0, 0,
                &reveal,