From 761800b47952875344780dcd2b6d1ceb45c1ed0c Mon Sep 17 00:00:00 2001 From: b Date: Sun, 6 Nov 2022 19:13:22 +0100 Subject: [PATCH] more order to this --- core.c | 96 +++++++++++++++++++++++++++++++++++----------- core.h | 26 +++++++++++-- enhance.c | 9 +++-- info.c | 81 +++++++++++++++++++++++++------------- makefile | 18 ++++++--- nofading.c | 6 +-- testimg/4_3_2.gif | Bin 0 -> 130 bytes testimg/4x4x4.gif | Bin 0 -> 145 bytes 8 files changed, 170 insertions(+), 66 deletions(-) create mode 100644 testimg/4_3_2.gif create mode 100644 testimg/4x4x4.gif diff --git a/core.c b/core.c index b39df1c..97301df 100644 --- a/core.c +++ b/core.c @@ -1,7 +1,7 @@ /* core.c The tool with multiple enhancements and manipulations of pictures -05.11.2022 +06.11.2022 Copyright (C) 2014, 2015, 2022 Balthasar Szczepański @@ -36,13 +36,21 @@ on Pentium III libdevil must be recompiled with uint_fast16_t n_pictures = 0; struct Picture * picture; +char INIT_FAILED[] = "Failae to set up library.\n"; char LOAD_FAILED[] = "Failed to load picture.\n"; char CREATE_FAILED[] = "Failed to create picture(s).\n"; +char NO_STR[] = ""; -void init (void) +int init (void) { ilInit(); - ilEnable(IL_FILE_OVERWRITE); + if (!ilEnable(IL_FILE_OVERWRITE)) + return EIO; + // if(!ilEnable(IL_ORIGIN_SET)) + // return EIO; + // if(!ilOriginFunc(IL_ORIGIN_UPPER_LEFT)) + // return EIO; + return 0; } void finish (int const returnvalue, char const * const returntext) @@ -151,7 +159,7 @@ int convert_picture (uint_fast16_t id, FLAG_TYPE flags) if (!(flags & CAN_BE_MULTIPLE)) { - if (ilGetInteger(IL_NUM_IMAGES) > 1) + if (ilGetInteger(IL_NUM_IMAGES) > 0) { fputs("Picture is not allowed to have multiple frames.\n", stderr); return EINVAL; @@ -382,29 +390,56 @@ int load_picture (uint_fast16_t id, char *path, FLAG_TYPE flags) return convert_picture(id, flags); } -void get_info (uint_fast16_t id, struct IL_full_info *info) +int get_info (uint_fast16_t id, struct IL_full_info *info, ILint frame) { + int r = 0; + if (id < n_pictures) + { ilBindImage(picture[id].handle); + if (frame <= ilGetInteger(IL_NUM_IMAGES)) + { + if(!ilActiveImage(frame)) + r = EIO; + } + } info->active_image = ilGetInteger(IL_ACTIVE_IMAGE); info->active_layer = ilGetInteger(IL_ACTIVE_LAYER); info->active_mipmap = ilGetInteger(IL_ACTIVE_MIPMAP); + info->blit_blend = ilGetInteger(IL_BLIT_BLEND); + info->compress_mode = ilGetInteger(IL_COMPRESS_MODE); info->conv_pal = ilGetInteger(IL_CONV_PAL); info->cur_image = ilGetInteger(IL_CUR_IMAGE); + info->default_on_fail = ilGetInteger(IL_DEFAULT_ON_FAIL); + info->dxtc_data_format = ilGetInteger(IL_DXTC_DATA_FORMAT); info->file_mode = ilGetInteger(IL_FILE_MODE); info->format_mode = ilGetInteger(IL_FORMAT_MODE); info->format_set = ilGetInteger(IL_FORMAT_SET); info->image_bits_per_pixel = ilGetInteger(IL_IMAGE_BITS_PER_PIXEL); + info->image_bpc = ilGetInteger(IL_IMAGE_BPC); info->image_bytes_per_pixel = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL); + info->image_channels = ilGetInteger(IL_IMAGE_CHANNELS); + info->image_cubeflags = ilGetInteger(IL_IMAGE_CUBEFLAGS); + info->image_depth = ilGetInteger(IL_IMAGE_DEPTH); + info->image_duration = ilGetInteger(IL_IMAGE_DURATION); info->image_format = ilGetInteger(IL_IMAGE_FORMAT); info->image_height = ilGetInteger(IL_IMAGE_HEIGHT); + info->image_offx = ilGetInteger(IL_IMAGE_OFFX); + info->image_offy = ilGetInteger(IL_IMAGE_OFFY); + info->image_origin = ilGetInteger(IL_IMAGE_ORIGIN); + info->image_planesize = ilGetInteger(IL_IMAGE_PLANESIZE); + info->image_size_of_data = ilGetInteger(IL_IMAGE_SIZE_OF_DATA); info->image_type = ilGetInteger(IL_IMAGE_TYPE); info->image_width = ilGetInteger(IL_IMAGE_WIDTH); + info->keep_dxtc_data = ilGetInteger(IL_KEEP_DXTC_DATA); + info->num_faces = ilGetInteger(IL_NUM_FACES); info->num_images = ilGetInteger(IL_NUM_IMAGES); + info->num_layers = ilGetInteger(IL_NUM_LAYERS); info->num_mipmaps = ilGetInteger(IL_NUM_MIPMAPS); info->origin_mode = ilGetInteger(IL_ORIGIN_MODE); info->origin_set = ilGetInteger(IL_ORIGIN_SET); + info->palette_base_type = ilGetInteger(IL_PALETTE_BASE_TYPE); info->palette_bpp = ilGetInteger(IL_PALETTE_BPP); info->palette_num_cols = ilGetInteger(IL_PALETTE_NUM_COLS); info->palette_type = ilGetInteger(IL_PALETTE_TYPE); @@ -412,6 +447,9 @@ void get_info (uint_fast16_t id, struct IL_full_info *info) info->type_set = ilGetInteger(IL_TYPE_SET); info->use_key_colour = ilGetInteger(IL_USE_KEY_COLOUR); info->version_num = ilGetInteger(IL_VERSION_NUM); + + + return r; } int action_1picture ( @@ -438,9 +476,9 @@ int action_1picture ( return EINVAL; ilBindImage(picture[id].handle); - data = ilGetData(); + // data = ilGetData(); - get_info(id, &info); + get_info(id, &info, 0); switch (info.image_format) { case IL_COLOUR_INDEX: @@ -481,11 +519,9 @@ int action_1picture ( default: flags |= IS_OVER_8BIT; } - frames = info.num_images; + frames = info.num_images + 1; if (frames > 1) flags |= IS_MULTIPLE; - else if (frames < 1) - frames = 1; if ((flags & IS_INDEXED) && (flags & OK_PALETTE_ONLY)) flags |= IS_PALETTE_ONLY; @@ -501,13 +537,13 @@ int action_1picture ( line_bytes = info.image_bytes_per_pixel * info.image_width; frame_bytes = line_bytes * info.image_height; - if (info.origin_mode == IL_ORIGIN_UPPER_LEFT) - { - line_start = frame_bytes; - line_bytes = 0 - line_bytes; - } - else - line_start = 0; + // if (info.origin_mode == IL_ORIGIN_UPPER_LEFT) + // { + // line_start = frame_bytes; + // line_bytes = 0 - line_bytes; + // } + // else + // line_start = 0; if (flags & IS_PALETTE_ONLY) { @@ -614,20 +650,34 @@ int action_1picture ( break; } + // for ( + // z=0, frame_offset=0; + // z=0)&&(yIv{Z-AOwnQXmK)F0{~0%A~FB~ literal 0 HcmV?d00001 diff --git a/testimg/4x4x4.gif b/testimg/4x4x4.gif new file mode 100644 index 0000000000000000000000000000000000000000..a2e6be84c983850bb1df31a8f52b7e4d8c5466a2 GIT binary patch literal 145 zcmZ?wbhEHbWMN=oSjfx(0^#d-rz!pa|6lPxx1VcBu(M-;tC5}oGb2z+@h1xh7sG!B j9gsSZ76vAkmVQoFtP(x_lGr7t^lM_5nA2~`%3uuuvV$6+ literal 0 HcmV?d00001 -- 2.30.2