X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=blobdiff_plain;f=core.c;h=0a3d1c41da19d3670bb4bd1a238113063a1f8384;hb=c9c9c6198f49a3a9159ed2f90753be548f42ecac;hp=6e2928aebebc9dec8afe88e2d4a7b8cf9b713bcc;hpb=8c85da0b525fbdc75e486d1a1c756c77086cb657;p=ott%2Fenhance diff --git a/core.c b/core.c index 6e2928a..0a3d1c4 100644 --- a/core.c +++ b/core.c @@ -1,7 +1,7 @@ /* 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 @@ -1561,6 +1561,67 @@ int palette_mix_index (ILuint n, struct PixelInfo *p, void *data) 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(