3 The tool with multiple enhancements and manipulations of pictures
6 Copyright (C) 2022 Balthasar SzczepaĆski
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 Requires Dev Image Library (libdevil) (http://openil.sourceforge.net/)
23 on Pentium III libdevil must be recompiled with
24 --disable-ssl2 --disable-ssl3
25 (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572954)
28 // #include <stdlib.h>
35 #define FLAG_TYPE uint_fast32_t
37 #define MUST_HAVE_ALPHA 0x000001
38 #define CANNOT_HAVE_ALPHA 0x000002
39 #define MUST_BE_GRAY 0x000004
40 #define CANNOT_BE_GRAY 0x000008
41 #define MUST_BE_INDEXED 0x000010
42 #define CANNOT_BE_INDEXED 0x000020
44 #define OK_PALETTE_ONLY 0x000040
45 #define CAN_BE_MULTIPLE 0x000080
46 #define CAN_BE_OVER_8BIT 0x000100
48 #define IN_WINDOW 0x000200
50 #define HAS_ALPHA 0x000400
51 #define IS_GRAY 0x000800
52 #define IS_INDEXED 0x001000
53 #define IS_MULTIPLE 0x002000
54 #define IS_OVER_8BIT 0x004000
55 #define IS_PALETTE_ONLY 0x008000
57 #define NOT_WRITABLE 0x010000
58 #define NOT_READABLE 0x020000
60 #define EFF_ALPHA 0x040000
61 #define EFF_GRAY 0x080000
62 #define EFF_INDEXED 0x100000
65 extern char INIT_FAILED[];
66 extern char LOAD_FAILED[];
67 extern char SAVE_FAILED[];
68 extern char CREATE_FAILED[];
69 extern char CONVERT_FAILED[];
70 extern char SIZE_MISMATCH[];
71 extern char MULTIPLE_FORBIDDEN[];
72 extern char INDEXED_REQUIRED[];
73 extern char PALETTE_ONLY_REQUIRED[];
74 extern char BAD_PALETTE_SIZE[];
86 ILint compress_mode; //
89 ILint default_on_fail; //b
90 ILint dxtc_data_format; //
94 ILint image_bits_per_pixel;
96 ILint image_bytes_per_pixel;
97 ILint image_channels; //
98 ILint image_cubeflags; //
100 ILint image_duration; //
105 ILint image_origin; //
106 ILint image_planesize; //
107 ILint image_size_of_data; //
110 ILint keep_dxtc_data; //
117 ILint palette_base_type; //
119 ILint palette_num_cols;
123 ILint use_key_colour;
171 struct IL_full_info info;
185 typedef int (ACTION_F)(ILuint n, struct PixelInfo *info, void *data);
186 typedef int (SUBTOOL_F)(int argc, char **argv, int argi, char **err);
189 void finish (int const returnvalue, char const * const returntext);
191 ILuint get_handle (uint_fast16_t id);
192 int get_data (uint_fast16_t id, void **data, ILuint frame);
193 int get_palette (uint_fast16_t id, void *palette, ILuint frame);
194 int set_palette (uint_fast16_t id, void *palette, ILuint size, ILenum type, ILuint frame);
195 void create_picture (uint_fast16_t id);
196 int create_pictures (uint_fast16_t n);
197 void close_picture (uint_fast16_t id);
198 void close_pictures (void);
199 void clear_pictures (void);
200 int reserve_pictures (uint_fast16_t n);
201 void get_flags (struct IL_full_info *info, FLAG_TYPE *flags);
202 int convert_picture (uint_fast16_t id, struct IL_full_info *info, FLAG_TYPE *flags);
203 int load_picture (uint_fast16_t id, char *path, struct IL_full_info *info, FLAG_TYPE *flags);
204 int load_picture_mem (uint_fast16_t id, const void *address, ILuint size, struct IL_full_info *info, FLAG_TYPE *flags);
205 int save_picture (uint_fast16_t id, char *path, FLAG_TYPE flags);
206 int build_picture (uint_fast16_t id, ILint width, ILint height, ILint frames, struct IL_full_info *info, FLAG_TYPE *flags);
207 int build_picture_from_info (uint_fast16_t id, struct IL_full_info *reference_info, struct IL_full_info *info, FLAG_TYPE *flags);
208 int get_info (uint_fast16_t id, struct IL_full_info *info, ILint frame);
210 ILuint upscale_value (ILubyte x, ILint bytes);
211 ILubyte downscale_value (ILuint x, ILint bytes);
213 int perform_action_1picture_1pixel (
215 ILint x, ILint y, ILint f,
221 int perform_action_1picture (
223 ILint x0, ILint y0, ILint f0,
224 ILint width, ILint height, ILint frames,
233 ILint *x0, ILint *y0, ILint *f0,
234 ILint width, ILint height, ILint frames,
240 int perform_action_palette_mix (
249 int copy_pixels (ILuint n, struct PixelInfo *p, void *data);
250 ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, ILint64 max);
251 int fill_color (ILuint n, struct PixelInfo *p, void *data);
252 int palette_mix_index (ILuint n, struct PixelInfo *p, void *data);
253 ILuint tsqrt(ILuint s);