/*
core.c
The tool with multiple enhancements and manipulations of pictures
-26.11.2022
+03.12.2022
Copyright (C) 2014, 2015, 2022 Balthasar SzczepaĆski
return 0;
}
-int get_palette (uint_fast16_t id, void **palette, ILuint frame)
+int get_palette (uint_fast16_t id, void *palette, ILuint frame)
{
if (id >= n_pictures)
return EINVAL;
ilActiveImage(frame);
if (ilGetInteger(IL_IMAGE_FORMAT) != IL_COLOUR_INDEX)
return EINVAL;
- *palette = ilGetPalette();
+ *((void **)palette) = ilGetPalette();
return 0;
}
return 0;
}
-
ILuint copy_1p_alpha (ILint64 src, ILint64 dst, ILint64 alpha, ILint64 max)
{
ILint64 v = (src * alpha + dst * (max - alpha)) / max;
return (ILuint)v;
}
+int palette_mix_index (ILuint n, struct PixelInfo *p, void *data)
+{
+ if (n < 3)
+ return EIO;
+
+ p[2].index = p[0].index * p[1].info.palette_num_cols + p[1].index;
+
+ return 0;
+}
+
+ILuint tsqrt(ILuint s)
+{
+ switch(s)
+ {
+ case 256:
+ return 16;
+ case 225:
+ return 15;
+ case 196:
+ return 14;
+ case 169:
+ return 13;
+ case 144:
+ return 12;
+ case 121:
+ return 11;
+ case 100:
+ return 10;
+ case 81:
+ return 9;
+ case 64:
+ return 8;
+ case 49:
+ return 7;
+ case 36:
+ return 6;
+ case 25:
+ return 5;
+ case 16:
+ return 4;
+ case 9:
+ return 3;
+ case 4:
+ return 2;
+ case 1:
+ return 1;
+ default: // not a square - please fail
+ return 0;
+ }
+}
+
+//unsigned short isqrt(unsigned s)
+//{
+// unsigned short r;
+// unsigned short b=0x0040;
+//
+// while(b>s)
+// b>>=2;
+// while(b)
+// {
+// if(s>=r+b)
+// {
+// s-=r+b;
+// r=(r>>1)+b;
+// }
+// else
+// r>>1;
+// b>>2;
+// }
+// return r;
+//}
+
// int action(
// ILuint n, struct PixelInfo *info, void *data