#include <assert.h>\r
#include <math.h>\r
\r
+#include <rfb/Rect.h>\r
#include <rfb/ScaleFilters.h>\r
\r
using namespace rfb;\r
filter.radius = radius_;\r
filter.func = func_;\r
return filter;\r
-}
\ No newline at end of file
+}\r
+\r
+void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab *weightTabs) {\r
+ double sx;\r
+ double ratio = dst_x / src_x;\r
+ SFilter sFilter = filters[filter_id];\r
+\r
+ weightTabs = new SFilterWeightTab[dst_x];\r
+\r
+ // Make the weight tab for the each dest x position\r
+ for (int x = 0; x < dst_x; x++) {\r
+ sx = double(x) / ratio;\r
+\r
+ // Calculate the scale filter interval, [i0, i1)\r
+ int i0 = int(__rfbmin(ceil(sx-sFilter.radius), 0));\r
+ int i1 = int(__rfbmax(ceil(sx+sFilter.radius), src_x));\r
+ weightTabs[x].i0 = i0; weightTabs[x].i1 = i1;\r
+ weightTabs[x].weight = new float[i1-i0];\r
+\r
+ // Calculate the weight coeffs on the scale filter interval\r
+ for (int ci = 0, i = i0; i < i1; i++) {\r
+ weightTabs[x].weight[ci++] = (float)sFilter.func(float(i)-sx);\r
+ }\r
+ }\r
+}\r