aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/rfb/ScaleFilters.cxx27
-rw-r--r--common/rfb/ScaleFilters.h2
2 files changed, 28 insertions, 1 deletions
diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx
index d5530b72..28fa24f9 100644
--- a/common/rfb/ScaleFilters.cxx
+++ b/common/rfb/ScaleFilters.cxx
@@ -20,6 +20,7 @@
#include <assert.h>
#include <math.h>
+#include <rfb/Rect.h>
#include <rfb/ScaleFilters.h>
using namespace rfb;
@@ -84,4 +85,28 @@ SFilter ScaleFilters::create(char *name_, double radius_, filter_func func_) {
filter.radius = radius_;
filter.func = func_;
return filter;
-} \ No newline at end of file
+}
+
+void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab *weightTabs) {
+ double sx;
+ double ratio = dst_x / src_x;
+ SFilter sFilter = filters[filter_id];
+
+ weightTabs = new SFilterWeightTab[dst_x];
+
+ // Make the weight tab for the each dest x position
+ for (int x = 0; x < dst_x; x++) {
+ sx = double(x) / ratio;
+
+ // Calculate the scale filter interval, [i0, i1)
+ int i0 = int(__rfbmin(ceil(sx-sFilter.radius), 0));
+ int i1 = int(__rfbmax(ceil(sx+sFilter.radius), src_x));
+ weightTabs[x].i0 = i0; weightTabs[x].i1 = i1;
+ weightTabs[x].weight = new float[i1-i0];
+
+ // Calculate the weight coeffs on the scale filter interval
+ for (int ci = 0, i = i0; i < i1; i++) {
+ weightTabs[x].weight[ci++] = (float)sFilter.func(float(i)-sx);
+ }
+ }
+}
diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h
index 0ec0730d..317d0b41 100644
--- a/common/rfb/ScaleFilters.h
+++ b/common/rfb/ScaleFilters.h
@@ -60,6 +60,8 @@ namespace rfb {
SFilter &operator[](unsigned int filter_id);
+ void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab *weightTabs);
+
protected:
void initFilters();