From: b Date: Tue, 8 Nov 2022 22:48:47 +0000 (+0100) Subject: introduce more order in big action runner, not finished. X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=c62d9d074b69832c0852909a840e578f5419a272;p=ott%2Fenhance introduce more order in big action runner, not finished. --- diff --git a/core.c b/core.c index 97301df..20a5f4b 100644 --- a/core.c +++ b/core.c @@ -1,7 +1,7 @@ /* core.c The tool with multiple enhancements and manipulations of pictures -06.11.2022 +08.11.2022 Copyright (C) 2014, 2015, 2022 Balthasar Szczepański @@ -60,6 +60,14 @@ void finish (int const returnvalue, char const * const returntext) exit(returnvalue); } +ILuint get_handle (uint_fast16_t id) +{ + if (id= n_pictures) return EINVAL; - ilBindImage(picture[id].handle); - - // data = ilGetData(); - - get_info(id, &info, 0); - switch (info.image_format) - { - case IL_COLOUR_INDEX: - flags |= IS_INDEXED; - switch (info.palette_type) - { - case IL_PAL_BGR32: - case IL_PAL_RGB32: - flags |= IS_OVER_8BIT; - break; - case IL_PAL_BGRA32: - case IL_PAL_RGBA32: - flags |= HAS_ALPHA; - break; - case IL_PAL_BGR24: - case IL_PAL_RGB24: - default: - break; - } - case IL_LUMINANCE_ALPHA: - flags |= HAS_ALPHA; - case IL_LUMINANCE: - flags |= IS_GRAY; - break; - case IL_BGRA: - case IL_RGBA: - flags |= HAS_ALPHA; - case IL_BGR: - case IL_RGB: - default: - break; - } - switch(info.image_type) - { - case IL_BYTE: - case IL_UNSIGNED_BYTE: - break; - default: - flags |= IS_OVER_8BIT; - } - frames = info.num_images + 1; - if (frames > 1) - flags |= IS_MULTIPLE; - - if ((flags & IS_INDEXED) && (flags & OK_PALETTE_ONLY)) - flags |= IS_PALETTE_ONLY; - if (!(flags & IN_WINDOW)) - { - x0 = 0; - y0 = 0; - width = info.image_width; - height = info.image_height; - } - - line_bytes = info.image_bytes_per_pixel * info.image_width; - frame_bytes = line_bytes * info.image_height; + ilBindImage(picture[id].handle); + get_info(id, &(p.info), 0); - // if (info.origin_mode == IL_ORIGIN_UPPER_LEFT) - // { - // line_start = frame_bytes; - // line_bytes = 0 - line_bytes; - // } - // else - // line_start = 0; + if (p.info.num_images > 0) + p.flags |= IS_MULTIPLE; + frames = (p.flags & CAN_BE_MULTIPLE) ? (p.info.num_images+1) : 1; - if (flags & IS_PALETTE_ONLY) - { + for ( + f = 0; + f < frames; + ++f + ){ + p.f_window = f; + p.f_pict = f; - } - else - { - r_offset = -1; - g_offset = -1; - b_offset = -1; - a_offset = -1; - v_offset = -1; - i_offset = -1; - switch (info.image_type) + ilBindImage(picture[id].handle); + ilActiveImage(z); + p.data = ilGetData(); + p.flags &= ~(IS_GRAY|IS_INDEXED|IS_OVER_8BIT|IS_PALETTE_ONLY); + + p.alpha_offset = -1; + p.value_offset = -1; + p.index_offset = -1; + p.red_offset = -1; + p.green_offset = -1; + p.blue_offset = -1; + + switch (p.info.image_format) { - case IL_INT: - case IL_UNSIGNED_INT: - switch (info.image_format) + case IL_COLOUR_INDEX: + p.flags |= IS_INDEXED; + p.palette = ilGetPalette(); + switch (p.info.palette_type) { - case IL_BGRA: - a_offset = 12; - case IL_BGR: - r_offset = 8; - g_offset = 4; - b_offset = 0; - break; - case IL_RGBA: - a_offset = 12; - case IL_RGB: - r_offset = 0; - g_offset = 4; - b_offset = 8; + case IL_PAL_BGR32: + case IL_PAL_RGB32: + p.flags |= IS_OVER_8BIT; break; - case IL_LUMINANCE_ALPHA: - a_offset = 4; - case IL_LUMINANCE: - v_offset = 0; + 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_COLOUR_INDEX: - i_offset = 0; + 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_SHORT: - case IL_UNSIGNED_SHORT: - switch (info.image_format) - { - case IL_BGRA: - a_offset = 6; - case IL_BGR: - r_offset = 4; - g_offset = 2; - b_offset = 0; - break; - case IL_RGBA: - a_offset = 6; - case IL_RGB: - r_offset = 0; - g_offset = 2; - b_offset = 8; - break; - case IL_LUMINANCE_ALPHA: - a_offset = 2; - case IL_LUMINANCE: - v_offset = 0; - break; - case IL_COLOUR_INDEX: - i_offset = 0; - default: - 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_BYTE: - case IL_UNSIGNED_BYTE: - switch (info.image_format) - { - case IL_BGRA: - a_offset = 3; - case IL_BGR: - r_offset = 2; - g_offset = 1; - b_offset = 0; - break; - case IL_RGBA: - a_offset = 3; - case IL_RGB: - r_offset = 0; - g_offset = 1; - b_offset = 2; - break; - case IL_LUMINANCE_ALPHA: - a_offset = 1; - case IL_LUMINANCE: - v_offset = 0; - break; - case IL_COLOUR_INDEX: - i_offset = 0; - default: - 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; - // for ( - // z=0, frame_offset=0; - // z=0)&&(y= 0) && (p.y_pict < p.info.image_height)) { for ( - x = x0, pixel_offset = line_offset + (x0 * info.image_bytes_per_pixel); - x < x0 + width; - ++x, pixel_offset += info.image_bytes_per_pixel + 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; + ++p.x_window, ++p.x_pict, p.pixel_offset += p.info.image_bytes_per_pixel ){ - if ((x>=0)&&(x=0) && (p.x_pict < p.info.image_width)) { + + + switch (info.image_type) { case IL_INT: @@ -769,17 +692,14 @@ int action_1picture ( return 0; } int action( - ILint x, ILint y, ILint z, - ILuint *r, ILuint *g, ILuint *b, ILuint *a, ILuint *v, ILuint *i, - FLAG_TYPE flags, - void *data + ILuint n, struct PixelInfo *info, void *data ) { printf( "%04lu %04lu %04lu: %03lu %03lu %03lu %03lu %03lu %03lu\n", - (unsigned long)x, (unsigned long)y, (unsigned long)z, - (unsigned long)(*r), (unsigned long)(*g), (unsigned long)(*b), - (unsigned long)(*a), (unsigned long)(*v), (unsigned long)(*i) + (unsigned long)(info->x_pict), (unsigned long)(info->y_pict), (unsigned long)(info->f_pict), + (unsigned long)(info->red), (unsigned long)(info->green), (unsigned long)(info->blue), + (unsigned long)(info->alpha), (unsigned long)(info->value), (unsigned long)(info->index) ); return 0; } diff --git a/core.h b/core.h index c02677a..29dfd29 100644 --- a/core.h +++ b/core.h @@ -1,7 +1,7 @@ /* core.h The tool with multiple enhancements and manipulations of pictures -06.11.2022 +08.11.2022 Copyright (C) 2022 Balthasar Szczepański @@ -64,6 +64,44 @@ struct Picture { ILuint handle; }; +struct PixelInfo +{ + ILint x_window; + ILint y_window; + ILint f_window; + + ILint x_pict; + ILint y_pict; + ILint f_pict; + + ILuint red; + ILuint green; + ILuint blue; + ILuint value; + ILuint alpha; + ILuint index; + + ILint red_offset; + ILint green_offset; + ILint blue_offset; + ILint value_offset; + ILint alpha_offset; + ILint index_offset; + + ILint line_start; + ILint line_bytes; + ILint frame_bytes; + + ILint line_offset; + ILint pixel_offset; + + FLAG_TYPE flags; + void *data; + void *palette; + + struct IL_full_info info; +} + struct IL_full_info { ILint active_image; ILint active_layer; @@ -111,9 +149,7 @@ struct IL_full_info { }; typedef int (ACTION_F)( - ILint x, ILint y, ILint z, - ILuint *r, ILuint *g, ILuint *b, ILuint *a, ILuint *v, ILuint *i, - FLAG_TYPE flags, void *data + ILuint n, struct PixelInfo *info, void *data ); @@ -121,7 +157,7 @@ typedef int (ACTION_F)( void finish (int const returnvalue, char const * const returntext); int init (void); - +ILuint get_handle (uint_fast16_t id); void create_picture (uint_fast16_t id); int create_pictures (uint_fast16_t n); void close_picture (uint_fast16_t id); diff --git a/makefile b/makefile index 3877468..aab5b13 100644 --- a/makefile +++ b/makefile @@ -9,6 +9,9 @@ all: enhance enhance: enhance.c core.h core.c nofading.h nofading.c info.h info.c $(CC) $(CF) -o enhance enhance.c core.c nofading.c info.c $(LF) +#test: test.c core.h core.c +# $(CC) $(CF) -o test test.c core.c $(LF) + clean: rm enhance diff --git a/testimg/4_3_2_t.gif b/testimg/4_3_2_t.gif new file mode 100644 index 0000000..caecdab Binary files /dev/null and b/testimg/4_3_2_t.gif differ