]> bicyclesonthemoon.info Git - ott/enhance/blobdiff - core.h
Partial CGI update bacause git disagrees with me.
[ott/enhance] / core.h
diff --git a/core.h b/core.h
index 4703a0b07f496bf47ce2542621351f67b0954b3c..999bf5ec9b30c0ed63b53b26ed1f008b0cded00d 100644 (file)
--- a/core.h
+++ b/core.h
@@ -1,7 +1,7 @@
  /*
-enhance.c
+core.h
 The tool with multiple enhancements and manipulations of pictures
-21.10.2022
+03.12.2022
 
 Copyright (C) 2022  Balthasar SzczepaƄski
 
@@ -30,19 +30,224 @@ on Pentium III libdevil must be recompiled with
 // #include <stdio.h>
 // #include <errno.h>
 
-#include "IL/il.h"
+#include <IL/il.h>
+
+#define FLAG_TYPE uint_fast32_t
+
+#define   MUST_HAVE_ALPHA   0x000001
+#define CANNOT_HAVE_ALPHA   0x000002
+#define   MUST_BE_GRAY      0x000004
+#define CANNOT_BE_GRAY      0x000008
+#define   MUST_BE_INDEXED   0x000010
+#define CANNOT_BE_INDEXED   0x000020
+
+#define     OK_PALETTE_ONLY 0x000040
+#define    CAN_BE_MULTIPLE  0x000080
+#define    CAN_BE_OVER_8BIT 0x000100
+
+#define     IN_WINDOW       0x000200
+
+#define    HAS_ALPHA        0x000400
+#define     IS_GRAY         0x000800
+#define     IS_INDEXED      0x001000
+#define     IS_MULTIPLE     0x002000
+#define     IS_OVER_8BIT    0x004000
+#define     IS_PALETTE_ONLY 0x008000
+
+#define    NOT_WRITABLE     0x010000
+#define    NOT_READABLE     0x020000
+
+#define    EFF_ALPHA        0x040000
+#define    EFF_GRAY         0x080000
+#define    EFF_INDEXED      0x100000
+
+extern char NO_STR[];
+extern char INIT_FAILED[];
+extern char LOAD_FAILED[];
+extern char SAVE_FAILED[];
+extern char CREATE_FAILED[];
+extern char CONVERT_FAILED[];
+extern char SIZE_MISMATCH[];
+extern char MULTIPLE_FORBIDDEN[];
+extern char INDEXED_REQUIRED[];
+extern char PALETTE_ONLY_REQUIRED[];
+extern char BAD_PALETTE_SIZE[];
 
 struct Picture {
        uint_fast8_t open;
        ILuint handle;
 };
 
-void finish (int const returnvalue, char const * const returntext);
-void init (void);
+struct IL_full_info {
+       ILint active_image;
+       ILint active_layer;
+       ILint active_mipmap;
+       ILint blit_blend; //b
+       ILint compress_mode; //
+       ILint conv_pal;
+       ILint cur_image;
+       ILint default_on_fail; //b
+       ILint dxtc_data_format; //
+       ILint file_mode;
+       ILint format_mode;
+       ILint format_set;
+       ILint image_bits_per_pixel;
+       ILint image_bpc; //
+       ILint image_bytes_per_pixel;
+       ILint image_channels; //
+       ILint image_cubeflags; //
+       ILint image_depth; //
+       ILint image_duration; //
+       ILint image_format;
+       ILint image_height;
+       ILint image_offx; //
+       ILint image_offy; //
+       ILint image_origin; //
+       ILint image_planesize; //
+       ILint image_size_of_data; //
+       ILint image_type;
+       ILint image_width;
+       ILint keep_dxtc_data; //
+       ILint num_faces; //
+       ILint num_images;
+       ILint num_layers; //
+       ILint num_mipmaps;
+       ILint origin_mode;
+       ILint origin_set;
+       ILint palette_base_type; //
+       ILint palette_bpp;
+       ILint palette_num_cols;
+       ILint palette_type;
+       ILint type_mode;
+       ILint type_set;
+       ILint use_key_colour;
+       ILint version_num;
+};
 
+struct PixelInfo
+{
+       uint_fast16_t id;
+       ILuint handle;
+       ILuint frames;
+       
+       ILint x0;
+       ILint y0;
+       ILint f0;
+       
+       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;
+       ILint pal_offset;
+       
+       FLAG_TYPE flags;
+       void *data;
+       void *palette;
+       
+       struct IL_full_info info;
+};
+
+struct ColorInfo
+{
+       ILuint red;
+       ILuint green;
+       ILuint blue;
+       ILuint value;
+       ILuint alpha;
+       ILuint index;
+};
+
+
+typedef int (ACTION_F)(ILuint n, struct PixelInfo *info, void *data);
+typedef int (SUBTOOL_F)(int argc, char **argv, int argi, char **err);
+
+
+void finish (int const returnvalue, char const * const returntext);
+int init (void);
+ILuint get_handle (uint_fast16_t id);
+int get_data (uint_fast16_t id, void **data, ILuint frame);
+int get_palette (uint_fast16_t id, void *palette, ILuint frame);
+int set_palette (uint_fast16_t id, void *palette, ILuint size, ILenum type, ILuint frame);
 void create_picture (uint_fast16_t id);
-void create_pictures (uint_fast16_t n);
+int create_pictures (uint_fast16_t n);
 void close_picture (uint_fast16_t id);
 void close_pictures (void);
 void clear_pictures (void);
 int reserve_pictures (uint_fast16_t n);
+void get_flags (struct IL_full_info *info, FLAG_TYPE *flags);
+int convert_picture (uint_fast16_t id, struct IL_full_info *info, FLAG_TYPE *flags);
+int load_picture (uint_fast16_t id, char *path, struct IL_full_info *info, FLAG_TYPE *flags);
+int load_picture_mem (uint_fast16_t id, const void *address, ILuint size, struct IL_full_info *info, FLAG_TYPE *flags);
+int save_picture (uint_fast16_t id, char *path, FLAG_TYPE flags);
+int build_picture (uint_fast16_t id, ILint width, ILint height, ILint frames, struct IL_full_info *info, FLAG_TYPE *flags);
+int build_picture_from_info (uint_fast16_t id, struct IL_full_info *reference_info, struct IL_full_info *info, FLAG_TYPE *flags);
+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 perform_action_1picture_1pixel (
+       uint_fast16_t id,
+       ILint x, ILint y, ILint f,
+       ACTION_F *function,
+       FLAG_TYPE flags,
+       void *data
+);
+
+int perform_action_1picture (
+       uint_fast16_t id,
+       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
+);
+
+int perform_action_palette_mix (
+       uint_fast16_t *id,
+       ACTION_F *function,
+       FLAG_TYPE *flags,
+       void *data
+);
+
+
+
+int copy_pixels (ILuint n, struct PixelInfo *p, void *data);
+ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, ILint64 max);
+int fill_color (ILuint n, struct PixelInfo *p, void *data);
+int palette_mix_index (ILuint n, struct PixelInfo *p, void *data);
+ILuint tsqrt(ILuint s);